introA watering controller that can be home networked
A couple of weeks ago, I published a great little controller module that provided 6 relays able to be controlled from a computer via a network. After I published it, I got to thinking that the same basic design, with a couple of changes could be pressed into service as a garden watering system controller. So, I got to work, modified the design, and here you have it... A sprinkler controller that runs by itself, that can be programmed and monitored from your computer via your home network.
This specific version of my sprinkler controller obeys some simple rules that have had to be implemented where I live. I live in Australia, or more specifically in an inland region called the A.C.T, where our government have implemented an ODDS and EVENS watering regime. Under the system if you live in an odd numbered house, you may water on an odd day of the month. Likewise, if you live in an even numbered house, you may water on an even day of the month. Everybody may water on the 31st.
This system, along with the mandatory replacement of sprinklers for dripper systems has sucesfully reduced the load on the cities limited inland water supply so that more drastic measures were not required.
Unfortunately, this system was unable to be implemented on my commercial water controller, it wanted to water on a Monday, or a Wednesday, so I was breaking the law, and subjecting myself to a potential fine every other week... So I had to build my own controller.
This instructable shows how I built it - there certainly is enough detail shown so that you can make it yourself if you are enthusiastic, and willing to give it a go.
Update: the full source tree for the Kicad project is located here
step 1How do you drive the solenoids?
The sprinkler controller is built on the base of my Adruino Ethernet controller. The Arduino ethernet controller provided a basic network connected ATMega328 chip, and had a number of spare I/O lines.
I extended the PCB design to provide 6 solid state outputs, each able to drive +12v at 300mA, which is enough for a watering solenoid.
Each solenoid output is driven from a NPN transistor, as shown by the attached picture. To turn on the transistor, the port pin is simply driven high. I decided to use individual transistors, as they cost $0.03 each, and if they are destroyed, they are individually replaceable easily.
There is also a DS1302 RTC chip on the PCB - it is simply driven directly off 3 pins of the Arduino.
The whole board is driven by a 12VDC plug pack transformer.
It is not sensible to describe the full details of the Ethernet controller here, just check out the Arduino Ethernet controller (which is basically an Arduino and a NuElectronics shield) for info.
You will find the full schematic diagram attached as a PDF.
Sprinkler-Controller-Schematic-v1.pdf(595x842) 82 KB
step 2Making the board
To make the PCB, I used press-n-peel and toner transfer, as I do for all of my projects.
Essentially, I print the PCB layout onto some toner transfer paper. I use Press-n-peel Blue, which costs a bit of money, but is beautifully reliable. That is then laminated onto some clean PCB stock the paper is removed, and the layout is touched up using a permanent marker where there are dust spots.
Then I etch the board using a mixture of 120mL Hydrochloric Acid, and 240mL of Hydrogen Peroxide (20%) - The excess copper is dissolved in about 5 minutes, then the board is thoroughly washed to ensure that all acid is removed.
Then I scrub the toner material off the board using steel wool, and protect the board using a solder through spray lacquer.
Finally, I drill the board using my trusty Dremmel (Which has been working great for 20 years)
I have made hundreds of boards using this method, and it works really well. Just be very careful using acids - wear eye protection, old clothes, and gloves. And make sure that you protect your stainless steel laundry sink. I protect mine by filling it with 10Litres of water, that way when a couple of drops of acid end up in it while I am rinsing off a board, it is diluted by lots and doesn't damage anything. :-)
step 3Soldering the components
Once the board has been made, I solder the parts onto it.
My board needed a few jumpers, because I can't make double sided boards at home, so I soldered them in first.
I used surface mount parts for some of the components. These were soldered onto the back of the board next. These components are simple to solder and it is well worth taking the effort to get them soldered - as I do more and more of them, I am finding it easier and easier.
There are many great instructables on how to solder surface mount parts, just have a look at one of them for ideas.
After the surface mount parts are soldered, continue by soldering the rest of the components.
I have created an assembly manual that shows the steps that I used. If I decide to make kits, this will be the manual that I will supply. It is attached.
Sprinkler-Controller-v1-Manual.pdf(595x842) 800 KB
step 4Programming the micro
After all of the parts have been mounted, load the code into the micro.
I use a FTDI USB-TTL cable for all of my Arduino programming work. If you don't have a cable, you can use your Arduinoboard. Simply unplug the micro from your board, plug in the ATMega328. Program it as per normal, and then move the programmed chip into the sprinkler controller.
Easy!
Here is the code for the project as a PDE file.
step 5Testing and programming
Now that you have the micro programmed, plug it into the board, and apply power.
The yellow led at the bottom of the board should flash a couple of times. If it does - YAY IT WORKS - if it doesn't, check for solder shorts and misplaced components.
Connect an ethernet cable between the board and your computer.
Make sure that the IP of your computer is 192.168.1.1 (for the default range in the code), open a web browser to 192.168.1.2, and you should see the screen below!
If you can see it - you are there. Set the clock, and define when you want the watering to happen, and create your program.
There you have it - you are there!!!!
If you decide that your home network is on address 10.0.0.x then you can simply modify the line in the PDE file to put the controller on the 10.0.0.x network and re-program the chip.
ie change these lines from this:
static uint8_t myip[4] = {192,168,1,2};
static char baseurl[]="http://192.168.1.2/";
to
static uint8_t myip[4] = {10,0,0,12};
static char baseurl[]="http://10.0.0.12/";
step 6Parts List
Capacitors
10uF SM x 4
18pF SM x 4
0.1uF SM x 3
Resistors
51R x 4
270R x 12
470R x 6
2K7 x 1
10K x 3
Semiconductors
AtMega168 micro (DIP) x 1
DS1302 RTC (DIP) x 1
ENC28J60 Ethernet (DIP) x 1
74HC08 AND Gate (SOIC) x 1
GREEN LED 5mm x 6
YELLOW LED 5mm x 1
RED LED 5mm x 1
BLUE LED 3mm x 2
BC547 Transistor x 6
1N4004 Diode x 7
16Mhz crystal x 1
32768Khz Crystal x1
25 Mhz crystal x 1
78L05 Regulator x 1
78L33 regulator x 1
Hardware
2 Pin PCB screw connector x 4
3 Pin PCB screw connector x 1
6 pin 0.1 inch pin array x 1
Small Pushbutton x 2
RJ45 MagJack from Sparkfun x 1
(http://www.sparkfun.com/commerce/product_info.php?products_id=8534)
8 Pin IC Socket x 1
28 Pin IC Socket x 2
10uF SM x 4
18pF SM x 4
0.1uF SM x 3
Resistors
51R x 4
270R x 12
470R x 6
2K7 x 1
10K x 3
Semiconductors
AtMega168 micro (DIP) x 1
DS1302 RTC (DIP) x 1
ENC28J60 Ethernet (DIP) x 1
74HC08 AND Gate (SOIC) x 1
GREEN LED 5mm x 6
YELLOW LED 5mm x 1
RED LED 5mm x 1
BLUE LED 3mm x 2
BC547 Transistor x 6
1N4004 Diode x 7
16Mhz crystal x 1
32768Khz Crystal x1
25 Mhz crystal x 1
78L05 Regulator x 1
78L33 regulator x 1
Hardware
2 Pin PCB screw connector x 4
3 Pin PCB screw connector x 1
6 pin 0.1 inch pin array x 1
Small Pushbutton x 2
RJ45 MagJack from Sparkfun x 1
(http://www.sparkfun.com/commerce/product_info.php?products_id=8534)
8 Pin IC Socket x 1
28 Pin IC Socket x 2
step 7PCB Artwork
Here are the PCB files for toner transfer
Sprinkler-Controller-v1-Component.pdf(595x842) 41 KB
Sprinkler-Controller-v1-Copper.pdf(595x842) 86 KB
Sprinkler-Controller-v1-Jumpers.pdf(595x842) 27 KB
step 8Where to now?
I am glad you asked...
1. I will be extending the code to be more general - Not everywhere on the world has the ODDS and EVENS system in place, and some people can water whenever they want. The code changes should be pretty minor.
2. In an ideal world I would understand how to make the interfaces better. At the moment, string space on the ATMega328 is sooo limited that it has been a shoe horning exercise getting everything to fit.
3. Adding recording data would be great - It would be cool to ask the watering controller how much water I used this month.
In all - lots of options to improve the project - but this is the point where I had to say - "That will do Pig, That will do'.
If you don't understand the reference above, you need to hire a copy of 'Babe from 1995'
PS - There is no security on this device - making it accessible to the whole world via the Big Bad Internet (tm) would be a bad thing. Would you give the Internet access to your tap out the back of your house??? I didn't think so :-)
step 9DC vs AC Solenoids.
There have been many comments on this Instructable regarding DC vs AC solenoids.
I am using Rainwater 24V AC Solenoids - and they operate well using 12V DC.
Essentially, when operating a solenoid outside it's design specification, you have to understand that your experience may vary, depending on the manufacturer.
As one posted indicated, the inductance of the coil is what limits the current flowing through the solenoid to a safe value when driven in an AC circuit. In a DC circuit, there is no inductance, just the resistance of the coil. I would never recommend operating a 24V AC coil at 24V DC, that will certainly overheat the wiring, leading to premature failure.
One commenter did mention that using a coil with DC will increase the amount of heat that it had to dissipate - This is correct, as long as you don't reduce the supply voltage. Depending on the DC resistance of the coil, you may find that your specific coils run just fine.
My advice, use a 12V battery, and a multimeter measuring current, and see whether (a) the coil is pulled in enough to run, and (b) how much current is flowing when the coil is energized. As long as there is less than about half an amp, then you are likely to have no problems.
I am working on a 24V AC version of this design, so that peoples concerns are alleviated - but that won't run using a solar cell as it needs an AC supply to operate.