Irrigation Controller and Timer

    I've been wanting to grow a garden for almost a year since I moved into the home with this tract of beautiful fertile land. However, considering my busy work schedule, I didn't feel comfortable knowing my poor veggies would be relying on my half-asleep and sometimes late-waking self to provide a proper watering. I started designing a rain water collection and automated irrigation system during the winter of 2011/12.

My arduino code for the irrigation controller (v2.4.1, 4/24/2012) can be found on github

 


I found the highest and sunniest section of my yard, then cleared and erected a fence from bamboo harvested in the yard.

 


At the time, it was to keep out my roommates' English bulldog. Now it merely separates ~924 square feet from the rest of the yard.

 


The ground is tilled and bricks are laid for the center walking path with two 4x4s for the narrower side paths.

 


    When it's too dark outside to satisfy my desire to manually till the earth, I take a seat on my Indian blanket and begin the immensely enjoyable process of building.

 


    Although the box I chose to house my circuitry in is waterproof, space constraints and my desire to control and monitor from within my house influence the design heavily. I also wanted this project to be modular, so if I wanted to change the sensors and power other devices, all I have to do is unplug the irrigation system, plug in something else, and alter the program.

 


    The design I ended up with is comprised of three 2-lead barrel plugs and a single 3-lead audio plug (float sensor, pump pressure switch sensor, temperature sensor, and one free port for a future rain sensor), two solid state relay-controlled electrical outlets (pump and 24v valve), and a blue LED next to each outlet for a visual signal when an outlet is live.

 


    This is the 1/2 HP well pump I'll be using to transport my water from the tanks to my sprinkler head(s). The rated output is 9 GPM (gallons per minute) @ 30 or 55 PSI (pounds per square inch), and has a current rating of 8.5 amps. At 120 volts, that's 1020 watts of power consumption. These figures are from the manufacturer. I'll be doing my own testing down the road to find the actual performance. If we assume these figures are accurate, we can take Atlanta's January, 2012 electricity cost of $0.113/kWh (killowatt-hour) and project how much it would cost to water every day of an 8-month growing season, for 30 seconds.

(30 seconds/day) x (30 days/month) x (8 months/year) x (1 minute/60 seconds) x (1 hour/60 minutes) = 2 hours.
(2 hours run time) x (1020 Watts) = 2040 Watt-hours = 2.04 kWh.
(2.04 kWh) x ($0.113/kWh) = $0.23052 or less than one quarter dollar

Pretty good!

 


    This is the working prototype, incorporating the Arduino Uno, with an ATMega328. The components include a 7-segment display (top left), a float switch (top center), a real time clock module (top right), and affixed to the breadboard is a temperature sensor (10k thermistor), two blue LEDs, a push-button rotary encoder, and a couple resistors here and there to prevent damage to the arduino.
    The basic operation will turn the pump on at scheduled times of certain days for chosen durations. If the rain barrels begin to run low on water, the float sensor will signal the electronic valve to open at the house's spigot. This valve is connected to one of the two barrels by a hose. This prevents the water level from falling below the pump's intake pipe. A temperature sensor prevents the pump and valve from powering if it's too cold (or will soon be too cold). A rain sensor will be incorporated in the near future to prevent watering while or directly after it's rained.

 

 


    Further progress shows the rotary encoder soldered to its board and the rest of the components plugged in to test before everything is soldered and tucked in. Surprisingly, the first test has all components properly connected and operating flawlessly.

 

 

 

 

 

 

 

 

 

 

    When powered, this jet pump relies on a pressure switch to enable and disable the current to the motor. In a situation where there is a blockage in the outflow line (debris collecting in the sprinkler filter, for instance), pressure can build up. If the psi that's measured in the head exceeds ~50 psi, the switch will kill the power to the pump. If no pressure tank is installed, the line pressure quickly drops and the switch resumes powering the pump motor. The off/on cycling rapidly occurs about 2 to 3 times per second, and if the blockage does not pass to return the line pressure to normal, the pump could quickly burn out. To prevent this, I turned to a cheap 120v to 5.5v USB adapter for a solution. I needed a signal from the pressure switch that power was continually being given to the pump. If this 5.5v signal is lost when the pump should be on, the whole system is programmed to shut down.

 


    Construction was simple. The enclosure was cracked open and wires were soldered to the 120v power leads and from the 5.5v USB leads. The enclosure was resealed with marine epoxy. The finished product can be seen protruding from the pressure switch enclosure, below. A problem appeared while testing, and it was that the charged capacitor within the USB adapter prevented the voltage from dropping by a detectable amount within the amount of time the pressure switch stayed off in it's on/off cycling (250-500 ms). This was resolved by increasing the resistance of the circuit by incrementally adding resistors in parallel. The resistors convert electrical energy into heat energy, discharging the capacitor. After the third 100ohm resistor was put in place, I was able to reliably detect a drop in voltage after only three off/on cycles of the pressure switch. This is due to the resistors dissipating the charge faster than the capacitor could recharge in the on/off cycling.

 

 

I wrote a set of instructions to be printed and adhered to the front cover:

