Introduction: How to Make a Linux Powered Garden Sprinkler System.
1. The Idea -- use a standard electric sprinkler valve and garden hose adapters to control the flow of water using a parallel port based C program in Linux. Scheduling accomplished by running a cronjob.
2. The Parts-- Gather the parts.
3. Build the Electronics -- Assemble the parts.
4. Plumbing-- Use the Thread Tape
5. Software -- Install linux compile some software and create a yard fountain. (see below)
6. Scheduling -- sudo Crontab -e
7. Other Notes-- more thoughts on the project.
Step 1: The Idea...
I have the hardest time remembering to turn on the sprinkler for my garden. I went looking for a solution.
The plan is to use a standard electric sprinkler valve two garden hose adapters a relay and old 12v power supply to control the flow of water from and old linux computer. This will allow the fine tuning of watering time using cronjobs.
Step 2: The Parts...
You will need the following.
1. A garden or other area that needs water on a regular basis.
2. A garden hose
3. A electric sprinkler vavle
4. 2x PVC to Garden hose adapter for the size valve you are using.
5. Old Laptop Power supply or other "Wall Wart" power brick with suitable voltage for your valve.
6. One 5v Relay ( radio shack )
7. One Diode ( radio shack )
8. One Male DB 25 connector ( radio shack)
9. Some Wire.
10. Tape, Electrical Tape and Plumbers Thread tape
11. PCB blank ( I used some scraps from other projects)
13 PCB enchant.
14. Old computer ( I used a Pentium III box ) just make sure it has the standard LPT printer port for the DB 25 connector.
Step 3: Build the Electronics...
The entire process relies on the parallel port from your computer outputing 5v logic to activate the relay and power on the sprinkler vavle.
The Parallel port is capable of provide the 5v logic from the data pins 2-9. This will be +5v when activated and 0v when off. We just need to grab that on off signal and use it to control our sprinkler vavle.
In the diagram you will see how everything is connected. The 5v logic comes trought the DB25 connector on any pin 2-9 and then powers the coil in the relay and returns to the computers ground. The diode protects the computer from any current stored in the relay coil. when the relay is activated the power from the wall wart will flow through the relay opening the sprinkler valve. thus causing the water to flow.
I used a sharpie to draw a simple circuit to solder the wires for the relay and diode too. Simply draw it on the copper side etch and drill. I also had some screw terminals left over from a previous project that I incorporated but they are not necessary.
Step 4: Plumbing...
In this step you will probably drench yourself so plan accordingly. Never leave home without a towel anyway.
you will need to connect the sprinkle valve between your garden spigot and sprinkler flow the arrow on the bottom of the electronic sprinkle that shows you the direction that water will flow.
Use the plumbers thread tape on all threaded connections including the spigot. this will help control leaks.
Once everything is plumbed up like you want it. simply open your spigot and return inside.
The water should stop at the sprinkler valve.
on to software....
Step 5: Software...
Install your linux os of choice. I run ubuntu for other things arround the house so I will be installing it. everything should work the same on linux.
I am by no means a programmer. I have dabbled in web programming and PHP code but never any system level codeing. I was able to download and compile parcon.
parcon is available here
After downloading and compiling running
./parcon 5h 3h
will provide 5v power logic out of the number 5 pin. I found that on my computer this circuit did not have enough power to switch the relay. I overcame this by wireing two pins and ground together in parallel. ( yo dawg ) This provide the power needed to throw the relay and I was rewarded with the sound of water rushing.
./parcon 5l 3l
powers off the relay and allows the valve to close.
almost to automated awesomness
Step 6: Scheduling...
Crontab is a very easy and powerful way to schedule tasks in linux. You can use it to run any program at a predetermined time daily monthly hourly down to the second. I have mine set to be on for 5 min and off for 5 min.
Note. You must run the parcon executable as root. This means you must edit the root user's crontab file.
1. sudo su
2. enter password
3. crontab -e
Here is an example of my crontab file.
# m h dom mon dow command
30 7 * * 1,3,5 /usr/bin/parcon 1h 2h 3h 4h 5h 6h 7h 8h
35 7 * * 1,3,5 /usr/bin/parcon 1l 2l 3l 4l 5l 6l 7l 8l
40 7 * * 1,3,5 /usr/bin/parcon 1h 2h 3h 4h 5h 6h 7h 8h
45 7 * * 1,3,5 /usr/bin/parcon 1l 2l 3l 4l 5l 6l 7l 8l
50 7 * * 1,3,5 /usr/bin/parcon 1h 2h 3h 4h 5h 6h 7h 8h
55 7 * * 1,3,5 /usr/bin/parcon 1l 2l 3l 4l 5l 6l 7l 8l
00 8 * * 1,3,5 /usr/bin/parcon 1h 2h 3h 4h 5h 6h 7h 8h
05 8 * * 1,3,5 /usr/bin/parcon 1l 2l 3l 4l 5l 6l 7l 8l
10 8 * * 1,3,5 /usr/bin/parcon 1h 2h 3h 4h 5h 6h 7h 8h
15 8 * * 1,3,5 /usr/bin/parcon 1l 2l 3l 4l 5l 6l 7l 8l
20 8 * * 1,3,5 /usr/bin/parcon 1h 2h 3h 4h 5h 6h 7h 8h
25 8 * * 1,3,5 /usr/bin/parcon 1l 2l 3l 4l 5l 6l 7l 8l
Step 7: Other Notes...
I learned a lot making this little contraption.
1. bury your line to the garden if it is in a high traffic area or where you will be mowing the grass.
2. don't rely on old printer cables to make a DB 25 connector, it was a pain and it didn't work. spend the 1.25 at radio shack or look them up on digikey.
3. Don't water too much. initially I had the water pressure set too high and was watering most of the yard and the neighbor's yard. ( adjust the pressure with the water spigot.)
4. Make sure your Wall Wart power supply can switch your sprinkler valve. Most say 25 volt AC but I am using a 12 DC Wall wart without any trouble.
5. you could add multiple sprinkler valves and relays to add functionality to your automated system.
6. Any linux remote connection program will let you manually connect and activate your sprinkler. You could operate it from you phone or laptop
Good luck with your own projects.