Controlling the Solenoids
Electrically, the solenoid valves used in the watering system are fairly simple: The valve is normally closed, and no water flows. When power is applied to the solenoid, it opens the valve. The valve stays open as long as the solenoid is held on by the electrical current, and is then closed by the water pressure when the electrical current stops. The solenoids typically run at 24 volts AC, or 12 volts DC. Each solenoid draws about 500mA current at 12VDC when switched on. This means that to turn the water on and off electronically, you need a way to switch 24VAC/12VDC at up to 500mA.
I’m using an old PC Parallel port relay board which has 8 relays rated up to 240VAC. I’ve modified the board to connect easily to an Arduino nano. Pull-down resistors keep the relays switched off when nothing is connected – this avoids the relays switching on and off rapidly when disconnecting or connecting wires, and when the Arduino nano is switched off. The relays themselves are controlled by a transistor array.
I was using a single 12v 1A power supply at first, but the Arduino would become unresponsive after switching a solenoid on, so now I’m using one 12V supply for the relays and Arduino (regulated using VIN), and another 12v supply to power the solenoids. What I realize now, six months after building the controller, is that the solenoids probably induce a large back-EMF, enough to upset the low voltage electronics. I assumed they didn’t need EMF-suppression diodes because they are switched by relays, but they do. Powering two solenoids and two relays also used slightly more than the 1A rating of the 12V power supply.
Building a prototype controller
When I was using a Raspberry Pi connected directly to the relay board, I used the following connections:
|Relay board||Raspberry Pi|
|Output Enable||3 – GPIO 2|
|Latch Enable||12 – GPIO 18|
|1||26 – GPIO 7|
|2||5 – GPIO 3|
|3||11 – GPIO 17|
|4||13 – GPIO 27|
|5||15 – GPIO 22|
|Gnd||6 – Gnd|
Connections using the Arduino nano are:
|nrf24 Module pin||Raspberry Pi pin|
|1 – Gnd||25 – Gnd|
|2 – Vcc||17 – 3v3|
|3 – CE||22 – GPIO25|
|4 – CSN||24 – GPIO 8/CE0|
|5 – SCLK||23 – GPIO 11/SCLK|
|6 – MOSI||19 – GPIO 10/MOSI|
|7 – MISO||21 – GPIO 9/MISO|
There are a few improvements I want to make to the controller in future:
1. A much smaller case.
2. Using transistors instead of relays
3. Solar powered
4. I might go back to an all in one WiFi box, rather than having the separate Raspberry Pi.
Stay tuned for part 5, the software component of the system.