# node red dynamic topic

**URL:** https://discourse.nodered.org/t/node-red-dynamic-topic/6632
**Category:** General
**Created:** [9 January 2019 22:54 UTC](https://discourse.nodered.org/t/node-red-dynamic-topic/6632 "2019-01-09T22:54:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![turkdoktoru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/turkdoktoru/32/5111_2.png) [@turkdoktoru](https://discourse.nodered.org/u/turkdoktoru)
#### Post date: [9 January 2019 22:54 UTC](https://discourse.nodered.org/t/node-red-dynamic-topic/6632/1 "2019-01-09T22:54:15Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [10 January 2019 06:18 UTC](https://discourse.nodered.org/t/node-red-dynamic-topic/6632/2 "2019-01-10T06:18:03Z")

</div>

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/](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.

---

<div class="post-metadata">

### Author: ![turkdoktoru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/turkdoktoru/32/5111_2.png) [@turkdoktoru](https://discourse.nodered.org/u/turkdoktoru)
#### Post date: [10 January 2019 16:41 UTC](https://discourse.nodered.org/t/node-red-dynamic-topic/6632/3 "2019-01-10T16:41:14Z")

</div>

very thanks @hotNpipi

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [11 January 2019 21:09 UTC](https://discourse.nodered.org/t/node-red-dynamic-topic/6632/4 "2019-01-11T21:09:51Z")

</div>

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.
