Monday, September 2, 2013

Automated Sprinkler System First Look

Our sprinkler system is now controlled by a Raspberry Pi! Achievement Unlocked.

Raspberry Pi Sprinkler Controller

With a little bit of Python and web development, we can now control the sprinkler system from a simple to use web interface and Google Calendars. The Raspberry Pi controller was actually pretty simple to setup. I simply connected several free GPIO pins to an relay module, connected the sprinkler valves to the relay module, and then control the relay module with a Python script.
8 Channel Relay Module(~$15)

A standard sprinkler system uses a 24 VAC line to power a sprinkler valve. When 24 VAC is applied to the line, the sprinkler valve opens and the lawn is watered. Remove the 24 VAC and the valve closes. Obviously we could not connect 24 VAC directly to the Raspberry Pi, so instead we hide it behind a relay (electrically operated switch) which physically isolates the two circuits.

To build a relay circuit would requires a transistor-resistor-diode-relay. As our sprinkler system has 8 "zones", and each zone would require one of these transistor-resistor-diode-relay circuits, this would have been quite a mess to assemble. Luckily there are numerous pre-built Relay Modules, such as the SainSmart 8-Channel 5V Relay Module for Arduino($15), that come in a variety of sizes to fit one's needs.

To connect the Raspberry Pi to the relay module, connect the 5V GPIO pin to the VCC pin on the relay module, then connect the Ground GPIO pin to the GND pin on the relay module, and finally connect 8 (or as many zones as you have) free GPIO pins to the relay module. Next connect one sprinkler valve line to each relay, and finally connect the common ground line to the other side of each relay. Now the sprinkler valves can be turned on and off from the Raspberry Pi using the GPIO output functions.

Schematic of Raspberry Pi Sprinkler Controller

With some Python, HTML and Javascript I then created a simple web interface that my wife could turn on and off the sprinkler system with.
Sprinkler Control Web Interface

When a zone is activated, the web interface highlights that zone and blinks on/off till the watering program has completed.
Zone 1 Activated

Finally, I wrote a Python daemon that runs in the background, probing Google Calendars. This allows the sprinkler system to be scheduled out in advance. Originally I was using a simple Cron Job scheduler, but I wanted something simple that my wife could also set.

Google Calendar Scheduling

The remote web interface access also allows for a really cool, and obvious, feature. We can now walk out into the back yard, with our tablets / cell phones, and control the sprinkler system right in front of our eyes. Instant gratification.

This remote control capability has led to a silly game that my kids absolutely enjoy. We would turn on a sprinkler zone at one side of the yard, and the kids would run towards it. Then we would turn on the sprinkler zone at the other end of the yard, and the kids would run there. They would enjoy this back and forth game until they were too cold to continue. Oh the sweet, simple things of life.


  1. Hi, coincidentally this is exactly what I planned, great project. Are the python & HTML codes available? Keep up the good work.

  2. NICE! I would like to do the same. Can you share the code please?


  3. I am a single guy that works all day long like most people. My lawn needs constant watering and TLC. Since I cannot be home during the day to move the sprinkler around, I want to install an automated system? Are these sorts of projects available in a package deal that I can purchase and have installed?

  4. I am impressed by the quality of information on this website. There are a lot of good resources here. I am sure I will visit this place again soon. Click Here

  5. This sprinkler system has been really interesting for me and I would be really interested to know more about it. It sure was a good idea to know that you are having something interesting to read.


Please be respectful.