My friend Per Ervland nurtures his practical skills by crafting a solution to relieve him and his wife from the rather cumbersome task of keeping their container garden alive. I helped him with some of the inner workings.
He is building a two-stage self-watering container. A water tray is located immediately below the plants. A number of partially immersed cotton threads absorb the water and transport it upwards into the above plant container.
Utilizing the capillary action of cotton threads for watering has been a well-proven method for a long time. A quick online search returns lots of nice examples from home gardeners around the world.
Per is building his container for herbs. He uses wooden planks as building material, and plans on painting the inside of the container with waterproof liquid membrane.
The cotton threads are distributed evenly along the length of the container and fastened to a steel wire running through the soil.
The threads keep the soil moist as long as the bottom tray contains enough water. Hence we need to make sure that the bottom tray never gets drained! This is where my electronic pump controller comes into play.
A small water pump refills the bottom tray from a larger reservoir on the floor. The circuit is designed to operate the pump, keeping the water level well within limits.
In case of malfunction, there’s a risk of flooding. Unless the container garden is outside with no risk of damage, it is very important to have some kind of draining. A suitable overflow pipe should do the job.
Per purchased a suitable immersible water pump on eBay that worked well with our circuit.
Of course, we could have used some kind of flotation device to control the pump mechanically. However, a more elegant solution is to design a simple, electronic circuit using non-movable parts to detect the water level. The sensor is of a simple, conductive point detector type. When the water touches one of the probes, it conducts current. The input from the probes is translated to logical ‘0’ (no water detected) or ‘1’ (water detected).
The basic idea is simple enough: When the water recedes, the circuit triggers the pump and starts filling the tray. Once the water flows back to high level, the pump stops. One might assume that it is sufficient to mount a single probe at the high level, turning the pump on when no water is sensed and switching it off when the water reappears. Unfortunately – unless you implement some kind of hysteresis – the circuit will be left in a rapid changing state, turning the pump on and off continuously.
For simplicity, we actually need two probes for the sensor: One at the minimum level for where the pump should start, and one at the maximum level for where the pump should stop.
By adding a tiny bit of digital logic, we have a perfect pump controller. When the tray is empty, the pump fills it to the maximum level. When the tray drains to the minimum level, the pump restarts and fills it back up to the maximum level.
The sensor is connected via terminal block P2. The common lead (0V) must be connected to terminal 1, while the LOW and HIGH probes must be connected to terminals 2 and 3, respectively.
The probes may be any piece of conductive material, preferably something that doesn’t corrode easily. Corrosion resistant bolts should work well.
The LOW probe is responsible for turning the pump on, while the HIGH probe is responsible for turning the pump off. The physical position of the probes determines when the pump kicks in (LOW) and when it is turned off (HIGH). Some simple logic is implemented make this work properly.
Click on the schematics below to download the PDF version. The circuit is built for 5-16V power supply (typically 12V), connected at P1. It can handle up to 5A motor current when the pump runs, which should be sufficient for most applications.
The darlington (PNP) transistor pairs Q1/Q3 (HIGH probe) and Q2/Q4 (LOW probe) amplifies the current from the sensor. The sensitivity of the probes can be increased or decreased by selecting a lower or higher (respectively) value for R1 and R2.
U2 is a CMOS 4011 logic circuit, consisting of four 2-input NAND gates. Two of the NAND gates, U2A and U2B, filters the sensor input such that if the water recedes below the LOW level probe, U2A will be 1 and the pump starts. If the water covers both LOW and HIGH level probes, U2B will be 0 and the pump stops.
Some simple diode logic formed by D2 and D3 prevents the pump from going into a rapid changing state. The other two NAND gates, U2C and U2D, forms a set/reset latch, switching the pump on and off. Diode D2 blocks U2A from pulling the latch low, thus preventing the pump from being switched off once the water hits the LOW probe. Likewise, diode D3 blocks U2B from pushing the latch high, keeping the pump from being switched back on as soon as the water leaves the HIGH probe.
Transistor Q5, TIP 120, switches the pump on. It can handle currents up to 5A, but a larger heat sink may be required for such heavy loads. Diode D1 protects against reverse polarity, and 7805 voltage regulator U1 provides stabile 5V power supply. Ripples and inductive back currents are reduced by capacitors C1-C4 and diodes D5 and D6.
The LED D4 indicates when the pump is in operation. To preserve batteries, the LED can be disabled by removing jumper JP1.
A pump connected to the circuit fills the tray until the water reaches the high level probe (yellow wire). When the pump stops, the water is siphoned back to the reservoir below. When the water recedes below the low level probe (white wire), the pump restarts and the cycle is repeated.
The printed circuit board
I’ve designed a printed circuit board (PCB) for the pump controller in KiCad. Since this project is intended for hobbyists, I’ve kept it simple. It’s one-sided with wide copper traces and large solder pads.
You may etch the PCB yourself using one of many online tutorials. In that case, you’ll need printable PDF versions of the copper layer and the silkscreen layer.
A more comfortable option is to order the card from a professional PCB prototype manufacturer. I got 10 copies of my PCB for less than $ 20 plus shipping from ITEAD Studio, but there are others as well. You will need the gerber/drill files if you order from any of them.
You can always use a stripboard instead of a custom made PCB.
A stripboard is a prefabricated prototyping board with 2.54mm hole grid and copper traces. This is a cheap and quick alternative to making or ordering a tailor made circuit board, but assembling it requires more concentration.
Use the schematics to connect the components. Be careful to cut the copper traces where required and pay attention to the power pins of the 4011 circuit, as these are not drawn on the schematics. Pin 7 is the ground pin (0V) and pin 14 connects to +5V.
I ordered the components for the pump controller at Tayda Electronics. Below is a complete parts list. For some of the components, you must order the minimum quantity, but that won’t break your budget.
|P1, P3||Screw terminal block, 2 pin||2|
|P1||Screw terminal block, 3 pin||1|
|U1||LM 7805 voltage regulator||1|
|U2||CMOS 4011 quad two-input NAND gate||1|
|14 pin DIP socket for U2||1|
|D1-D3, D5-D6||1N4001 diode, 1A 50V||5|
|D4||5mm red LED||1|
|Q1-Q4||BC557 PNP transistor||4|
|Q5||TIP120 NPN transistor||1|
|Heat sink for Q5||1|
|C1||470µF electrolytic capacitor||1|
|C2-C4||100nF ceramic capacitor||3|
|R1-R2, R5-R6||370kΩ resistor||4|
|R3-R4, R7-R8||3kΩ resistor||4|
|R9-R10, R12||10kΩ resistor||3|
|JP1||Pin header row||1|
|Jumper for JP1||1|
Start with the resistors. The color coding for these are as follows:
- 370kΩ = orange, violet, black, orange
- 3kΩ = orange, black, black, brown
- 10kΩ = brown, black, black, red
- 560Ω = green, blue, black, black
Then mount the capacitors. Mind the polarity of C1. When mounting the diodes, take care in getting the polarity correct. On the LED, the shorter leg is the cathode, closest to the flat edge of the casing. If you use the premade PCB, the LED cathode should face upwards.
On the 1N4001 diodes, there is a grey band near the cathode, corresponding to the marking on the PCB silkscreen-printing.
The voltage regulator and the transistors are mounted as indicated. Put the heat sink on the TIP120 before soldering it to the circuit board. Get the empty IC socket, the terminal blocks and the pin header with the jumper in place. Lastly, plug in the 4011 IC, and you’re done!
Testing the device
Connect the three sensor wires, strip off a few millimeter of insulation from the cable ends and dip them into a glass of water.
Connect the power leads. The LED should be off. Keep the common lead in the water throughout the test sequence.
- Pull both LOW and HIGH probes out of the water. The LED should turn on (pump starts).
- Put the LOW probe back into the water. This should not have any effect. The LED is still on.
- Put the HIGH probe into the water as well. Now, the LED should turn off (pump stops).
- Pull the HIGH probe out of the water again. This should not have any effect. The LED stays off.
- Pull the LOW probe out of the water. This should reactivate the LED (pump restarts).
One thought on “Watering pump controller”
Thank you for the article. Loved reading it.
The circuit board you have designed is awesome,