HomeTutorials › Raspberry Pi Irrigation Control – Part 1

Raspberry Pi Irrigation Control – Part 1

In this multipart project tutorial we will be building a Raspberry Pi based Irrigation Controller using our Raspberry Pi IrrigationHAT. We wanted to create a functional project for people to dip their toes into the world of smart devices – and an irrigation controller seemed like a great choice! Following this tutorial will result in an operational Irrigation Controller with multiple zones, a configurable schedule, configurable run duration, and basic notification system. We will break this tutorial down into four components: An assembly guide and board overview, Installing libraries and reading sensors / controlling outputs using python, email notifications and configuration, and installation outdoors. The tutorial is focused on our Raspberry Pi Irrigation Board designed and manufactured here at BC Robotics.

About the Board:
The Pi Irrigation Board is designed to give your Raspberry Pi everything it needs to control solenoid valves (commonly found in garden and lawn irrigation) along with other inductive loads while providing a number of interfaces and connections for different sensors to suit a variety different configurations.

The board is comprised of 6 independent solenoid driver circuits. Each circuit has an LED indicator showing when it is triggered and integrated snub diode to protect your Pi from any power spikes caused by inductive loads. A 4 Channel 12-bit analog to digital converter is also used, giving the Pi the ability to read a variety of basic analog sensors including Soil Moisture. We have also built in a connector specifically for the DS18B20 Temperature Sensor, a Flow Sensor, along with breakout headers for I2C, SPI, and Serial. To aid in powering the board, we have also included an extra connection point for a Pololu 5V 2.5A Regulator – this allows the Pi to be powered off the 12V power supply we are using for the solenoids rather than a separate 5V power adapter.

The Parts Needed:

parts

This tutorial will be requiring a few common parts:

Optionally, these items may also be required depending on how you plan to set your irrigation system up:

Going forwards there will also be tools and other components required – we will discuss these throughout the next 3 parts of this tutorial.

Step 1 – A Quick Overview of the assembly steps

parts

This board is offered in both an assembled and “bare bones” version. The assembled version ships fully assembled and requires no soldering under most circumstances. Screw terminals are used on all of the commonly used connection points and the GPIO header is soldered in place.

The bare bones version is intended for users wishing to solder their own preferred connectors or for custom integrations. For those using the bare bones version: we will start with a quick look at each of the connection points on the board and how to connect up each of the sensors. If you are using the assembled version of this board, feel free to skip ahead to Step 8.

Step 2 – Soldering the header

Step2

First we need to solder the header that allows this board to plug into the Raspberry Pi. We recommend using this header, but any compatible Raspberry PI GPIO header will work. If you haven’t soldered before, or want a quick refresher course, have a look at this awesome comic: Soldering Is Easy! https://mightyohm.com/…/FullSolderComic_EN.pdf

Start by Tacking two opposite corners of the connector in place and checking the connector alignment. We do this to ensure the connector is sitting correctly before soldering all 40 pins; once these have all been soldered, it is very difficult to adjust the alignment.

Step 3 – Soldering the header (continued)

Step3

Once the connector is aligned to the board, and you are happy with the alignment, solder the remaining pins. It should look something like the header in the attached photo when you are finished!

Step 4 – Soldering Power Screw Terminal

Step2

Step2

On the assembled version of the board, we use a 2 pin 3.5mm screw terminal. Alternatively, feel free to solder in your 3.5mm pitch compatible connector to the board. This connector can now be soldered to the board. Start with one pin, check the alignment, and solder the other pin.

Step 5 – Soldering DS18B20 Connector

Step2

Next we are going to install a screw terminal to connect the DS18B20 Temperature Sensor. The DS18B20 is weatherproof, so the probe will actually be mounted outside of the box, with the wires running into the board, so having them removable will make the installation into a box much easier going forwards. If you prefer, you could also solder the wires direct to board.

We went with a screw terminal on this one, but any standard 3 pin 2.54mm pitch connector would work. Just like all the other connectors, tack one pin in place, check the alignment, and solder the remaining pins.

Step 6 – Soldering Solenoid Screw Terminals

Step2

Just like the power connector on the board, on the assembled version we use a 2 pin 3.5mm screw terminal for each solenoid connector. Alternatively, feel free to solder in your 3.5mm pitch compatible connector to the board. Each of these connectors can now be soldered in place.

Step 7 – Soldering Analog and Flow Sensor Connectors

Step2

On the assembled version of the board we use 2.54mm / 0.100” male breakaway headers as connectors for the Analog inputs and Flow Sensor. Alternatively, if you would like a more secure method of connecting each sensor, 3 pin Molex KK series connectors (in Straight or Right Angle configurations) or 3 Pin 2.54mm Screw Terminals are also an option. When soldering these in place, be sure to keep your solder joints clean tight to the board as large “globby” solder connections may contact the Raspberry Pi PoE header on the Raspberry Pi 3B+.

Step 8 – Connecting the DS18B20

