# Creating flow for DS18B20 sensor and relays on RPI with Node-Red

**URL:** <https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911>\
**Category:** General\
**Created:** [12 September 2021 05:54 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911 "2021-09-12T05:54:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blixen66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/blixen66/32/47876_2.png) [@blixen66](https://discourse.nodered.org/u/blixen66)\
**Post date:** [12 September 2021 05:54 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911/1 "2021-09-12T05:54:16Z")

</div>

I have tried and tried but do not get it, my knowledge is not enough at the moment. I would be very happy if someone could help me with a flow to control a heater using a DS18B20 sensor and two GPIO controlled relays. Relay number one must be activated for 1 second when the temperature drops to 18 degrees Celsius and activated again for 6 seconds when the temperature reaches 24 degrees Celsius. The second relay should be activated for 1 second for every 4 degrees the temperature increases from 0 degrees Celsius and upwards. Is there anyone on this forum who has the time to help me with this?

---

<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:** [12 September 2021 06:43 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911/2 "2021-09-12T06:43:12Z")

</div>

Can you explain what the overall purpose is please? It seems a very odd requirement.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 September 2021 06:43 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911/3 "2021-09-12T06:43:45Z")

</div>

Hi, welcome to the forum.

> [@blixen66](#):
>
> Relay number one must be activated for 1 second

Use a trigger node for this. Send a `true` or `1` then 1 second later send a `false` or `0` (read the built in help for GPIO - i forget if its true/false or 1/0)

> [@blixen66](#):
>
> when the temperature drops to 18 degrees Celsius

Use a switch node for this.

> [@blixen66](#):
>
> The second relay should be activated for 1 second for every 4 degrees

For this, you will need to store the value and test against a remembered value. For this, read up on context.

* * *

As a new user, I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

**Author:** ![blixen66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/blixen66/32/47876_2.png) [@blixen66](https://discourse.nodered.org/u/blixen66)\
**Post date:** [12 September 2021 07:44 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911/4 "2021-09-12T07:44:03Z")

</div>

Hi Colin  
This is to be able to control the temperature of a Chinese heater that otherwise works with a timer and no thermostat

---

<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:** [12 September 2021 07:49 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911/5 "2021-09-12T07:49:44Z")

</div>

Have you looked at node-red-contrib-pid in conjunction with node-red-contrib-timeprop? I am the author of those nodes. One of its prime uses is for the control of heaters to maintain a temperature.

---

<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:** [11 November 2021 07:50 UTC](https://discourse.nodered.org/t/creating-flow-for-ds18b20-sensor-and-relays-on-rpi-with-node-red/50911/6 "2021-11-11T07:50:31Z")

</div>

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