Water Level Control Relay Rule

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Michael_BruceLee
Normal user
Posts: 10
Joined: 16 Feb 2018, 12:06

Water Level Control Relay Rule

#1 Post by Michael_BruceLee » 16 Feb 2018, 12:12

Hi Guys,

i´m new to the Rules business and i´ve built together a Waterlevel Sensor (HC-SR04) with an NodeMCU V3 Board and want to toggle a 1channel Relay when a certain Waterlevel has reached.
It´s for my Dog´s trinkin place ;-)
So for example his watter bowl is full and the distance betwenn the water and the sensor is 40cm, and he comes and drinks out of his bowl the waterlevel decreases to for example 20cm distance to the sensor, esp easy should toggle my relay to pump new water in the bowl. The relay should be toggled for about 20sec. to not overfill the bowl.
how do i write this rule? i´ve tried a lot but nothing works, as i´ve said i really ned your help because i´m new to the rules game here.
would be awesome if someone could help me out here!!
thanks a lot

Mike

Michael_BruceLee
Normal user
Posts: 10
Joined: 16 Feb 2018, 12:06

Re: Water Level Control Relay Rule

#2 Post by Michael_BruceLee » 16 Feb 2018, 12:14

sorry i mean if he waterlevel increase when he drinks to for example 60cm....

User avatar
budman1758
Normal user
Posts: 303
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Water Level Control Relay Rule

#3 Post by budman1758 » 17 Feb 2018, 17:21

Have you read the Wiki page?
https://www.letscontrolit.com/wiki/inde ... rial_Rules

What you want to do is quite easy.
"The glass is twice as big as it needs to be".

Michael_BruceLee
Normal user
Posts: 10
Joined: 16 Feb 2018, 12:06

Re: Water Level Control Relay Rule

#4 Post by Michael_BruceLee » 18 Feb 2018, 14:26

thanks for your reply.
yes i´ve read the wiki page but i don´t get is ;-) as i told you it´s my first rule.
and i don´t know how to connect these 3 things ( ultrasonic sensor, relay, motion sensor)
the motion sensor because everything should be off if the dog is around and drinks.
so for my logic it should be something like:
bowl empty (45cm)
bowl full (35cm)

if ultrasonic sensor > 44cm
then send command on to relay switch
if ultrasonic sensor > 35cm
then send command off to relay switch

but the syntax is more then wrong ;-) and i don´t really know how i will put the motion sensor in there.

thanks for your help

Michael_BruceLee
Normal user
Posts: 10
Joined: 16 Feb 2018, 12:06

Re: Water Level Control Relay Rule

#5 Post by Michael_BruceLee » 18 Feb 2018, 14:40

on Wasserstand#Distance>44 do
if [Bewegung#Contact]=0
gpio,13,0
else
gpio,13,1
endif
endon

Ultrasonic Sensor Name = Wasserstand, Value: Distance
Pir Sensor Name = Bewegung, Value: Contact , 1=On, 0=Off
Relay Switch Name = Relay, Value: Switch, gpio 13 , 0=On, 1=Off

would this be right? but how do i connect the relay toggle off rule when distance is <35?

User avatar
budman1758
Normal user
Posts: 303
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Water Level Control Relay Rule

#6 Post by budman1758 » 18 Feb 2018, 18:42

You did not mention the pir sensor at first. That changes things quite a bit because rules don't allow multiple "if" or "and" statements. So I would look at creating "events" based on the water level. This way you can make up for the rule limits. Something like this....

On [waterlevel]=50
event,fill
else
endon

on fill do
if pir = whatever
gpio 1 1
else
gpio 1 0

Something along those lines. Using events allows you to take more than one thing into consideration when evaluating what to do and when to do it. Also you can use either the pulse commands for the gpio or timers so the water does not overfill. :lol:
Hope this is helpful.
"The glass is twice as big as it needs to be".

Michael_BruceLee
Normal user
Posts: 10
Joined: 16 Feb 2018, 12:06

Re: Water Level Control Relay Rule

#7 Post by Michael_BruceLee » 20 Feb 2018, 22:38

thanks alot man!!! now it works!!
great!!

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests