Joining mqtt messages with multiple sensors

Hi,

Let’s say I have 10, 20 or 50 sensors located around a building that transmit temperature and humidity data through mqtt in topics such as:

sensors/sensor1/temperature
sensors/sensor1/humidity

I would like to combine these in to a single message to add in to a database. I can use the join node to do this just fine.

My question, if I have a single mqttin node using wildcards to receive all the messages from the sensors, is the join node clever enough to only join messages from the same mqtt client? How will it handle multiple mqtt clients sending data in at the same time and is it possible for the wrong two messages will be joined?

Alternatively am I better to just send a single mqtt message containing both the temperature and humidity data as json etc?

When adding the data to the database I want to associate the sensor it came from. Should I pass the sensor name in the payload with the readings or extract it from the topic?

Any suggestions on how best to handle this would be appreciated.

If you have the ability to send both temperature and humidity in the same msg, that means you can eliminate the join but may mean more coding in the sensors.

Hi, Thanks for the response. Yes, I can code it on the sensors as they are ESP32's with Micropython.

Just trying to gauge the balance between the easy way and the right way. So many examples show sending temperature and humidity as separate topics. Was just interested in people's opinions.

As it is too easy to identify the target sensor and measurement from separated topics (in case of MQTT in node uses wildcard) I'd do nothing to change that route.

image

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.