One of the functions I have my ESP8266 undertaking is control of the sump level in my Aquaponics system.
Because it's a 'flood and drain' setup, sometimes the sump will overflow if the timings should synchronise accidentally. So I need to create a ruleset that runs the standard flood & drain cycle but also checks regularly to ensure the sump level isn't too high (and if it is, switch the solenoid valve back on out of cycle to dump the excess water back into the Aquaponic Tubs).
Because my Ultrasonic Water Level Detector points down, the lower the number of centimeters, the higher the level of the water. I do not want the water level to drop below 25cms (away from the ultrasonic sensor) as that's the level where it starts overflowing.
GPIO2 controls a relay that opens a solenoid valve to the tubs.
Here's my ruleset - I am a beginner at ESP8266, ESP Easy and Programming. So please bear with me!
Code: Select all
On System#Boot do
gpio,2,0 //if the solenoid is open, close it
timerSet,1,10
endon
On Rules#Timer=1 do
gpio,2,1 // open the solenoid for 5 minutes
timerSet,2,360
endon
On Rules#Timer=2 do
gpio,2,0 // close the solenoid for 30 minutes to drain the tubs
timerSet,1,1800
If [depth#centimeters] < 30
gpio,2,1 // check to ensure the sump isn't flooding, if it is, turn the solenoid on out of cycle.
else
gpio,2,0
endif
endon
Cheers, Jason