Raspberry Pi Irrigation Controller
Gardening improves health and quality of life, connecting us to our local environment. Plus, you can eat organic fruits and veggies at very little cost. Yet for all these fantastic benefits, remembering to water can still take a backseat to our busy lives. Fortunately, home automation is easier than ever with inexpensive and accessible microcontrollers like the Raspberry Pi and Arduino.
This tutorial details the construction process for a remotely controlled solenoid irrigation valve. In other words, a home computer controls the water flow of an outdoor hose spigot, or bib. The materials cost is about $30-40, excluding the Raspberry Pi (RPi). Cheaper parts can be found with patience and creativity.
The design is intended as a simple introduction to building a complete, personalized home irrigation system. It is also intended to encourage simple DIY solutions to everyday problems. Make modifications and upgrades to suit your needs, resources, and skill level. To conserve water, include drip irrigation and a soil moisture sensor.
Note: This project involves high voltage which requires extreme caution. Always check power connections before touching exposed wires.
Step 1: Materials
Raspberry Pi, GPIO Cable, breadboard/PCB board adapter
This tutorial uses a 24 VAC solenoid for a 3/4″ hose spigot.
Some background: there are two main types of solenoids: AC or DC.
An AC solenoid valve turns water on when voltage is applied, and turns it off when the power is off. The drawback is that it uses AC voltage, requiring an adapter to convert the wall voltage, 120 VAC, into the 24 VAC voltage needed to trigger the valve. Outdoor Installation likely requires an extension cord.
A DC solenoid valve allows for a battery powered system. It can easily be modified to be wireless and powered by renewable energy using a medium solar panel (~10 W). However, most DC irrigation valves are latching solenoids and require switching the valve lead polarity to turn water on and off.
I chose an AC valve for the first prototype because I already had a few parts.. and adequate rechargeable batteries can be expensive.
The Solid State Relay, or relay, is the intermediary switch between the RPi and the solenoid valve. This tutorial uses a Crouzet Model OAC5-315; its input is 3 – 8 VDC and its output is between 24 – 120 VAC at 1A.
Sized to fit the relay, GPIO pins, transistor and resistor.
— AC Power Adapter (120 VAC to 24 VAC)
Use an extension cord and/or longer leads to install outdoors.
— 22-gauge stranded wire (insulated), min. 10 feet
— Waterproof container
I used a leftover project box wrapped with waterproof tape. Cheap/free containers are easy to find; Talenti ice cream containers are an example, and also happen to contain delicious ice cream. With small containers, be sure exposed AC connections are completely covered in epoxy to protect the RPi.
— Optional: Waterproof connectors, waterproofing tape/lots of duct tape
Step 2: Tools
Soldering iron, solder, solder sucker
— Wire strippers
Check that it is safe for outdoor use. Marine-grade epoxy may be best for long-term outdoor installation.
— Optional (but highly recommended): Multimeter
— Depending on your system container, a drill might also be useful.
Step 3: Solenoid Setup
Add wire leads to the AC power adapter (if there are none); use at least 3-4 ft of wire.
This AC power adapter has screw-type connectors. Recommended to coat these in epoxy.
2. Verify that the solenoid works by connecting the leads to the power adapter.
The valve makes a “clicking” sound when it is turned on.
For thorough testing, repeat with the valve connected to the hose spigot.
3. Optional: Extend solenoid valve leads using the waterproof connectors.
Twist wires together inside the connectors, check the connection (aka continuity), then epoxy the openings.
Remember, never touch exposed wires when the power is on. Go slow when working with AC to double- and triple-check power.
Step 4: Build it! Hardware Pt. 1
Foreword: Pay attention to the layout of the PCB pads and use them to make connections simpler and more direct. Plan where components are connected prior to soldering. It may be easier to solder components in a different order.
1.a. Solder the relay to the PCB board.
The labels on the relay tell you the function of each pin. Here’s the datasheet for further reference.
1.b. Solder a wire lead to each relay pin, leaving 6 in. or more for the AC leads.
2. Solder the RPi GPIO pin 18, 3.3 VDC pin, and ground pin to PCB board pads.
3. Solder the transistor to the PCB board, keeping each of the legs electrically insulated.
4. Solder one end of the resistor to the middle transistor leg (base pin) and the other end to GPIO pin 18.
For best results, use one 4.7 kOhm resistor and connect as shown in the last photo.
For more detail: Raspberry Pi Irrigation Controller