Irrigation Controller (Arduino)

By James on

The irrigation timer I had bought was ok for the money (£12) but its functionality was quite limited.  It's basically a electronic valve, you can set the frequency and duration and it will repeat opening the valve at that interval until the 2xAAA batteries run out.  Firstly its quite annoying to have to keep replacing batteries and even worse if they run out on a hot day and you don't notice! Secondly, frequency and duration alone aren't all that useful. You can have it come on for 10 minutes every 6 hours for example, which is ok but it will be running during the night too. Every 12 hours is ok as you can get morning and night, but I want it to be more frequent during the hot days and to not run at all during the night.

I decided (well, its really the reason I bought it) to hack the timer a bit, so I removed the control board and battery holder, leaving just essential parts. Its a really simple design, just 2 wires going to a standard DC motor and plastic gearbox controlling a ball valve, and another 2 wires going to a microswitch.  The switch gets pushed as the valve turns to the open position and gets releases when the valve turns to the closed position. This allows the electronics to know when to stop turning the motor.

I replaced the board with a custom design, based on the ATmega328 chip, which is the chip at the center of a lot of the popular Arduino boards. I connected the microswitch to an input pin and the motor to an output pin (through a power transistor). I also added a temperature sensor to the board and connected that as an input.  I wrote a simple bit of code to turn the motor until the microswitch state changes, and then stop turning the motor. I added a communication chip so the device can sit on my sensor network and listen for instructions. This allows me to turn the irrigation on and off remotely from any computer on my network.

I have added a new event condition to the Raspberry Pi that manages the sensor network to switch the irrigation on for 5 mins every 3 hours if the temperature inside the controller rises above 20°c, every 2 hours if temp above 30°c, every 1 hour if above 40°c and every 30 mins if above 50°c.  This now runs this irrigation more frequently the hotter the day and doesn't run at all during the night.