Step2

Temperature monitoring in this project is entirely optional, but the connection is there for those wanting to install it. We have connected the DAT pin to GPIO04 (Pin 7) with the appropriate 4.7K Ohm Resistor between the 5V and Data Pin.

The DS18B20 can ship with two different sets of wire colors – these are often seen with Red, Black and White or Red, Black, and Yellow. Normally Red will be power, Black will be Ground, and White / Yellow will be the Data pin. Be sure to check the pinout, we list it on our product page for the DS18B20.

Connect your DS18B20 according to the color code of your sensor.

Step 9 – Connecting the Flow Sensor

Step2

If you are interested in monitoring water flow, the flow sensor we are using works by spinning a small pinwheel with a magnet. As this magnet passes an integrated hall sensor, the output pin is triggered high. If you are using the same flow sensor we are using, simply connect as shown. For advanced users, there are three pins here with the first being a 5VDC power pin, the second being a signal pin to GPIO24 (Pin 18) with a 10K pull up resistor connected to 3.3V, and finally a ground pin.

Step 10 – Connecting Solenoids

Step2

The board can handle up to 6 solenoids, each driven by its own MOSFET based driver circuit. You can use our Solenoid Valves or if you need higher flow, off the shelf commercial 12V solenoids found in the irrigation section of your local hardware store.

Each circuit has its own snub diode and LED indicator. While we refer to driving solenoids with each circuit, you could directly drive external relays or small pumps as well. Each circuit is capable of driving in excess of 1.5A @12V without getting too hot.

The channels are connected as follows:

  • S1: GPIO13 / Pin 33
  • S2: GPIO16 / Pin 36
  • S3: GPIO19 / Pin 35
  • S4: GPIO20 / Pin 38
  • S5: GPIO26 / Pin 37
  • S6: GPIO21 / Pin 40

To connect your solenoid, simply run each wire into the screw terminal and clamp it down. For many multi-zone sprinkler systems wired with a commercial controller, power will be provided over a single wire. In this case, connect the power wire to one of the positive terminals, with each ground going to its respective terminal on the board. We will cover this further in later tutorials.

Step 11 – Connecting Analog Sensors

Step2

The Irrigation Board has an ADS1015 chipset providing 4 x 12-bit analog inputs to the Pi. We like this sensor because it has great resolution, it isn’t terribly expensive, and it has an amazing Python library created by Adafruit.

Each of these inputs are broken out on the right side of the board to their own 3 pin header. A pin for power, a pin for analog input, and a ground pin are provided. We envisioned these would be used with simple Soil Moisture Sensors – but any analog sensor capable of providing a signal between 0-3.3VDC will work.

One thing to note: Resistive soil moisture sensors will corrode quite quickly if they are left powered all the time in damp soil. We have taken that into account with the design of this board. Next to each header we have given each analog input an option for its 3.3V power source – a straight 3.3V from the onboard voltage regulator or 3.3V power via a GPIO pin. By default, these solder jumpers are set to power normally, but by changing the solder jumper, each can be powered via GPIO pin. Powering via GPIO pin is usually a big no-no, but because most resistive soil moisture sensors we envision being connected to this board draw an incredibly small amount of power, it is OK in that specific application. Doing this allows us to shut each sensor off when not in use with no additional hardware very easily. Sound confusing? We will address this further in the next couple tutorials!

For now, connect your Soil Moisture Sensor(s), carefully note the labels on the board.

Step 12 – Optional Power Regulator

Step2

One challenge with the Pi is power – we have given two options with this board.

If you have mains power nearby the installation location for your Irrigation Controller and a Raspberry Pi 5V Power adapter, simply power as per normal using the Pi’s power plug.

However, out in the middle of your garden, you may not have mains power available… But you will need 12V power for your solenoids. So to keep things nice and simple, we have included a spot to add a Pololu 5V 2.5A Step Down Regulator to the board. This takes power off the 12V source, and uses it to power your Pi nice and efficiently.

To install the regulator, ensure the regulator pinout matches the labels on the board, and solder in place. Just note that as soon as you attach 12V power, your Pi will boot up!

Step 13 – Double Check Your Work!

set11

Before we power anything up, it is always a good idea to go through and make sure there are no issues with the work that has been done. Make sure all the solder joints are clean, with no un-intended bridging. Check to make sure all the sensors are plugged in correctly, add the two standoffs as shown, and connect the board to the Raspberry Pi. If using the Raspberry Pi 3B+ be sure to check the POE header (located near the USB ports) is not contacting anything on the IrrigationHAT.

In the next section of this tutorial we will be getting the Raspberry Pi set up with the Raspbian operating system, installing software libraries for each sensor, and writing some basic Python code to read the sensor inputs and control the outputs. Ready to tackle it? Head over to Part 2!

Have A Question?
If you have any questions, or need further clarification please post in the comments section below; this way future users of this tutorial can see the questions and answers!

Parts Used In This Tutorial:

Leave a Reply