Thursday, September 13, 2007

Open Source Watering

All Dried Up
Mid-summer in the Midwest is relatively dry and I'm not talking about the humidity. I'm talking about rainfall. If your lawn gets direct sunlight for most of the day and the temperature is >90°F, then you'll have a beautiful brown lawn for you and your neighbors to enjoy. Up until the beginning of this summer, we had watered our grass with conventional garden hose sprinklers and one Orbit head that ran off of a Black and Decker indoor/outdoor X10 module (with electric valve). This worked fine, but I wanted more. I wanted multiple zones that were computer controlled, with a boost in pressure if it was possible. It turns out that we have a creek that runs behind the house. It's about 15' down, in elevation, from our walk-out basement and usually has plenty of flowing water throughout the summer months to supply the yard....... this drove me to look at some Flotec pumps at Menards. Menards has a wonderful selection of Rainbird and Orbit sprinkler heads, fittings, tubing, and electric valves, so why not make it a one stop shop? I picked up one of the 1/2 horse Flotec pumps. I wanted something that would consume a relatively small amount of energy, but still have the lift power that I needed. I ended up placing the pump next to the house and running the input line down into a foot valve. I found a filter sack at Menards that was designed to filter pond water. I placed this over the foot valve. The valve was then placed inside of a bucket with holes that was submerged in the creek.

After the pump installation, I ran 1/2" and 3/4" poly-tubing around the house to various sprinkler heads (I seemed to have better luck with the Rainbird variety). Our house is surrounded with mulch, so I was able to bury the tubing beneath it. This saved quit a bit of actual digging. In the Fall I'll take the air compressor and blow out the lines to prevent freezing. After running the pump and experimenting with the number of heads that I could run at once , I set up the zones with 24VAC sprinkler valves. I ordered an inexpensive 24VAC(ELK) power supply from SmartHome. The power supply provided enough power to run several valves at once. There is a valve to control each zone (4) and one that will allow the system to be supplied by house water. You have to be very cautious not to back feed a potable water system(city or well water) with untested and potentially contaminated water. I installed a check valve to ensure that water would only be able to exit the house supply and not enter. Most of the time I end up leaving the spigot closed for peace of mind.

Controlling
Now that the manual work is complete (almost), we can get to the fun (for nerds/me) part. I needed to control this system without having to go outside every day, flipping the valves open (manually), and plugging in the pump. Our house is already partially automated with some Insteon products. Insteon doesn't provide Linux support (I'm not droppin coinage for the SDK), but I did manage to run the Insteon USB - PowerLinc from my Ubuntu file server. I was able to use USBSnoop to figure out the serial data and can now operate various lights from any web browser, on any computer, in the house. The reason I bring this up is because Insteon has a Sprinkler Controller called EZRain. At $125, I was hesitant on the purchase. I also wanted to run the system via a web browser, through the same Ubuntu Server. I started looking at different ethernet i/o boards along with other expensive i/o PCI cards. I ended up going with a Parallel Port relay board. This would provide me with 8 i/o channels, which was plenty. This was an inexpensive solution that I could even build myself with no problem (yeah right). If I had to do it again, I would definitely buy a pre-assembled board. I bought my parts from Newark and started soldering. It was a piece of cake until I cut into the Parallel cable. There are 36 tiny wires inside (due to the Centronics end that goes to an ancient printer). After two nights of assembly, my board worked on the first shot. I just used a free Windows program to test it. My plan was to run the 5 valves and one 15A(24VAC) relay (for the pump) off of the board. I downloaded a program called Parapin and just modified one of the example programs to my needs. The only changes that I needed to make were for safety. I didn't want the pump to start unless enough valves were open and once the pump was running, valves couldn't be allowed to close unless other valves were opened or the pump was turned off. This meant that I had to monitor the status of the system. I chose to do this with a binary file on the server. Every time Parapin is executed, the binary file is read, it's data was updated to the new status, and rewritten to the file. This safety measure allowed me to build a PHP/AJAX web page without worrying about undesired commands being sent back to the server. The web page sends GET requests back to a PHP page:

$valve = $_GET["valve"];
$pin = $_GET["pin"];

if($valve != "" && $pin == "")
{
system("sudo sprinkle $valve", $rtvalue);
}
else if($valve != "" && $pin != "")
{
system("sudo sprinkle $valve $pin", $rtvalue);
}

echo $rtvalue;
?>

Here's a shot of the very simple control page.



This system works pretty good. Sometimes I have to restart the pump once or twice, initially. I think it's a priming issue. Once it's going it'll pump all day long. I'm hesitant to automate the system because of this issue. I was thinking of installing a flow switch to shut off the pump if there isn't enough water/flow present. For now I'll just look out the window and maybe spray a passer-by or two from my phone(wifi enabled)!

Parts List

-Menards
1/2 horse Flotec Jet Pump (FP4012)
misc. Rainbird and Orbit sprinkler heads
misc. barbed fittings and PVC parts
several 100' rolls of 1/2", 3/4", and 1" poly-tubing
foot valve
filter sack
small bucket


-Newark
All parts for parallel port relay board
15A (24VAC coil) relay for pump


-SmartHome
ELK 24VAC Power Supply (wall wart)


PC running Ubuntu (w/parallel port)