Posting to MQTT does not work

(Stephan Kluge) #1

I am running EmonCMS on a separate RPi ( Now I want to post several values from my feeds to my already running MQTT broker running on a different RPi (
My broker is working correctly. It receives data from my EmonESP and some other ESP’s.
I configured my emoncms/settings.php:

//3 #### MQTT
    // The 'subscriber' topic format is rx/* - where * is the emoncms input node number.
    // The 'publisher' topic format is user selectable from the 'Publish to MQTT' input process, for example power/solar
    $mqtt_enabled = true;          // Activate MQTT by changing to true
    $mqtt_server = array( 'host'     => '',
                          'port'     => 1883,
                          'user'     => '',
                          'password' => '',
                          'basetopic'=> '/emon',
                          'client_id' => 'emoncms'

My broker does not require username or password. I added “publish to MQTT” in my process list

but unfortunately my broker doesn’t get any data on /emon/emoncms/#

I don’t know where to look

(Brian Orpin) #2

I am not sure that the MQTT connections made by emoncms can be anonymous. Not certain a blank user/password works. I’d need to check if this still does not work.

Should be no leading /

Note this base topic is the incoming topic so do not use the same base topic when publishing else you create a loop.

Did you use a leading / in the publishing topics? It should be something line emoncmsout/temp1 and for a second topic emoncmsout/temp2.

You can test MQTT from the command line using the mosquitto_pub and mosquitto_sub commands (search on the community for examples).

(Stephan Kluge) #3

I changed it back to emon without leading /

The fault was on my side… Somehow I did not install the mosquito engine properly… Now as I fixed this MQTT is working fine