Multiple DS18B20 temperature sensor (Tasmota->NodeRed->InfluxDB))

Hi there,
I have been tired to resolve an issue for the last couple of days but unfortunately, it seems is over my knowledge so here I am here writing hoping that someone would help me.
I have two DS18B20 sensors connected to WeMos module running tasmota firmware. the flow i have is:


And the message just after the MQTT node is
image
How do I manage to send the data to influxdb?
Currently influxdb only sees the first sensor (DS18B20-1) of course there is influxdb node instead of debug node

1 Like

Take a look at the Info panel for the influxdb node

If msg.payload is an object containing multiple properties, the fields will be written to the measurement.
For example, the following flow injects three fields, numValue , randomValue and strValue into the same measurement with the current timestamp.

msg.payload = {
   numValue: 123.0,
   strValue: "message",
   randomValue: Math.random()*10
}
return msg;

So you need to get your data into that form.
Start by placing a debug node after the JSON node. Where your data will be a javascript object that you can manipulate.
Then use the guide to "working with messages" in the docs Working with messages : Node-RED which will show you how you can identify the right path to a bit of data and use the change node to move them around...

If you get stuck, come back, but hopefully that's enough of a nudge for you to do it.

Side note: you can configure the mqtt node to output json, no need for the json node.

For the last hours I have tried to work it out but since I am back here you know what the answer is.......didn't succeed. I have set up an inject node to simulate json data and tried different options, unfortunately, would not happen today. so here is my test flow I someone could take a look I would be grateful.

[{"id":"e7255c2c.81bb4","type":"inject","z":"e9e4c2cf.74d2","name":"","topic":"tele/Wemos/SENSOR","payload":"{\"Time\":\"2019-07-16T07:16:50\",\"DS18B20-1\":{\"Id\":\"0317714CDDFF\",\"Temperature\":21.9},\"DS18B20-2\":{\"Id\":\"0416A23873FF\",\"Temperature\":22},\"TempUnit\":\"C\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1340,"wires":[["1f5b6b68.dfdfd5"]]},{"id":"1f5b6b68.dfdfd5","type":"json","z":"e9e4c2cf.74d2","name":"","property":"payload","action":"","pretty":false,"x":290,"y":1400,"wires":[["7f7a2070.721908"]]},{"id":"7f7a2070.721908","type":"change","z":"e9e4c2cf.74d2","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"payload[\"DS18B20-1\"].Temperature","fromt":"msg","to":"DS18B20-1","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"payload[\"DS18B20-2\"].Temperature","fromt":"msg","to":"DS18B20-2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1360,"wires":[["a8e33692.179f3"]]},{"id":"a8e33692.179f3","type":"debug","z":"e9e4c2cf.74d2","name":"debuginfo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":640,"y":1340,"wires":[]}]

Unfortunately your flow isn't currently importable.Please read the following post How to share code or flow json and then edit the above message.

You want to Move the data in the change node, and as the influxdb node requires it to be in msg.payload, you need to put it there...

[{"id":"1840b612.f851ba","type":"inject","z":"edaf3fb5.1907c","name":"","topic":"tele/Wemos/SENSOR","payload":"{\"Time\":\"2019-07-16T07:16:50\",\"DS18B20-1\":{\"Id\":\"0317714CDDFF\",\"Temperature\":21.9},\"DS18B20-2\":{\"Id\":\"0416A23873FF\",\"Temperature\":22},\"TempUnit\":\"C\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":179,"y":207,"wires":[["c214567f.495a7"]]},{"id":"c214567f.495a7","type":"json","z":"edaf3fb5.1907c","name":"","property":"payload","action":"","pretty":false,"x":319,"y":267,"wires":[["e31939e1.54ac68"]]},{"id":"e31939e1.54ac68","type":"change","z":"edaf3fb5.1907c","name":"","rules":[{"t":"move","p":"payload[\"DS18B20-1\"].Temperature","pt":"msg","to":"payload.DS18B20-1","tot":"msg"},{"t":"move","p":"payload[\"DS18B20-2\"].Temperature","pt":"msg","to":"payload.DS18B20-2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":489,"y":227,"wires":[["66fce211.fa0b44"]]},{"id":"66fce211.fa0b44","type":"debug","z":"edaf3fb5.1907c","name":"debuginfo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":669,"y":207,"wires":[]}]

I can't thank you enough ukmoose. Thanks, everything is working now.

And I'll try to learn from here on how to place the two sensors DS18B20-1 and DS18B20-2 under the temp something like that

Thanks once again!!!!

1 Like

For those who run into this. Another way to deal with the problem could be with jsonata expression:


still learning, NR is fun :slight_smile:

2 Likes