Arduino sprinkler valves + wifi + twitter

FeaturedContest Winner
Picture of Arduino sprinkler valves + wifi + twitter
[Edit: I made the hardware part more compact by using a relay shield. If you plan on using 4 relays or less, then have a look here...]

This is my first post so... be brutal !

I have a small yard with a very odd shape, well... L-shaped really and not enough pressure at the tap to be able to water it in one go. So I had to create 3 sprinkler sub systems that can only be turned on one at a time.

I sourced 3 Gardena valves but refused to cough up the extra cash for their dull 'computer' (not sure why they call it a computer btw). Besides, controlling the valves from a browser was the bear minimum I would expect and Gardena does not offer this functionality. (My friend) dd-wrt even allowed me to re-use an old router of mine and made the whole thing wireless...

Arduino time, I say...

As a bonus, I inserted at the end of this instructable my scripts that automagically turn the sprinklers on and off, check the weather forecast (so I don't water the lawn if it is going to rain soon) and log their activity on twitter.

Enjoy !

Here are the parts I used for this project:

- various pipes / hose adapters (from Gardena)
- 3 x 24v Irrigation Valve (from Gardena)
- 1 x arduino board
- 1 x ethernet shield ( )
- 1 x relay board (which I had lying around, a smaller board / a relay shield - with at least 3 relays - would have been sufficient)
- 1 x 220v -> 24vAC transformer (from ebay)
- 1 x 10vDC adaptor (a recycled phone charger)
- 1 x router (Buffalo WHR-G125) with dd-wrt ( )
- 2 x momentary push button
- 1 x power switch
- a couple meters of ethernet cable.

Remove these adsRemove these ads by Signing Up
Ah ha! Your transistors are on their own board... Got it!
nicoo (author)  Chris the Carpenter3 years ago
Yep, I used my 'proto relay shield' for this project. I had in mind to eventually build a dedicated pcb / protoboard. Although I since have found an arduino relay shield (at which is going to be just fine.
I will post an update when I have retrofitted my project with it.
nicoo (author)  nicoo1 year ago
Finally got around and did it... It's here:

I hope this will make the project simpler to tackle for those who were put away by the apparent mess...

zhenry12 years ago
This is really cool. I've been wanting to do something like this for a while, and this gave me a ton of good ideas. I have an old 12 zone (expandable to 16) rainbird clock that I'm thinking of converting using your plan. The programming logic and the valve switching are on two separate boards, so I'm thinking I can use your idea just replacing the relay board with the rainbird switching board. I'll let you know how I do.
nicoo (author)  zhenry12 years ago
Thanks ! Please keep us posted.
zhenry1 nicoo2 years ago
Will do! My first stumbling block seems to be selecting the hardware... I'd wanted an all-in-one ethernet Arduino because of its low price, but it's look like that won't give me near the outputs I need. I've got 12 zones connected now and an ever evolving drip system, so I want something with plenty of outputs. The rainbird board has what looks like a 24-pin harddrive connection on it. I'm thinking I'll bite the bullet and pay for the new Mega and an ethernet shield. Decent plan?
nicoo (author)  zhenry12 years ago
I never used the all-in-one ethernet arduino but make sure your ethernet board / shield is built around the W5100 chip and has an integrated SD card. It will save you a lot of hassle.

A Mega seems overkill for your project. In a similar situation I was able to chain up 4 shift registers (SN54HC595J) for a total of 32 digital outputs, only using 3 pins of the 'regular' arduino. Digital outputs are the one type of I/O really easy to extend.

zhenry1 nicoo2 years ago
I got the UNO and some shift registers as you recommended. Thanks for saving me some dough!

I'm running into trouble now connecting to the existing rainbird board. My original idea was just to use the existing 24 pin plug on it, but figuring out the existing logic has been complicated. It also appears to be getting 24V off of the logic board. My electronics knowledge is limited and I think converting 5V logic to 24 is more hassle than its worth.

I ordered today a sainsmart 16 relay board for $29, that's built to use with Arduino, and am going to try and attack from that angle. Thanks for the advice, and I'll let you know how I do.
jhall302 years ago
Thank you so much for this contribution!

After I got my Nest Thermostat, I got totally fed up with not understanding our sprinkler system, and have been really wanting something like this. Our system is a bit more complex, but I'm sure I could get it to work just fine.

Also, I'm thinking about the possibility of a touch-screen interface next to the controller in the garage (for our landscape people), and doing a web interface for our own use.

This might be the first step I take towards smartifying our house (aside from seeing if I can retrofit solar/rechargeable into our electric blinds).

Thanks again!
nicoo (author)  jhall302 years ago
Thank you for the kind comment !

I think the trick is to make the (sprinkler) controls as low-tech (aka robust) as possible and connect to them through ethernet / wifi. Once you are on a computer you can make your interface as fancy as you want (e.g. connect to your system through a web interface on a dedicated tablet, automate tasks with scripts, send data to an internet-of-things web server etc...)

Btw, my sprinkler system is still in use and has been upgraded to 6 valves...

Have fun !

nicoo (author) 2 years ago
Here are a few helpers that might be useful to others (originally by PM):

1. a relay has 3 output pins: no,nc,common. You should (must) use common and no, so that when your relay board / arduino is not powered, your circuit is open.

2. I found that my arduino powered from the USB port was not able to switch the relays. I had to have the external power connected at all time so that I could test while connected to the computer.

3. vcc and ground on your relay board must be connected to the arduino vcc and ground. It is possible (although unexpected) that your board expects a 5v on each input pin in order to remain in its normal state (i.e. same state as un-powered) and a 0v to switch state. Change the sketch accordingly if this is the case (swap LOW for HIGH everywhere onoff is used/tested).

4. pin 0 and 1 are special on the arduino as they are used for communicating with the IDE. If you are not prepared to deal with the added complexity, avoid them.

5. the ethershield also uses some of the (digital) pins of the arduino. Look at your documentation to see which pins are unused and therefore available for your program. For example, if you need 4 relays and if you use the same shield as me, use pins 4,5,6,7 for your relays. Instead of using pin 4 for ground (which was just a convenient trick for me), just remove all code related to this pin and use the 'ground' pin on the arduino board instead.

6. I only use one button in my sketch. I intented to have different ways of cycling through which proved useless once I had the http interface in place.

7. If you want two buttons for your application, bear in mind that for 2Kohm, one can use two 1Kohm resistors in series. Alternatively, if this part is causing more confusion than help, use one analog entry per button (e.g. A0 and A1).

8. If your switch box is behaving weirdly, un-comment out the line '#define WATER_DBG', you will get some debug information on your console and understand what is going wrong with your switch.

9. Led indicators: simply add a led (and the corresponding resistor) to pins 4,5,6,7 to get a feedback on your pins' states.

I hope this helps,

bpike12 years ago
Thank you for such a brilliant contribution. I have ordered the parts for this project and waiting for their arrival.  I participate on a community farm and intend to use this to remotely control some irrigation.  I am particularly interested in extending the web interface for this, with specific interests introduce and extend features of time.  My ideas so far;
- Web scheduling interface
- Web viewable logging
- Skip watering if soil moisture levels above a certain reading
- Email event notification
- Failure detection and handling (power interruptions etc)

I'm thinking the interface would be best implemented as a MySQL / PHP application.  Is this something you would have interest in collaborating with me on?
nicoo (author)  bpike12 years ago
Sure, I would be happy to help (although my time is usually fairly tight so don't expect much more than ideas and pointers from me).

Talking of which... maybe you can have a look at
I run this frontend to control my X10 devices and I think it would be very easy (if not built-in already) to have commands run wget or curl (to control the arduino web interface) instead of heyu (the X10 control).

With scheduling + logging already there, it is probably a good base for your project.


Damonic3 years ago
I've been DYING for someone to do something like this! Bravo! However I agree, a bit more detail and sources for the relay board, etc. Spoon feed me!
nicoo (author)  Damonic3 years ago
Thank you !

I have added details about the relays on the 4th step. Hopefully this will shed some light. Let me know if you have more questions.
Are you running the relays directly off the output pins? No transistors? No Darlington driver?
nicoo (author)  Chris the Carpenter3 years ago
Well, this diagram is really there to give an overview of the connections of the arduino + shield to the rest of the components. The relays can not / should not be driven directly off the output pins.

I tried to be more precise but then the diagram became messy and missed the point, I thought.

The 'A0' connection is one that I can never find documented when I need it (the 2KOhm resistor especially) so here it is for your (my) reference. I have added up to 5 push buttons (on one analog pin) this way in other projects, it works great.
vishalapr3 years ago
I would like to do this but no ethernet shield so I will just follow my instructable
nicoo (author)  vishalapr3 years ago
...and I will follow mine ! ;-)
crapflinger3 years ago
i think a parts list would be really helpful here. you get 3 or 4 steps in and then all of a sudden start talking about a relay board. it's a little confusing
nicoo (author)  crapflinger3 years ago
Good point.