In an earlier instructable, presenting an automatic garden watering project with an Attiny, I mentioned it could also be done with an op amp. So, let me put my money where my mouth is and present you one. It has an option to use a regular relay, or a solid state relay
Here is what you need:
1 Opamp UA741 (or LM741, or other '741 'type')
1 LED (red or green, for LED's with a high voltage drop, like blue, you may want to adapt R2)
1 resistor of 10-200k (I'll get back to that in the text)
1 resistor of 10-100 Ohm (whatever you have lying around)
1 reed switch (The small ones in a glass) if you can't find one, try a door contact
1 8 pins DIL IC foot
1 electrolytic capacitor 220uF 16-25 V (optional)
1 small submersible pump (I use a 5 W pump that pumps 430 l/h that is about 7 liters a minute) (Garden centers, eBay)
- if you chose to build the thing with a solid state relay add the following:
1 resistor 220 Ohm
1 solid state Relay (I use a 39MF22)
1 8 pins IC foot
1 resistor of 100 Ohm (optional)
1 capacitor of 100 nf 400 V (optional)
Note. I have chosen the 39MF22 solid-state relay because it is rather cheap. If you cannot find
it in your area, choose the mechanic relay. If that is no option consider replacing the solid state relay by an optocoupler with TRIAC. If you have a low voltage DC pump, consider switching it with a FET or transistor, or the mechanical relay
- if you chose to build it with a mechanical relay, add the following
1 resistor 1k
1 NPN transistor such as BC547
1 diode 1N4001
1 relay (make) voltage 5-18 Volt (depending on your situation)
A large bucket (DIY stores, I use one that is used to mix cement)
Tubing/Hose (DIY stores, garden stores)
Double cable low voltage
110-220 V cable suitable for outside use (DIY stores)
2 galvanized nails or a galvanized clothes hanger (DIY store, your mothers closet), or 2 carbon rods from an old battery
heat shrink tubing
blank PCB of about 5x5 cm
Hydrochloric acid (drugstore, diy store)
A watertight wall socket for outside use (DIY store)
A wallwart PSU of 5-15 Volt (depending on your situation).
That is very difficult to say as I had much of the stuff already available. The most expensive was I think the pump (14 euro's). The electronic components are really nickle and dime stuff. A 741 cost 25 cents (euro's), the 39MF22 was 1.80 euro.
I used a watertight wall socket that I had available, but I think these are about 3 euro's. Everybody must already have a wallwart PSU available somewher.
Mains cables for outside use are not really cheap (say a euro/meter) but often you can get it cheaper and if you are a gardener, you may have something left over from a previous installation.
I am not really counting the chemicals for etching either coz I had these for other projects as well, but also that is very cheap.
If I just count stuff that I had to buy especially for this project, it may have costed me 20-25 euro's, but I guess that if you dont have that much stuff laying around, it could be 35-40 euro's.
I will cover the following steps:
The electronic circuit (Intro)
Printing the PCB (step 1)
Etching the PCB (step 2)
Mounting the components (step 3)
Using a stripboard instead of a PCB (step 4)
Making a humidity sensor out of galvanized material (step 5)
Making an alternative humidity sensor out of gypsum (step 6)
Making a level indicator (step 7)
On overview of the finished project (step 8)
Seeing it in action (step 9)
Expansions (step 10)
The circuit is quite simple. P1 is used to set the level where the pump should start pumping. In dry soil the resistance of the spikes is high and the voltage on the inverting pin of the opamp is low. If that is lower than the voltage on the non-inverting pin (set by P1) the output will go high. This will activate the solidstate relay (a 39MF22) and or activate the mechanical relay. The PCB allows for both. The value of R1 is depending on your humidity sensor and the type of soil you use. For me 10 K was a good choice. In Step 4, where I describe the humidity sensor. I will tell you how to choose a good value for this resistor.
The pump that I use is a small submersible pump, used for small pond fountains. It pumps water from a container into a drip line in my veggie bed. Submersible pumps do not like to run dry, so we need some way to measure the waterlevel and to stop the pump when the level is too low. That is where S1 and R5 come in. S1 is a simple Normally Open float switch. I use a reed relay attached to the outside of the container and a floating device with a magnet on the inside (more about that later. When the level in the container goes too low, the float switch closes.
The trick is that I connect the floatswitch via a very small resistor (10-100 R) to the same terminals that the moisture sensor is attached to. So if the water level is too low, and the switch closes, there suddenly is a very low resistance over the humidity spikes and the 741 Op amp is 'tricked' into 'thinking' that the soil is wet enough and will switch off the pump.
You could use other switches than a reed relay, but this one has worked for me (I will come with some suggestions later)
C2 is not really necessary. One can put it in to give a bit of a delay with switchin the relay's on or off and thus avoid jittering.
The voltage to feed the 741 op amp is not so critical. Mine works on 5 Volts (I would not go much lower) but depending on the type of 741 you use you may go as high as 18 or 22 Volts. If you do though, you may want to recalculate R2. The current value of R2 is 220 Ohm.
In calculating the resistor value for other voltages, take the following in consideration: The 39MF22 has forward voltage of 1.2 Volts. Current should be between 5 and 20 mA. Most green or red LED's have a forward voltage of 2 Volts. Therefore the value of R should be at least (Vcc-3.2)/20 (gives value in kOhm) and at most (Vcc-3.2)/5 (gives value in kOhm).
So for 5 Volts this would be 1.8/20=90 Ohm till 1.8/5=360 Ohm
This table will save you calculating the value of R2:
Voltage Minimal value Max value
5 90 360
6 140 560
7 190 760
8 240 960
9 290 1160
10 340 1360
11 390 1560
12 440 1760
13 490 1960
14 540 2160
15 590 2360
16 640 2560
17 690 2760
18 740 2960
Values in Ohms. Just chose one sort of in the middle of the range for your voltage
The snubbing network around C1 and R3 is optional and most likely not necessary as I understand solid state relays to be quite capable of handling inductive loads. If you use it, put it in the wall socket (more about this later)