*-*-*-*-*-* Operation and Navigation *-*-*-*-*-*
The current time & temperature will alternate on the display by default. If the colon is blinking when the time is displayed, the schedule is on. If the colon is not blinking and stays solid, the schedule is turned off. While the time & temperature is being displayed. The knob can be pressed to activate the control menu. Turn the knob to change a value, then press to confirm the value.
 
*-*-*-*-*-* Menu Options *-*-*-*-*-*
1: Exit the control menu and return to displaying the current time.
2: Display schedule(s) in the format: start time, duration on, days between running, next run day (1=Mon...7=Sun).
3: Change schedule
   A: "# x" #: Which schedule, x: How many schedules to use (up to 3).
   B: "XXYY" X: Starting hour, Y: Starting minute. Selecting the time will confirm & display the next schedule time.
   C: "# x" #: Which schedule, x: watering duration in seconds (~5 gallons/minute).
   D: "#d x" #: Which schedule, x: how many days between running the schedule.
   E: "#n x" #: Which schedule, x: Which day of the week to start schedule (1=Mon...7=Sun).
4: Override the pump (to run the sprinkler) to either remain OFF or ON
5: Override the valve (to fill the barrels) to either remain OFF or ON
6: Turn the timer schedule OFF or ON
7: Reset the pump and valve overrides so they return to a scheduled operation (if schedule is turned on)
8: Display temperature history over the past 24 hours, 0 is the most current temperature stored

 
-*-*-*-*-* Emergency Modes *-*-*-*-*-*
If an emergency is detected, the valve and pump will remain off until the button is pressed to resume normal operation. During emergency mode, one of the following will interupt anything currently being displayed:
 
-E-1: The valve was open > 15 continuous seconds. This indicates the water is not activating the float switch in a timely manner. Ensure the hose going into the tank is connected & clear, the valve is operational, the spigot is open, the tanks are free of leaks, the float switch is free to move, and the switch is indeed activated when the water level reaches the sensor.
 
-E-2: The pressure switch began rapidly turning on and off or the pump has run dry. This indicates there is too much pressure building in the pump outlet or no water at the pump inlet. Ensure the outflow hose from the pump is not kinked, the sprinkler screen/heads are clean, and there is an adequate amount of water reaching the pump inlet.
 
-E-3: The float switch has been activated after more than 3 minutes from when the end of a scheduled watering. This indicates there may be a leak or water is being manually removed via the barrel's spigot. If the barrels were allowed to fill, which could take over a minute of the valve turning on and off [to equilibriate the water levels], the float switch should not activate this late. If water is being manually taken out, remember to exit emergency mode in order to resume the schedule.

 

 

 

 

 

    Now that the circuitry is complete, I can focus on the water storage and delivery system. The general idea is that water will enter one 55 gallon barrel by flex tubing from the gutter, a hose connecting the two barrels near the bottom will equilibrate the water levels, and the pump will then pressurize it back above the water line and down to a hose that runs out to a sprinkler in the garden.

 

 

    The outflow pipe from the pump rises over the point of the highest possible water line to prevent water from siphoning out while the pump is not running. This is only possible when a separate pipe extends from the top of the bend to allow air to be introduced into this bend immediately proceeding the pump being turned off. This vent serves two purposes. It allows air to flow into the top portion of the pipe when the pump shuts off, preventing the gravitational flow of water toward the sprinkler from drawing water out from the barrel, but it also alters the water pressure that's allowed to reach the sprinkler by either closing (increase pressure) or opening (decrease pressure) Ball-valve 1, diverging the flow back into the barrel so no water is lost. With Ball-valve 2 in-line after the bend, there is now the ability to completely alter the pressure from 0% to ~100% to the sprinkler beyond Ball-valve 2.

 

 

 

 

 


A sprinkler valve fills the barrels from the spigot if the water level falls below a minimum level that is signaled with a float sensor.

 

 


The float sensor protruding from the barrel.

 


Temperature sensor consisting of a thermistor encased in heat-shrink tubing and epoxy.

 


My rain sensor is a recycled plastic water bottle nailed to a board.

 


It utilizes the latest stainless steel screw technology.

 


...with protection from large debris.

 


High-heat is required to properly solder stainless steel.

 


    It's best to protect these connections from oxidation/corrosion. The principle behind how this works is conduction. When there is no water in the cup, air separates the two screws. A 5 volt potential is in one wire going to one of the screws. Since this large air gap is non-conductive, this 5 volts is not detected by the arduino from the second screw. When rainwater fills the cap, it acts as a conductor, allowing electrons to pass from one wire to the other, completing the circuit and signaling that it's raining.

 


    I'll end with a final photo of my current garden and an experiment at deterring the ravenous squirrels from digging my newly sprouting plants. The first two weeks seem like a success with battling the squirrels. The holes that previously dug my newly-sprouted veggies from their home can now only be found bordering the outside of the fence. Who knows what enlightenment my great wall of wire will bring to the pea-sized brain of my backyard squirrels. All I know is if they do become smarter to circumvent my deterrent, I'll just have another project on my hands.

 

 

2012.04.29: 3 additional 55gal barrels have been added to the system.

 

 

 

 

 

 

 

2012.05.11: Filtration system added

 

 

 

 

I hope this has served as entertainment, inspiration, or a practical how-to for your own garden project.