# Temperature sensor functionality

**URL:** https://discourse.nodered.org/t/temperature-sensor-functionality/68790
**Category:** General
**Created:** [10 October 2022 09:24 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790 "2022-10-10T09:24:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [10 October 2022 09:24 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/1 "2022-10-10T09:24:29Z")

</div>

Hello. I have 20 DS18B20 temperature sensors connected to my Pi.  
Every minute the values will be refreshed. Sometimes the value from any sensor does not show the right temperature e.g. 20°C. but 85°C.  
For this wrong value I have a switch. All values under 82°C are OK. If the value is other for more than 5 seconds, then there is a message with sensor FAIL.

What I miss: If the sensor is broken and does not continue to send a plausible value, a message should also appear: SensorFAIL. For this, a permanent update of the sensor value would have to be queried. How can I do that?  
The temperature sensors are for a battery pack. It is necessary to check the values permanently  
and reliable for a safety battery. This is the background for he permanent sensor check.

Here my nodes from one sensor:

```auto
[{"id":"e958ebcc85e2d1a6","type":"trigger","z":"c3f1bf5d5aa9131b","name":"","op1":"","op2":"SensorOK","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":760,"y":1940,"wires":[["f8498cbdc4c54a46","2a92649be426b61d"]]},{"id":"2a92649be426b61d","type":"debug","z":"c3f1bf5d5aa9131b","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1010,"y":1900,"wires":[]},{"id":"f8498cbdc4c54a46","type":"trigger","z":"c3f1bf5d5aa9131b","name":"","op1":"","op2":"SensorFAIL","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"SensorOK","bytopic":"all","topic":"topic","outputs":1,"x":800,"y":1880,"wires":[["2a92649be426b61d"]]},{"id":"8ae24cb28683d449","type":"inject","z":"c3f1bf5d5aa9131b","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":130,"y":1860,"wires":[["c265575fae74d697"]]},{"id":"9159e0cfa6187611","type":"inject","z":"c3f1bf5d5aa9131b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":true,"onceDelay":"0.1","topic":"","payload":"","payloadType":"date","x":130,"y":1720,"wires":[["9f36c32e060f88df"]]},{"id":"3cd72f99b8d4cb4b","type":"change","z":"c3f1bf5d5aa9131b","name":"Welche Zelle & Wert","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"ZelleTemp1:\"& payload","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1720,"wires":[["c66ab942bc80c938"]]},{"id":"c265575fae74d697","type":"switch","z":"c3f1bf5d5aa9131b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"82","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":1720,"wires":[["3cd72f99b8d4cb4b"],["f8498cbdc4c54a46","e958ebcc85e2d1a6"]]},{"id":"b3153aa2f0dda4e4","type":"debug","z":"c3f1bf5d5aa9131b","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":490,"y":1660,"wires":[]},{"id":"c66ab942bc80c938","type":"debug","z":"c3f1bf5d5aa9131b","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1030,"y":1720,"wires":[]},{"id":"9f36c32e060f88df","type":"sensor-ds18b20","z":"c3f1bf5d5aa9131b","d":true,"name":"","topic":"","sensorid":"28-1217b20164ff","timer":"1","repeat":false,"x":330,"y":1720,"wires":[["c265575fae74d697","b3153aa2f0dda4e4"]]},{"id":"9f8e39bdf7494ad3","type":"inject","z":"c3f1bf5d5aa9131b","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"85","payloadType":"num","x":130,"y":1820,"wires":[["c265575fae74d697"]]},{"id":"21d0eefe2af1069c","type":"comment","z":"c3f1bf5d5aa9131b","name":"Real sensor value","info":"","x":510,"y":1620,"wires":[]},{"id":"8cc5f724a493eb8b","type":"comment","z":"c3f1bf5d5aa9131b","name":"If sensor value more than 5 seconds fail","info":"","x":890,"y":1840,"wires":[]},{"id":"e8eba61633ea14fc","type":"comment","z":"c3f1bf5d5aa9131b","name":"Value up to 80°C","info":"","x":860,"y":1680,"wires":[]},{"id":"36df3c7e318d59d7","type":"comment","z":"c3f1bf5d5aa9131b","name":"Test: Click, click, click.....","info":"","x":150,"y":1780,"wires":[]}]

```

[flows (18).json](https://discourse.nodered.org/uploads/short-url/qtCX30GXNXNqKj1f6o3bz03riO1.json) (3.5 KB)  
Thanks for help.

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [10 October 2022 09:46 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/2 "2022-10-10T09:46:04Z")

</div>

Just had a very quick look at your flow and spotted you are triggering the DS18B20 **once every 2-seconds**.  
You will need to look-up the maximum rate you can re-trigger the sensor - I seem to remember it should be a lot higher than that - maybe once every 30-seconds (??).

Try changing the 'inject' node to once every 60-secs, as per your 'spec', and see if that improves things.

---

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [10 October 2022 09:49 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/3 "2022-10-10T09:49:39Z")

</div>

Hello,

thats correct. I have only for the forum the re-trigger in 2 seconds.  
In real situation the re-trigger is every 70 seconds

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

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [10 October 2022 09:55 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/4 "2022-10-10T09:55:31Z")

</div>

If you have a numbers of sensors connected to the same pin on the RPi - you might find it useful to have a look at this thread...

> [@DS18B20 not functioning](https://discourse.nodered.org/t/ds18b20-not-functioning/68769/8):
>
> I'll try 1.5k tomorrow and report back. I'm just surprised that when I clamp a new sensor and an old one together, it doesn't work and when I take two old ones or two new ones, it works. Then it can't normally be due to the resistance?!

I've never had more than 2 or 3 sensors connected to the same pin, so may not be able to help you.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 October 2022 12:01 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/5 "2022-10-10T12:01:15Z")

</div>

> [@Herbert](#):
>
> If the sensor is broken and does not continue to send a plausible value

What do you see from the sensor node in that case?

---

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [30 November 2022 13:36 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/6 "2022-11-30T13:36:16Z")

</div>

Hi Colin,

I don´t know, which signal or how ever I receive in Nodered, of the sensor is broken. This is the issue, why I want to analyse the cycling signal from the sensor.  
If over 3 minute no signal is coming, then alarm. If over 3 minutes the sensor send 85°C, then alarm. Maybe, there is any possibility in Nodered to see the cycle from signal?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 November 2022 14:11 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/7 "2022-11-30T14:11:56Z")

</div>

To run a watchdog that triggers after three minutes of no good data you can use a Switch and a Trigger node, something like this

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f61bb88cbc985e55b669105561cec090eef8d911.png)

```auto
[{"id":"15315cd0a375dfd4","type":"comment","z":"e672d6322ed2b137","name":"From sensor","info":"","x":110,"y":520,"wires":[]},{"id":"f807c4395ad35617","type":"switch","z":"e672d6322ed2b137","name":"Good data?","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"85","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":290,"y":520,"wires":[["ec3e07b0837ad439"]]},{"id":"ec3e07b0837ad439","type":"trigger","z":"e672d6322ed2b137","name":"","op1":"","op2":"Error","op1type":"nul","op2type":"str","duration":"3","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":450,"y":520,"wires":[[]]},{"id":"e415d5f7a6dd635e","type":"comment","z":"e672d6322ed2b137","name":"Error message comes out here","info":"","x":670,"y":520,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [29 January 2023 14:12 UTC](https://discourse.nodered.org/t/temperature-sensor-functionality/68790/8 "2023-01-29T14:12:28Z")

</div>

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