SkillAgentSearch skills...

Irrigator

Smart Sprinkler Controller for the Raspberry Pi

Install / Use

/learn @nebhead/Irrigator
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Logo IrriGator

Raspberry Pi Zero W or NTC CHIP based Smart Sprinkler Controller

This smart sprinkler controller allows you to setup your own custom sprinkler system using a Raspbery Pi, a 4+ channel relay, and 24V AC Power Supply. If you have an existing sprinkler controller, it's likely you can swap in this project relatively easily, utilizing the existing power supply.

Features:

  • Manual Control of Zones and Schedules via WiFi / Network
  • Custom Schedules, easily configured in the app from your smart phone or PC
  • Weather Check / Percipitation Check - Cancel watering schedule if percipitation exceeds threshold.
  • Event Logging - Check history of schedules, whether any errors occurred, etc.

Screenshots:

Dash / Schedules Dashboard Schedules

Notes on this Project & Code Organization

This project was actually created back in 2016, and is the reason that it is based on rather old versions of bootstrap, jquery, circliful, etc. I was still very much learning when I created this project and much of it is pretty cring-worthy looking back at how it is organized. With all that said, I said 'To heck with it!' and decided I should release this to the world anyway, in case anyone would value it. I've been running in my home since 2016 and it's worked nearly flawlessly the entire time.

I've done a little big of clean-up to the code, modernizing it to use Python 3.x and so forth, but the large majority of it is original from when it was concieved. So please don't judge my poor design. :)

Initially this project used Flask's native WSGI services without Gunicorn or nginx as a proxy. However, I noticed that after some time, the app would become unresponsive. After a little research, it appears that Flask's built in web server is for testing purposes only and shouldn't really be used in production. With that said, I'm using Gunicorn and nginx to proxy web resquests. This is simple enough to configure and setup, however I had to redesign the application without the threading libraries, due to conflicts with Gunicorn. Instead, I am using two processes running concurrently (control.py and app.py). Control handles all of the RasPi GPIO interfaces, while App handles the web routes. They communicate through a JSON file.

Hardware Configuration

The hardware configuration for this project is relatively simple if you have an existing sprinkler system installed. The setup of the sprinklers, the solenoids, and the wiring back to your panel is not in scope of this guide. The focus here is to provide you with instructions on one working configuration.

In a basic residential sprinkler configuration, you'll have indivdual valve solenoids to control each zone (which may contain several sprinklers). These solenoids are actuated with two wires, commonly connected to a 24V AC power source. When power is applied, the solenoid valve opens and the zone gets water.

In a typical setup, you may have a thick cable that contains 5 wires that goes to a set of valves/solenoids. One end of the solenoid would be connected to one of the four wire that would travel back to the controller, and one wire would be connected through a wire nut to the common wire, which travels back to the power supply.

Your mileage may vary, however, and your home sprinkler system might have some quirks (i.e. mine had different wire color for the common wire between the two cables coming into my house), different voltages etc. This hardware may need some tweaks.

The Parts List

  • Raspberry Pi Zero W - Technically any Raspberry Pi will do fine, but for this application a Raspberry Pi Zero W works really well (wifi is built right in)and is the right price.
  • 8-Channel Relay - Technically you can use any number of channels that you need (plus the gate channel), but in my setup I used this 8-channel relay for my zones. Irrigator uses Active Low logic, so ensure you get an Active Low or Low Trigger relay. You can also modify the code in control.py to reverse the logic if needed. Amazon Link
  • Micro SD Card - Greater than 4GB is probably good.
  • MicroUSB Power Adapter - At least 1 amp current recommended.
  • 24V AC Power Supply / Brick - I used the power supply from my old Toro sprinkler controller, which already had the leads spliced.
  • Dupont Cables - Female to Female for connecting your GPIOs to the relay board. Readily found on Amazon, etc.
  • AC/DC Coverter [Optional] - I just picked up a AC/DC converter that is capable of converting the 24V AC to a 5V DC input. This allows me to remove the Raspberry Pi power supply and only use the 24V power brick for both the sprinkler solenoids and the Pi+Relays. It's a little on the pricier side, but it cleans up your implementation by removing one more power-supply from the mix. Amazon Link

Raspberry Pi Default GPIO Mapping

(FYI, this project is using BOARD pin mapping, not BCM pin mapping. This means you'll need to use the pin number of the 40-pin header on the Pi instead of the BCM GPIO numbering)

  • GPIOxx Relay 0 - Zone Gate - Pin 29 (BOARD)
  • GPIOxx Relay 1 - zone_01 - Pin 31 (BOARD)
  • GPIOxx Relay 2 - zone_02 - Pin 32 (BOARD)
  • GPIOxx Relay 3 - zone_03 - Pin 33 (BOARD)
  • GPIOxx Relay 4 - zone_04 - Pin 35 (BOARD)
  • GPIOxx Relay 5 - zone_05 - Pin 36 (BOARD)
  • GPIOxx Relay 6 - zone_06 - Pin 37 (BOARD)
  • GPIOxx Relay 7 - zone_07 - Pin 38 (BOARD)

Schematics

Basic Wiring Schematic for the entire project.

HW Schematic

HW Install

I couple of photos of the hardware mounted in a painted project box. Not really all that pretty or exciting, but it does the job.

HW Schematic HW Schematic

Software Installation

Raspberry Pi Zero Initial Headless Setup

Once you've burned/etched the OS image (I prefer to the Raspberry Pi OS Lite) onto the microSD card, connect the card to your working PC and you'll see the card being mounted as "boot". Inside this "boot" directory, you need to make 2 new files. You can create the files using a text editor editor.

  • Step 1: Create an empty file. You can use Notepad on Windows or TextEdit to do so by creating a new file. Just name the file ssh. Save that empty file and dump it into boot partition (microSD).

  • Step 2: Create another file name wpa_supplicant.conf . This time you need to write a few lines of text for this file. For this file, you need to use the FULL VERSION of wpa_supplicant.conf. Meaning you must have the 3 lines of data namely country, ctrl_interface and update_config

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="your_real_wifi_ssid"
    scan_ssid=1
    psk="your_real_password"
    key_mgmt=WPA-PSK
}

Power-On, Log In, and Run RasPi-Config (REQUIRED PRE-REQUISITE FOR AUTO-INSTALL)

Now you can power-up your Raspberry Pi with your microSD card inserted, and connect to it via SSH. If you're on a Linux PC, use the command line connect to your Pi.

ssh pi@192.168.10.xxx

If you're on a Windows PC, you can use Putty to SSH to your Pi, or you can install the Windows Subsystem for Linux and install a Linux image like Ubuntu to run the above command.

Once connected, you'll want to run raspi-config to get the system setup.

sudo raspi-config

Once raspi-config is open, the following should be configured at a minimum.

  1. Set locales (Always good practice. For US English, I typically use EN UTF8)

  2. Set timezone (This ensures you have the right time in your dashboard)

  3. Replace Hostname with a unique hostname ('i.e. pifire')

Automatic Software Installation (Recommended)

I've created a script to install this automatically, but it is in ALPHA testing. Your mileage may vary, and if anything fails, you may just want to try running the manual steps below.

NOTE: Do not use SUDO when running these commands. Permissions will be aquired automatically.

After you've done the above steps to configure your raspberry pi, at the command line type the following:

curl https://raw.githubusercontent.com/nebhead/irrigator/main/auto-install/install.sh | bash

OR you may find that it is more reliable to download the script to your raspberry pi first, and execute directly.

wget https://raw.githubusercontent.com/nebhead/irrigator/main/auto-install/install.sh
bash install.sh

Follow the onscreen prompts to complete the installation. At the end of the script it will reboot, so just be aware of this.

Manual Software Installation

NOTE: This installation assumes that you install on the 'pi' user account, otherwise the supervisor portion of the install will likely fail. If you are using a different user account, make sure you modify the correct folder structures in the supervisor configuration files.

Let's start by setting up the /tmp folder in RAM. On your Pi, open the fstab file for editing:

sudo nano /etc/fstab

Add the following line to the bottom of the file.

tmpfs /tmp  tmpfs defaults,noatime 0 0

Save and exit.

Install Git, Python PIP, Flask, Gunicorn, nginx, and supervisord

sudo apt update
sudo apt install python3-dev python3-pip python3-rpi.gpio nginx git gunicorn supervisor -y
sudo pip install flask python-crontab cron-descriptor requests geopy
git clone https://github.com/nebhead/irrigator

Setup nginx to proxy to gunicorn

# Delete default configuration
sudo rm /etc/nginx/sites-enabled/default

# Copy configuration file to nginx
sudo cp irrigator.nginx /etc/nginx/sites-available/irrigator

# Create link in sites-enabled
sudo ln -s /etc/nginx/sites-available/irrigator 
View on GitHub
GitHub Stars33
CategoryDevelopment
Updated1mo ago
Forks8

Languages

CSS

Security Score

90/100

Audited on Feb 5, 2026

No findings