Hello guys, I'm developing an IoT project and I'm sending data from my ESP32 to an MQTT broker and I want to build a dasboard on Node-red. I'm sending it in JSON form, because I read that this is the best form when it comes to MQTT. How do I separate the variables that are inside JSON? For example, I will have readings from temperature, humidity and air quality sensors, all coming together in JSON. I want to separate this information to set up a dasboard .. Follow what I have done so far, my sensors haven't arrived yet, that's why the strange numbers.
Set the MQTT In node to return a Parsed JSON object (it is in the node configuration). That will parse the JSON string and convert it to a javascript object.
I see you are writing the data as an array, it might be better to write the values to separate properties rather than relying on the array order, so in the ESP you could send {"temperature": 21, "humidity": 45, ...}
then after it comes out of the MQTT node you will be able to usemsg.payload.temperature.
I can't configure ESP in this format {"temperature": 21, "humidity": 45, ...} because I am sending an entire package from another LoRa device. So I get a buffer with all this data and send it to MQTT. Do you know any function in javascript that I can get each position of this array?
Ah yes, it works! But I wanted to separate right after MQTT to build a dashboard .. I'm still learning how to use Node-red, I apologize for the simple questions