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

**URL:** <https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345>\
**Category:** General\
**Created:** [16 July 2019 10:18 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345 "2019-07-16T10:18:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ventzitt](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@ventzitt](https://discourse.nodered.org/u/ventzitt)\
**Post date:** [16 July 2019 10:18 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/1 "2019-07-16T10:18:29Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1740411f572225cbaf9a68a79f4c141945f1c567.png)  
And the message just after the MQTT node is  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fed715276d293a56767713f3b50dd4bdec6e2b57.png)  
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

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 July 2019 10:40 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/2 "2019-07-16T10:40:01Z")

</div>

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.

```auto
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](https://nodered.org/docs/user-guide/messages) 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.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 July 2019 11:33 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/3 "2019-07-16T11:33:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ventzitt](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@ventzitt](https://discourse.nodered.org/u/ventzitt)\
**Post date:** [16 July 2019 12:25 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/4 "2019-07-16T12:25:25Z")

</div>

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 July 2019 12:26 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/5 "2019-07-16T12:26:34Z")

</div>

Unfortunately your flow isn't currently importable.Please read the following post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and then edit the above message.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 July 2019 12:37 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/6 "2019-07-16T12:37:41Z")

</div>

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...

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![ventzitt](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@ventzitt](https://discourse.nodered.org/u/ventzitt)\
**Post date:** [16 July 2019 12:49 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/7 "2019-07-16T12:49:31Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a0d9e4a840f2729a4c597de810ecd8edc091e4ea.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/309781dac76dcdfb045801f2ae08f39cbd702f16.png)

Thanks once again!!!!

---

<div class="post-metadata">

**Author:** ![ventzitt](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@ventzitt](https://discourse.nodered.org/u/ventzitt)\
**Post date:** [17 July 2019 10:14 UTC](https://discourse.nodered.org/t/multiple-ds18b20-temperature-sensor-tasmota-nodered-influxdb/13345/8 "2019-07-17T10:14:26Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3fc335d5c1bde738a1bc9b12b22fc6057cb2d490.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0ce5212f5d2de1b1b5d2c09430c2817abe049b3e.png)

still learning, NR is fun 🙂
