I'm new to node red and have an issue with multiple devices.
I've managed to send data from my esp via mqtt to node-red. this data is processed and stored in influxDB. so far so good, everything worked.
the next step was to multiply the devices sending messages. when I start my second esp (same code), the MQTT messages are arriving at node red, but the messages from the previous device are no longer arriving. When I reset the first device the messages from the first device are here, but the messages from the second device no more.
It seemed to me that only one device can send on one topic. So I created a new topic for the second device but the results were the same: only messages from one device were arriving at node red.
Are you setting unique MQTT client ID for the esp devices?
Check your brokers logs
Ps, yes, you need unique topics. How else would you know which device is sending data?
You could always use the MAC address to form part of the topic (and client ID) to make them unique (and therefore keep your esp code the same/portable)
As @Steve-Mcl has said you should check your broker logs. You can also use MQTT Explorer (http://mqtt-explorer.com) to look at messages in real time to see if they are in fact being sent but not being received correctly by your MQTT-in nodes.
I have a similar setup with multiple ESP-based devices sending sensor readings or receiving commands, and although most messages have unique topics there are some which I use a fixed topic for, as I'm not worried which device it came from.
thanks for the answers.
I checked the broker logs and noticed that I can't have the same code twice because they both had the same mqtt client id and therefore the mqtt broker disconnect the first one.
There's a chance that using random() could give a repeated ID, especially if it's done quite early the startup code, before any variable time steps like connecting to the WiFi. I've gone with using the MAC address as mentioned by @Steve-Mcl as it's supposed to be unique for every device.
eta : unless the random seed is set "randomly" during startup, you'll actually get the same value every time, so it's probably not a good way to set the client ID...