A remotely-accessible sprinkler controller built using Home Assistant and Raspberry Pi 3B+
I wanted a fairly simple sprinkler controller that could handle up to 8 valves and run sequential schedules at certain times of the day and for certain days of the week. I run Home Assistant for general home automation and wanted to integrate the sprinkler scheduling into my existing setup.
- Remote/mobile access via Home Assistant mobile app and remote access
- Multiple schedules that can be toggled on/off with configurable runtime for each valve
- Ability to delay or schedule off-time for all schedules to account for precipitation
- Manual control of each sprinkler valve for inspection/calibration
- Enforce only one valve open at a time; I don't have the water pressure to run multiple valves at once and most controllers only allow for one to run at a time
- Raspberry Pi 3B+ with power source
- BUD Industries electric/utility box
- Plastic internal panel to secure parts
- 24VAC to 5V DC converter Convert AC from transformer to 5V DC to power the relay
- Jumper wires
- 5V 8 relay board For switching sprinkler valves on/off
- 24VA 1.6A transformer Power for opening sprinkler valves and power to buck converter
This is a slightly modified design from other common Raspberry Pi-based sprinkler controllers. Instead of powering the relay off of the Pi board, an AC to 5V DC buck converter is wired to the 24VAC transformer to power the relay via the JCC-VD pin (jumper removed). With the jumper in place the 5V pin for the inputs would also power the relay coils, however a Pi 3B+ has a maximum output of somewhere around 200 mA and may not be enough to power the board if all 8 coils are on. While the sprinkler code forces only one coil to be on at a time, I wouldn't consider it a "proper" design to run anything with the potential to draw more current than a given component can provide. And while Pi's are reasonable cheap, it would be a shame to burn one up with excessive power draw. The 1.6A transformer provides plenty of spare amperage to tap into for the buck convertor, but technically isn't required. The choice is yours.
Another thing to note is the absence of an inline fuse. I debated whether to add one between the buck converter and the relay but wasn't sure how necessary this was. It would seem to me that the source of any electrical surge would come from the outlet, and the transformer is internally fused (which if tripped would require replacement), so adding any additionally fuses downstream would be unnecessary and only protect against wiring faults. I'm no expert on this, but if you think an inline fuse is appropriate somewhere let me know.
The code includes two files. The sprinklers.yaml file contains all of the scheduling code and is loaded as a package via the Home Assistant config file. The Sprinkler Scheduler View.yaml file contains code the can be pasted into the raw view of the LoveLace frontend editor. This will provide a single view for calibrating the sprinkler system as well as schedule delays and determining when the system will run next.
- If Home Assistant or the Raspberry Pi shuts down, the sprinkler valves will close so there is no chance the sprinkler system will stay on in case of a hardware or software failure (barring some kind of mechanical problem with the sprinkler valves themselves).
- If Home Assistant reboots or the schedule is toggled off/on, the code will resume a running schedule and calculate the remaining runtime for the scheduled zone.
My Home Assistant Raspberry Pi lives in my garage where it also runs a Z-wave network along with some other integrations. The Pi connects to my home network using an ethernet drop that runs to a POE switch. I use a POE hat to provide power to the Pi.
- Weather/precipitation integration. I intially tried to automate this based on recorded precipitation from one of the weather API integrations in Home Assistant. However I found it easiest to just manually set a schedule delay after checking the forecast. With a traditional controller I would often forget to turn the sprinklers back on after turning them off for rainy days and this was enough to overcome this problem. However I may try to incorporate a rain sensor into the setup at a later time.
- Schedule that runs every N days instead of certain days of the week