Dead of winter, what better time to think about smart sprinkler algos! Trying to piece some ideas together. This is what Ive got
Weather API
-
chanceOfRain: % chance of rain -
forecastRainLevel: Amount of rain predicted -
rainLevelYesterday: How much it rained yesterday
Constants
-
desiredLevel: level (inches) of amount of water per cycle -
applicationRate: measure rate of sprinkler flow (inches/second) (you have to doink around with times/measurements to get this)
Run Time Variables
-
runTime: How long the sprinklers are run (seconds)
Persistent Variables
-
lastRun: timestamp of the last scheduled run -
levelApplied: the amount of water applied during scheduled run (calculated based on applicationRate * runTime) -
levelYesterday: Amount of water applied added with the amount of rain reported
Assumptions
- A scheduled run completes and provides the proper water level
- Water every other day, pending day-before/day-of rain
- Weather API current day rain level is accurate
Process
// right before midnight
- grab current days rainLevel
- add rainLevel to any watering level done via sprinklers
- levelYesterday = rainLevelToday + levelApplied
// at scheduled time in AM
if `levelYesterday` < `desiredLevel`:
// either no watering or not enough rain
`rainLevel` = `forecastedRainLevel`
if `chanceOfRain` < 60:
// roll the dice that it wont rain
`rainLevel` = 0
end
`levelNeeded` = `desiredLevel` - `rainLevel`
`waterTime` = `levelNeeded` * `applicationRate`
// run sprinklers for waterTime (s)
else:
// do nothing yesterday met requirements
end
Problems
- What if
levelYesterdaywas jus slightly less thandesiredLevel - Maybe need a 2 day running total? Because in theory, the
desiredLevelis over two days? - This hurts my brain
Would love some others perspective. Its things like this that I also wonder, isnt it easier to just click a button the night before that tells the system "Run the sprinklers in the AM" .. but making logic is fun
