Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

MQTT PUB und SUB funktionieren nicht

2022-07-17
2022-08-17
  • master-student - 2022-07-17

    Ich habe das mqtt-Beispielprojekt befolgt, das in der Bibliothek enthalten ist, und es scheint, dass der mqtt_client eine Verbindung zum Brocker herstellt. aber es gibt einen Fehler im Veröffentlichungs- und Abonnementteil. bitte helfen. Danke

     
  • kais - 2022-08-05

    hallo
    ich habe auch die gleich Bibliothek , die du befolgst hast.das hat bei mir nicht funktionniert. Als Beispiel habe ich sHostname :'test.mosquitto.org' und port : 1883 gegeben. Als client habe ich als beispiel kais genommen.
    Wenn ich mich mit dem NUC verbinde und einlogge , dann wird xError auf True gesetzt und eMQTTError zeigt NO_ERROR . Zudem findet es keine Verbindung in xConnectetToBroker statt.
    Als anhang schicke ich dir zwei screenshots. Auf den ersten bild ist Codesys im Run Modus zu sehen und auf den zweiten ist Mosquitto im lokal Run Modus.
    Ich hätte eine Frage was hast du als Brücke benutzt ?
    Ich hoffe,dass du mich dann ja helfen kannst zumindest was ich bei den Einstellungen drauf achten muss, damit ich das ins Laufe bringe und danach geht es weiter mit meiner Masterarbeit.
    und Vielen Danke im voraus

     
  • master-student - 2022-08-11

    hi, I am using a beaglebone black to send data from temperature sensor to my pc through lan cable. Meaning I am not using online mode. but I had similar problem with connection to brocker.

    what i did is : I turned on mosquitto brocker in my Beaglebone black (BBB) terminal using the command (mosquitto -v) and i run the code again in BBB and the client is connecting to the brocker and i receaved a notification in the BBB terminal. hope this will be helpful.

     
  • kais - 2022-08-15

    Can you explain me what configuration you have changed in "mosquitto.conf" because I don't use also the online mode, but an IP address.
    I just changed the following lines at the end of the file:
    listener 1883
    allow_anonymous true

     

    Last edit: kais 2022-08-15
  • master-student - 2022-08-17

    hi, looks lik your configuration is right.
    I am guessing that you are using raspberry pi as the device.
    first step is to install mosquitto brocker on rasp pi.
    then run it in the rasp pi using the command 'mosquitto -v'
    thnen load the codesys programm on to the rasp pi.

    Make sure you are using the right ip, or you can simply use locakhost as host name.

     

    Last edit: master-student 2022-08-17

Log in to post a comment.