Irrigation Controller


16 posts
by Gru » Tue Jun 26, 2012 1:58 pm
I just got my first Raspberry Pi yesterday, and am eager to start learning with it. I have been using both Debian and Ubuntu Linux for about 10 years already, but am by no means a power-user of Linux. I can get a system up and running, and do some basic things, but I have a lot of room to grow.

One project I have in mind that I really want to learn how to do is put together a controller for my home sprinkler system. The off-the-shelf controller I have is very basic. It will let me set up three programs to run my nine zones, and has a rain sensor that will stop the system from running if it has rained recently.

So far the ideas I have for my system include:
*Unlimited programs. I need one basic program to run the sprinklers every even-numbered day of the month from June to early October. However, I'd like the ability to easily add programs that can either be finite or indefinite. For example, if I put down seed or sod in one zone to repair a patch of dead grass, I'd like to set up a program to water that zone two or three times per day for a few weeks and then stop.
* Web control On my programming education to-do list is to learn to make Android - and then iOS - apps. Apps aren't necessarily a must for this project, but it would be nice to at least be able to create a mobile-ready web page to control my system. I'd like to be able to walk around the yard with my phone and turn zones on and off manually. This is especially useful in the spring when starting up the system (to check for broken sprinkler heads) and in the fall when blowing the system out for winter. It might also be nice to run it remotely too. I'm not sure why I'd want to start my system up from three states away, but if I come up with a good reason when I'm there, it would be nice to be able to.
* Rain sensor This should be the easiest requirement of all. I have to be able to hook up my rain sensor to prevent the system from running if it has rained recently. I believe my sensor is just a normally-closed circuit that opens when wet (not sure of the mechanics, but that's the electronics of it).
* Weather forcasting. It's great to save water when it has already rained, but it would be even better if I could set it up to not run if the weather forecast predicts rain. I have no idea what threshold I'd set yet (50% chance of rain, 70%, etc. - 1 inch, 1/2 inch, etc.) There's nothing more frustrating than seeing the system finish watering an hour before a storm rolls through.
* Variable Start Time - I run it in the morning, but it might be nice, rather than starting at 6:00, to start 30 minutes before sunrise, at sunrise, or in some other way tie it to a moving target, or be altogether variable.

There's my idea, but I have no idea where to start. I am assuming at this point that Python may be the easiest programming language to learn for this. However, I have no idea how to interface this system with the sprinkler heads, which require 24volts to run (AC I believe, but would need to verify). Any advice on implementing this would be greatly appreciated.
I fly to the moon, I shrink the moon, I grab the moon, I sit on the toilet bowl... what?
Posts: 7
Joined: Fri Jun 15, 2012 1:48 am
by dmsuse » Tue Jun 26, 2012 9:44 pm
A neat little project you have, I have plans for something similar in the future.

I wouldn't bother with python; unless you are interested in learning it. The best and simplest thing you can use for this project is bash script.

it is as simple as putting in a relay between the wires on your sprinkler, connect it to the pi and having a bash script turn it on.. the weather forecast (to not work when rain is on the way) would also be possible to do with bash, so too the web control should be pretty easy.

The only thing I am unsure about is the rain sensor.
Posts: 5
Joined: Sat May 19, 2012 9:47 pm
by frankSoCal » Tue Jun 26, 2012 10:03 pm
I am working on a similar project too. I'm an IT guy therefore I do not know electronics too well however I took apart a four station timer and noticed it had two circuit boards, a timer/clock and power. both boards are connected with two ribbon cables, power (3.3v DC) and stations. I am going to try and reuse this power board and its wall wart by increasing the board power output to 5V and connecting the pi to it.

user interface: lighthttpd, php, jquery mobile and sqlite database (I got these installed already).
backend: python daemon to query database and maintain cron jobs to activate stations. cron job will execute a python file with timer delay.

weather conditions: There are several free weather api's

hope this helps
Posts: 2
Joined: Tue Jun 26, 2012 4:32 pm
by fatcinco » Tue Jun 26, 2012 11:10 pm
I know this is not the same as building it yourself but I currently have OptiRain Open running on my Pi. It connects to an EtherRain controller. I am extremely happy with it. The EtherRain controller is easy to connect to with their web service but OptiRain was so complete, I just moved on to the next project.
Posts: 26
Joined: Tue May 15, 2012 4:50 am
by Gru » Tue Jun 26, 2012 11:12 pm
dmsuse wrote:A neat little project you have, I have plans for something similar in the future.

I wouldn't bother with python; unless you are interested in learning it. The best and simplest thing you can use for this project is bash script.

it is as simple as putting in a relay between the wires on your sprinkler, connect it to the pi and having a bash script turn it on.. the weather forecast (to not work when rain is on the way) would also be possible to do with bash, so too the web control should be pretty easy.

The only thing I am unsure about is the rain sensor.

Thanks.

The relay is unclear to me. Not sure exactly how that works.

I would like to learn Python just as part of getting a rounded education in programming. (Sounds like a good starter language anyway.) I've started a little Java programming (an intro course from Stanford on iTunes U), but had to shelve it to finish up some unrelated professional development. I intend to pick programming back up when that's finished.

frankSoCal wrote:I am working on a similar project too. I'm an IT guy therefore I do not know electronics too well however I took apart a four station timer and noticed it had two circuit boards, a timer/clock and power. both boards are connected with two ribbon cables, power (3.3v DC) and stations. I am going to try and reuse this power board and its wall wart by increasing the board power output to 5V and connecting the pi to it.

user interface: lighthttpd, php, jquery mobile and sqlite database (I got these installed already).
backend: python daemon to query database and maintain cron jobs to activate stations. cron job will execute a python file with timer delay.

weather conditions: There are several free weather api's

hope this helps

Hacking in parts from an existing controller is an interesting idea, but until I have a finished, working product, I'm not going anywhere near my existing controller :D

Are you documenting your project anywhere? If so, I'd love to see the details.
I fly to the moon, I shrink the moon, I grab the moon, I sit on the toilet bowl... what?
Posts: 7
Joined: Fri Jun 15, 2012 1:48 am
by Gru » Tue Jun 26, 2012 11:14 pm
fatcinco wrote:I know this is not the same as building it yourself but I currently have OptiRain Open running on my Pi. It connects to an EtherRain controller. I am extremely happy with it. The EtherRain controller is easy to connect to with their web service but OptiRain was so complete, I just moved on to the next project.

I'm happy to use something already done too. I usually figure that once I start looking into something I've dreamt up, I'll find something someone else has already done - and better than I could do. Thanks for the heads-up, I'll at least look into it.
I fly to the moon, I shrink the moon, I grab the moon, I sit on the toilet bowl... what?
Posts: 7
Joined: Fri Jun 15, 2012 1:48 am
by carlpalmer » Wed Jun 27, 2012 12:50 pm
I am also looking to get some automation for irrigation. Love you follow progress by those who have their Pi
Posts: 2
Joined: Wed Jun 27, 2012 12:47 pm
by Gru » Wed Jun 27, 2012 1:16 pm
Upon further investigation, I'm looking into the "Irrigation Caddy". It is similar to the "EtherRain", but has more zone controls (I need 9, would like 10). I'm not exactly sure how open it is, and their software is unimpressive, but their blog says they have an API that will allow you to create custom programs using HTTP GET and POST requests. If I understand that correctly, it's not the perfect solution, but better than I started with.
I fly to the moon, I shrink the moon, I grab the moon, I sit on the toilet bowl... what?
Posts: 7
Joined: Fri Jun 15, 2012 1:48 am
by tech_monkey » Wed Jun 27, 2012 2:02 pm
Have a look at this site http://www.wgldesigns.com/ .They do a variety of water sprinkler controllers, designed for use with computers or home automation systems.
For the rain detection, I would use a rain sensor. Most have some form of expanding disc. When it gets wet it expands. Be careful though if you live in a very humid area the sensor sometimes thinks it has rained when it hasn't.
You could have override buttons for each zone so if you push button 3 zone 3 will turn on for 30 minutes or so. Or similar.
I would also have some form of water flow sensor just in case a valve fails you can then have another valve on the input to the manifold for the zones. This can then be turned off in case of problems.

I've done similar with the x10 rain controller from WGL Designs.
Zone 1 comes on 15minutes after midnight, for 10 minutes then Zone 2 for 5 minutes, then Zone 3 for 5 minutes and then Zone 4 for 15 minutes. It was also possible to turn on or off any zone at any time of day. The zone would only be on for a allowed maximum, so Zone 1 10min and zone 2 5min etc. This is set in the controller itself, just need to hook it up to a PC running windows, to change the default settings.
Hope this helps.
http://www.casatech.eu
Posts: 130
Joined: Fri Mar 09, 2012 6:12 pm
by frankSoCal » Thu Jun 28, 2012 4:31 pm
I have not been documenting my project but I took a picture of the board that I want to connect to the pi. I want to modify it to output 5V. I am hoping I can just change a diode or resistor to get 5v DC. Input voltage is 26v AC from a wall wart, Any suggestions on what I need to swap or change to power the pi? or if it is even possible? It will save me a lot of time googling.

IMG_000.jpg
IMG_000.jpg (53.86 KiB) Viewed 3974 times

Thanks
Posts: 2
Joined: Tue Jun 26, 2012 4:32 pm
by rayshobby » Fri Feb 22, 2013 12:28 am
Just finished my sprinkler extension board for Raspi, it's called OpenSprinkler Pi:
http://pi.opensprinkler.com
I haven't written a full-featured scheduling algorithm yet, but there is a demo that shows how to use Google calendar to program sprinkler events.

I used a switching regulator to convert 24VAC to 5VDC. There are many switching ICs, I picked the most common one: MC34063. Schematics and program code are all open-source. You can download from the link above. Thanks.
Attachments
ospi_header-300x225.jpg
ospi_header-300x225.jpg (18.29 KiB) Viewed 2672 times
Posts: 3
Joined: Fri Feb 22, 2013 12:23 am
by abishur » Fri Feb 22, 2013 3:34 pm
Very nice looking! It would seem we're working on kinda the same thing :-)

This may be the wrong direction for you, but I've written up some code that runs an auto schedule using mySQL, and C++ and provides web control with PHP.

It is, admittedly, a work in progress that has gotten hung up due to the fact that I *really* want some of the content on the web page to auto update, but html and javascript are not my forte. Feel free to make use of any of the code that works for you (just be sure to give me a head nod if you do ;-) )

