Ds18b20 and relay rule
Moderators: grovkillen, Stuntteam, TD-er
Ds18b20 and relay rule
Hi
How do you write a rule for a sonoff and espeasy with a ds18b20 temp,
I wish to turn relay on or off if temp gets above say 30 degrees or below 30 degrees
Thanks for your help,
How do you write a rule for a sonoff and espeasy with a ds18b20 temp,
I wish to turn relay on or off if temp gets above say 30 degrees or below 30 degrees
Thanks for your help,
Re: Ds18b20 and relay rule
Hello,
I'll give it a try, be aware I couldn't test it.
<task> The name you gave the DS18B20 task.
<value> The name you gave the value within the task, e.g. "temperature"
I've chosen 30° and 29°, not 30° and 30° for a reason.
This gap ("hysteresis") avoids "flickering", a quick on/off/on/off switching if the value is fluctuating around 30°.
If you have a "Sonoff basic" the GPIO for the relay is GPIO12. so the lines should read "gpio,12,1" and "gpio,12,0" for that.
Regards
Shardan
I'll give it a try, be aware I couldn't test it.
<task> The name you gave the DS18B20 task.
<value> The name you gave the value within the task, e.g. "temperature"
Code: Select all
on <task>#<value> do
if [<task>#<value>] > 30
gpio,<GPIO of relay>,1 switches GPIO to high if temperature is above 30°
endif
if [<task>#<value>] < 29
gpio,<GPIO of relay>,0 switches GPIO to low if temperature is above 30°
endif
endon
This gap ("hysteresis") avoids "flickering", a quick on/off/on/off switching if the value is fluctuating around 30°.
If you have a "Sonoff basic" the GPIO for the relay is GPIO12. so the lines should read "gpio,12,1" and "gpio,12,0" for that.
Regards
Shardan
Regards
Shardan
Shardan
Re: Ds18b20 and relay rule
Hi
Thankyou will try later and report back
Thankyou will try later and report back
Re: Ds18b20 and relay rule
Hi,
I needed it, tried it, and Shardan's rule works perfectly !
So thank you very much !
I needed it, tried it, and Shardan's rule works perfectly !
So thank you very much !
-
- New user
- Posts: 4
- Joined: 22 Feb 2018, 20:42
Re: Ds18b20 and relay rule
You need to set threshold level to avoid flickering in your case.Shardan wrote: ↑21 Apr 2017, 20:49 Hello,
I'll give it a try, be aware I couldn't test it.
<task> The name you gave the DS18B20 task.
<value> The name you gave the value within the task, e.g. "temperature"
I've chosen 30° and 29°, not 30° and 30° for a reason.Code: Select all
on <task>#<value> do if [<task>#<value>] > 30 gpio,<GPIO of relay>,1 switches GPIO to high if temperature is above 30° endif if [<task>#<value>] < 29 gpio,<GPIO of relay>,0 switches GPIO to low if temperature is above 30° endif endon
This gap ("hysteresis") avoids "flickering", a quick on/off/on/off switching if the value is fluctuating around 30°.
If you have a "Sonoff basic" the GPIO for the relay is GPIO12. so the lines should read "gpio,12,1" and "gpio,12,0" for that.
Regards
Shardan
Re: Ds18b20 and relay rule
A threshhold says "Switch at x°C".
This - without a hysteresis defined - will directly lead to flickering relays.
It's for a reason i've chosen a wide hysteresis of 1°C for this example.
Rgds
Shardan
This - without a hysteresis defined - will directly lead to flickering relays.
It's for a reason i've chosen a wide hysteresis of 1°C for this example.
Rgds
Shardan
Regards
Shardan
Shardan
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Ds18b20 and relay rule
Here's what happens with a system with no hysteresis...
Thermostat in my bathroom
Thermostat in my bathroom
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Ds18b20 and relay rule
hey... if you modify that a bit you may use it as a kind of pulse width modulation... 

Regards
Shardan
Shardan
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Ds18b20 and relay rule
Hehe probably. I really can't understand how they missed that part...
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- New user
- Posts: 4
- Joined: 22 Feb 2018, 20:42
Re: Ds18b20 and relay rule
I dont think so PWM is the solution.
Just do like this to get rid of it
This is just overview the logic which I meant to and I hope you get my point
Just do like this to get rid of it
First add two local variable for example Lower_Threshold and Higher_Threshold and now set Lower_Threshold value to 29C and for Higher_Threshold set it to 30C and with this setting now you have two fixed values one is 29C and 2nd is 30C and in your case you want to switch that thermostat to set OFF if reach 30C and back ON if its <30 and this is the point you need to use these two threshold levels accept your actual temperature value like this
Code: Select all
on Current_Temp#Current_Temp_Value do
if [Current_Temp_Value #Higher_Threshold ] > 30 // Turn off relay
gpio,<GPIO of relay>,1
endif
if [Current_Temp_Value #Lower_Threshold ] < 29 // Turn on relay with one degree of freedom
gpio,<GPIO of relay>,0
endif
endon
Who is online
Users browsing this forum: Bing [Bot] and 6 guests