Hello,
I have 100,000 arduino devices. I will connect them all to the node-red network with mqtt. But I don't want to add them all one by one.
How can I add a mqtt entry and dynamically provide it?
Hello,
I have 100,000 arduino devices. I will connect them all to the node-red network with mqtt. But I don't want to add them all one by one.
How can I add a mqtt entry and dynamically provide it?
Your devices should be configured in the (smart) way that you can use wildcards
to listen all devices with only one or couple of MQTT- in node(s). https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/
MQTT - out node takes msg.topic
as input and uses it as MQTT- topic. So you can make your logic in Node-RED to select device you will need to talk to by preparing the message using function or change/switch or template nodes and send prepared message to only one MQTT - out node.
So the MQTT communication part is not an obstacle.
Main thing with this kind of projects is how to make your devices defined in Node-RED so that it will be easy to add or remove them. And as there will be probably a lot of iterations thru devices properties, the definition should be done in the way that deep nesting of iterations can be avoided.
very thanks @hotNpipi
The suggested method is absolutely right.
For example, I have a number of sensor platforms (ESP8266 based) that report temperature and humidity (and sometimes other stuff like light levels, sound levels, etc).
I have topics like TEMPERATURE/D1M01
where D1M01
is a device name. That means I can listen for all temperatures by subscribing to TEMPERATURE/#
or to all sensor values from a single device using +/D1M01
.
Much of the art of using MQTT well is choosing a good set and structure of topics.