I have a ESP8266 that publishes a temperature reading every 5 seconds.
I subscribe to that topic on my node-red flow, but the values from the esp8266 only updates if I actually publish something back to the esp8266 (switching a relay on/off)
I've search the forum and it seems that I need to use mqtt-dynamic-topic (from here)
I followed the instructions. Did the "npm install node-red-contrib-mqtt-dynamictopic" install, but I still cannot find the node called "mqtt dynamic in" as shown on the page mentioned before.
Any suggestions on how I can get an input mqtt node to get the dynamic data? I am using Dashboard to display the temperature, but as mentioned before, the value does not change unless I issue a command back to the esp from the dashboard.
I have Node Red version 0.20.7 installed
What platform are you running Node-RED on??
The MQTT nodes are part of the core nodes and should appear in the left-hand palette.
I use loads of ESP8266 devices (Wemos D1 Mini) with Node-RED with just the standard MQTT nodes.
If you are running on a Raspberry PI - why not update to the latest version v1.0.2
Check first with a tool like Mqtt explorer if the ESP8266 is really sending every 5 seconds data and on what topic this data is published.
If the ESP8266 is really sending data every 5 seconds it should not be any problem for the default mqqt node in NR to receive this data, no need for some other nodes.
I would be careful using that node, there are reports that it is broken see: Pull requests · rswilem/node-red-contrib-mqtt-dynamictopic · GitHub
I am using Raspberry Pi as my MQTT server. Unfortunately I am booting my Pi from a USB, and the latest Raspbian OS (as from July this year) has a major problem with booting USB and displaying on HDMI, hence I was forced to downgrade the OS.
As for the ESP8266 NodeMCU, I am running MicroPython with Thonny editor. I know the values are being updated. It does show on the debug window every 5 seconds.
I think my problem is in the MicroPython library used for MQTT.
It looks like it only replies back on MQTT once a message was received, but the temperature reading is being updated every 5 seconds.
Hi. Sorry, bad choice of words. Thonny has a "Shell" at the bottom that shows your MicroPython interactions and replies. There the update is updated every 5 seconds.
I have however manage to solve the problem I had.
The original publish command was
I had to add the following ...
client.publish(topic, message, qos=1, retain=False)
My Node Red dashboard is now updated without any interaction from my side. Just what I wanted.
Thanks all for the help and replies