viewtopic.php?f=37&t=32350
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4263
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by rayshobby » Fri Feb 22, 2013 4:37 pm
Very nice. Indeed seems we are working on the same line. I actually started with an Arduino-based circuit (you can check it out at http://www.opensprinkler.com) and I've written a full-featured scheduling program for that version (which stores program data in EEPROM and formats webpages using Javascript). Then recently I bought a Raspi and started working on the extension board for Pi. We (me and a friend) have been working on converting the Arduino-based program to Pi. So hopefully the new program will be released soon. I haven't thought about using mySql: so far we've just been storing program data in a human-readable text file. I want to keep it simple to start.
Posts: 3
Joined: Fri Feb 22, 2013 12:23 am
by abishur » Fri Feb 22, 2013 7:00 pm
So how did y'all end up going from 24V down to 5V? I had the joy of also having AC solenoids on my sprinklers so I had to go from AC to DC then step it all down to 5V :roll:

In the end I've put a LM2596 circuit together, I haven't gotten the opportunity to test it out yet (my smallest drill bit is too large), but it should do a nice job of stepping down the voltage without producing too much excess heat.
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4263
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by rayshobby » Fri Feb 22, 2013 7:48 pm
abishur wrote:So how did y'all end up going from 24V down to 5V? I had the joy of also having AC solenoids on my sprinklers so I had to go from AC to DC then step it all down to 5V :roll:

In the end I've put a LM2596 circuit together, I haven't gotten the opportunity to test it out yet (my smallest drill bit is too large), but it should do a nice job of stepping down the voltage without producing too much excess heat.


I used a simple half-wave rectifier + MC34063 switching regulator to step 24VAC down to 5VDC. MC34063 can be noisy, but is quite a bit cheaper than LM2596. On the other hand, I think LM2596 is more robust and can sustain impulse high voltages.
Posts: 3
Joined: Fri Feb 22, 2013 12:23 am
by abishur » Fri Feb 22, 2013 9:00 pm
Ah, that makes sense. If I wanted to produce more than my one little circuit I probably would of chosen a more cost effective one. As it was I just chose one of the first ones I saw that could handle the job :lol:
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4263
Joined: Thu Jul 28, 2011 4:10 am
Location: USA