I recently went on a short one week vacation and knew the forecast called for rain while I would be gone. Not knowing what to do about watering the garden, I decided to turn off the sprinkler system while we were away. As it turned out, it rained every day and the large population of rats with hooves (deer) ate the garden down to the roots. At least I didn't waste any water.

I decided to build a remote controlled sprinkler system using a Raspberry Pi running my new favorite automation package, Node Red. Maybe my next project will be a remote controlled or automated Gatling gun to take care of the garden pests.

Here's the schematic of the Raspberry Pi interface I came up with. I added an I2C interface just in case I wanted some kind of remote sensor in the future.

Update: Just for grins I added a BME280 temperature / humidity sensor to monitor conditions inside my workshop.

And here's the Eagle printed circuit board. The interface is a 40 pin ribbon cable and the power and valve interfaces are screw terminals.

Here's the Node Red flow:

and finally the Node Red dashboard:

The flow relies heavily on MQTT. A couple of sections were added to the dashboard that aren't necessarily required for a sprinkler system, but they come in handy for my situation. One section is WiFi status. I have a separate WiFi hot spot in my work shop and wanted to make sure the Raspberry Pi was connecting to it rather than my house WiFi. If the work shop WiFi dies, it can connect to the house router, but with a much lower signal strength.

Another section reports a summary of the local weather conditions. If I'm out of town, I can use this to decide whether or not to disable the system.

A "Disable" section will prevent automatic watering, but can be overridden with the 10 minute override buttons.

The "10 Minute Override" section allows a press of a button to water a zone for 10 minutes. That's very helpful for a particularly hot day.

The "Status" section shows when each valve is energized. I use a "Master" valve in my system and it is energized automatically when a zone is energized. If you don't require a master valve, you can change Node Red to add a watering zone. The "Rain" indicator will light up if the weather report from the "openweathermap" node reports rain in my area and it prevents watering. The Rain RST button will turn this off , but will reoccur if a later report indicates rain. Openweathermap is queried every 10 minutes. At 8:00 PM each night, the rain indicator will automatically be reset so that watering can occur the next day (unless rain comes later that evening or night). 

Watering times and duration are set using a node called "timerswitch". Multiple watering times and duration can be set using this node. I currently have only one zone so if you have more than one, just duplicate the "Timers" section for Zones 2 and 3. Watering times have to be set within Node Red, but I decided that would simplify the dashboard setup. Typically, watering times won't vary much throughout the gardening season.