Nodered won't connect to MQTT

Hi, Im pretty new to this, but I’m trying to connect a relay to my emonpi via Nodered.
The emonpi is brand new and has the pre-loaded SD. It’s also posting to emonCMS.
When I configure an MQTT input node to reference any of the emonpi topics the node won’t connect.
If I reboot the emonpi I get a message (below the node) to say it’s connecting but eventually it goes back to disconnected.
As far as I can tell the MQTT server is posting the data as it shows in the emonhub log. The config file also has the MQTT username/passwords: emonpi/emonpimqqt2016
Sorry if this is covered elswhere but I can’t seem to find anything. Thanks in advance for any help.

Can you post the flow JSON please? to do that select the flows by dragging the mouse over them then on the hamburger menu top right, select export, then clipboard and (with the text in the window highlighted), click export to clipboard. You can then paste it in a message here like this. put 4 left ticks (not apostrophes) before and after the text to put it in a box.

[{"id":"f53cfc06.fab2f8","type":"debug","z":"25471496.37cf34","name":"","active":true,"console":"false","complete":"true","x":670,"y":320,"wires":[]},{"id":"b889d5d7.f53b2","type":"catch","z":"25471496.37cf34","name":"","scope":null,"x":500,"y":320,"wires":[["f53cfc06.fab2f8"]]}]

Could you also explain a little about what you are trying to do. It may be better on a Node-red forum if it is a general Node-red issue.

Thanks for the reply but you lost me with the “hamburger”.
I told you I was new to this.
I’m trying to set up the emonpi to control the MQTT relay depending on the electricity export.

The icon with 3 horizontal bars - “sandwich”?

Common term for the 3 horizontal lines at the top right of the node-red page (and other pages) indicating a menu.

image

We all were new once.

So you are sending data to Node-red from Emoncms?

Yes, or at least I’m trying to.
I think I must be missing something somewhere as I assumed I just told nodered to subscribe to the topic on the emonpi.

So on your inputs page on Emoncms, you have something like
image

Yes, I do,

Ok great. So in the text for the process it will look like

image

Are you happy to SSH into the EmonPi? If so, using the guide here if you use the command

$ mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t ' emoncms/#'

(substitute the right user/password and topic name - th # simply means all sub-topics) you should then see your published data.

I’m afraid I’ll need help with getting into the emonpi with SSH.

Ok so, plenty on google but assuming you are on windows 10, easiest way is to download and install putty http://www.putty.org/ and google ‘using putty’. IP can be got from the LCD screen. Once at the command prompt, type in the command above.

OK thanks for all the help. I’ll do a bit of research and let you know when I’m up to speed.

Good morning.
I’m connected to the emonpi by SSH but when I type in the command (it took me a while to realise that it was “P” not “p”) the cursor moves to the next line and nothing else happens.

Sorry I jumped the gun a bit there. I have the feeds showing now. I was using the wrong topic .

Great - a useful skill to have.

You see the topics at the command line? If so double check what you have in th Node-red node. Do you have a leading ‘/’ by any chance?

If you use the ‘snipping’ tool in Windows (7 upwards) you can take a snap of a bit of your screen and just paste it into this comment box.

Thanks for all the help Brian. I managed to figure it out in the end. I was just confused about the feed names.

1 Like