MQTT with ESP8266 and Node-Red

I am total noob with Node-Red/mqtt, but am trying to teach myself with (what I thought was) a simple example.

I want to send an mqtt message from my Hazzah ESP8266 module to Node-Red, but cannot get it to work.

I started with Adafruit’s digital_in project that sends an mqtt message to my dashboard on their io.adafruit.com site every time I press a button on i/o port 2.

I compiled and downloaded that (using Arduino IDE) to the ESP and it works fine.

I then modified the code to send the same message to Node-Red on my emonpi (emonSD-07Nov16), but it fails with “Not authed”.
Arduino debug output:

Connecting to MyWiFi

WiFi connected
IP address:
192.168.2.54
Connecting to Adafruit IO… Not authed
Retrying connection…

This is my flow:

[{“id”:“8d34a3a1.78e738”,“type”:“mqtt in”,“z”:“8994967a.1e2ea”,“name”:“”,“topic”:“#”,“qos”:“2”,“broker”:“a8cb6a09.24f778”,“x”:375,“y”:215,“wires”:[[“ca33f55.94b5608”]]},{“id”:“ca33f55.94b5608”,“type”:“debug”,“z”:“8994967a.1e2ea”,“name”:“debug”,“active”:true,“console”:“false”,“complete”:“payload”,“x”:521,“y”:215,“wires”:},{“id”:“a8cb6a09.24f778”,“type”:“mqtt-broker”,“z”:“8994967a.1e2ea”,“broker”:“192.168.2.55”,“port”:“1883”,“clientid”:“”,“usetls”:false,“verifyservercert”:true,“compatmode”:true,“keepalive”:“15”,“cleansession”:true,“willTopic”:“”,“willQos”:“0”,“willRetain”:“false”,“willPayload”:“”,“birthTopic”:“”,“birthQos”:“0”,“birthRetain”:“false”,“birthPayload”:“”}]

And this is my ESP8266 code:

emon_mqtt.ino.txt (4.1 KB)

I think I must be getting my names, topics, IDs etc muddled up or something.
Or have I misunderstood how it should work?

Looking at the log I would check your MQTT username/password;

if it is the SD card defaults the password is emonpimqtt2016.

thanks @jeremypoulter that was it. :+1:

I didn’t know to look for another different password, so was looking for some fundamental problem.
I don’t want to remember how long I spent trying to figure that out! :rolling_eyes: