Legacy post. This article was written between 2016 and 2018. Software versions, commands and services mentioned here may be outdated. Check the official documentation before running anything.

The aim of this tutorial is to wire the electrical part of a sprinkler system. At the end of this tutorial, we will be able to control the sprinkler system from a Raspberry Pi.

Electrical part

Prerequisites

Overview

Valves box final
Valves box final

Components

Component Description Quantity Unit price Total
borne_auto_levier_2 Wago electrical lever connectors 2-way 10 0.59 5.9
borne_auto_levier_3 Wago electrical lever connectors 3-way 5 0.78 3.90
borne_auto_levier_5 Wago electrical lever connectors 5-way 1 1.04 1.04
boite_étanche_IP54_80x80x45 Waterproof distribution box IP54 80x80x45 1 1.2 1.2
boite_étanche_IP54_D70xP40 Waterproof distribution box IP54 70x40 3 1.40 4.20
barrette_12_dominos_2.5mm Domino bar x12 1 1.9 1.9
multi_conducteur_7_brins 7-core multi-conductor cable wire 15m 1mm 1 31.32 31.32
transformer Transformer 220VAC/24VAC 1 31.19 31.19
- - - - 80.65€

Wiring

Electrical connection

  • Connect the electrical box to the valve boxes with a 7-core multi-conductor wire
  • Install one distribution box at the entrance of the valve box.
  • Connect the power supply to the 24V solenoid valve with a transformer.

Tools: Electrical screwdriver, wire cutter, wire stripper.

Sprinkler electric part
Sprinkler electric part

Electronic part

Prerequisites

Overview

Electronic part
Electronic part

Components

Component Description Quantity Site Price
relay_card_raspberry Relay AC 250V 10A ; DC 30V 10A Relay card module AC/DC 5V 4 channels 1 Ebay 8.00 €
cable_MM_MF_FF 10 x Cables male/female female/female male/male 10 ebay 1.00 €
raspberry_pi_3 Raspberry Pi 3 1 Farnell 37.69 €
power_supply_micro_USB_5V_2500mA Power supply Micro USB 5V 2500mA 1 Amazon 8.99 €
micro_sd_16go_class_10 Micro SD Card 16GB class 10 1 amazon 9.90€
breadboard_raspberry Breadboard 1 ebay 3.50€
- - - - 69.08 €

Wiring

Sprinkler Overview
Sprinkler Overview

Note: Connect the relay to the Raspberry Pi (control electronics). Each relay is supplied with 3.3V from the Raspberry Pi.

Software part

Prerequisites

Program

Clone it from GitHub, or get this project.

git clone https://github.com/jluccisano/rpi-sprinkler-control.git

See more details:

https://github.com/jluccisano/raspberry-scripts/tree/master/scripts/home-automation

Follow the install steps described in the README.md.

pip install https://github.com/jluccisano/rpi-sprinkler-control/archive/v0.0.2.tar.gz
pip show rpi-sprinkler-control
Name: rpi-sprinkler-control
Version: 0.0.1
Summary: Control your sprinkler system via a Raspberry Pi
Home-page: https://github.com/jluccisano/rpi-sprinkler-control
Author: Joseph Luccisano
Author-email: <your-email>
License: UNKNOWN
Location: /home/pi/.local/lib/python2.7/site-packages
Requires:

Create a service

See more

[Unit]
Description=Home Automation Server
After=multi-user.target

[Service]
ExecStart=/usr/bin/python /opt/home-automation/server.py
Type=simple
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Install release package

  • Connect to the Raspberry Pi via SSH
  • Install package
  • Create Service
  • Run

Test

Get the state of each valve

python zone_control.py get

Get the state of a specific zone

python zone_control.py get --zone 1

Set the state of a specific valve

python zone_control.py set --zone 1 --state 1

Set the state of each valve

python zone_control.py set --state 1

Toggle the state of a specific valve

python zone_control.py toggle --zone 1

Now we are able to control the sprinkler system from a Raspberry Pi. That is already a good start, but we need to control it directly from a mobile phone and from anywhere… Go to the next tutorial.