About three years ago, I built a DIY irrigation controller for my backyard. It was hooked into my drip irrigation hose and controlled a single electronic valve salvaged from a washing machine. The whole thing ran on ESPHome as part of my Home Assistant setup, and honestly, it worked flawlessly the entire time. It still works exactly as designed today.
So why touch it? Because my garden grew.
I added more hose and split the system into three separate zones, and the old single-valve setup simply could not keep up. In this project, I am upgrading the controller to drive a three-way valve so each zone can be watered independently. Along the way, I am also switching the firmware from ESPHome to Tasmota, since I am moving away from Home Assistant to my own platform that I covered in a previous video.
This video is sponsored by Altium Develop. Get your free trial here.
Why One Zone Was Not Enough
The main issue with the single-zone setup was water pressure. As the drip hose got longer and longer, there was simply not enough pressure to feed the zones that sit higher up in the garden. This had nothing to do with the controller itself. The electronics were running perfectly. It was purely a plumbing problem.
The fix was to take a three-way valve from a used washing machine and split all the hoses into three distinct zones. Instead of one relay opening one valve, the upgraded controller uses three relays, one per zone. That way I can program each zone to run independently for the time it needs, and water actually reaches everywhere it is supposed to.
The New Relay Board
To control the three valves, I prepared a four-channel relay board. It is similar to the relay I used in the original build, but this one is optically isolated and can be controlled directly from 3.3 volt logic. The board itself is powered from 5 volts because it uses 5 volt relays, but on the output side it switches the 220 volts that the electronic valve needs.
This is the point where I have to be very clear about safety. If you want to replicate this project, please be extra careful and only attempt it if you know exactly what you are doing. You will be dealing with mains voltage, and that voltage can kill you. If you would rather avoid mains entirely, there are valves that work on 12 volts DC. You can build the exact same system around one of those and stay on the safe side.
For the wiring, the incoming mains live wire connects to all of the common terminals on the relay board, and I am reusing the same wires that came with the washing machine valve. Relays one, two, and three each control one of the valve coils. Relay four stays unused for now, but it leaves the door open for a fourth zone later.
Tearing Down the Old Controller
The first step of the actual build was taking the original controller out of its box and removing the old single relay. The plan was to replace it with a cable that connects the controller box to the new relay box. I could have used one larger enclosure for everything, but keeping them as two separate boxes works fine, and both of them live mounted under the sink I have in the backyard. That spot has kept the original box dry for three years. It gathered some dust, but it was never exposed to moisture because it is well sheltered under the sink.
The original build used a relay that was not isolated, so back then I had to add a transistor switch to control the 5 volt relay from the 3.3 volt output of the NodeMCU. The new board is optically isolated, so none of that is needed anymore. The microcontroller pins can drive it directly.
I started by removing the old wires, and since one of them was soldered before I had crimped the ends, I just cut it. It was getting replaced anyway. Then I desoldered the relay itself. In the end, I decided the cleanest approach was to strip the board of all the old switching components entirely, so I had a clean slate and knew exactly what was connected where.
One thing I did keep was the NTC thermistor that measures the outside temperature, along with the resistor underneath the board that forms the voltage divider for it. That sensor has been useful, so it stays in the build.
Wiring the Signal Cable
With the board cleaned up, the controller box needed to send out five connections to the relay box: 5 volts, ground, and three control signals. For this, I went with a regular UTP networking cable. It has eight wires inside, so three of them stay unused for now, which is fine. Spare conductors might come in handy in the future.
I drilled two holes in the box and fitted cable glands, one for the mains cable feeding the power module and one for the signal cable. On the cable itself, I used the brown wire for the 5 volt supply, white-brown for ground, and three more wires for the relay control signals. The 5 volt wire gets soldered to the same point where VIN used to connect, coming in from the 5 volt power supply the controller has always run on, and ground goes to any of the ground pins on the NodeMCU.
Choosing the Right Pins
For the relay control pins, I picked D1, D2, and D6 on the NodeMCU. This choice matters. Many of the other pins on the ESP8266 go low during boot depending on the conditions, which would briefly trigger the relays every time the controller powers up. D1, D2, and D6 behave safely. The green wire went to D1, the blue wire to D2, which was conveniently the same pin that controlled the old relay, and the last wire to D6.
After that, everything got packed back into the case with a small piece of electrical tape holding things in place. The old front panel had two holes where I previously exposed the relay LEDs as power and activity indicators, but they were never really useful, so I left them out and covered the holes with a sticker for now. On the relay box side, I stripped the other end of the cable and soldered the wires to a female header, so the whole thing just plugs onto the relay board pins, with VCC on the far left and ground on the far right.
Finally, I added the mains cable as the incoming supply and tightened the glands so they grip the cables properly.
Installing and Configuring Tasmota
With the hardware done, the NodeMCU needed new firmware that knows about the new pins. Since I am moving away from Home Assistant to my own platform, I flashed Tasmota onto the module. One important note here: I made sure nothing was plugged into the mains side before connecting the USB cable for flashing. Never have both connected at once.
I did the flashing itself off camera, but it was fairly simple. I am using a custom Tasmota build that I slightly modified for my own purposes, but that is irrelevant for this project. Any standard Tasmota build for your microcontroller will work just the same.
Inside the Tasmota configuration, I chose the Generic module type and assigned D1, D2, and D6 as the three relays. I set them as inverted relays because this board triggers when the signal goes low. On the analog pin A0, I configured ADC temperature for the NTC probe. Depending on your exact thermistor, you will need to calibrate the sensor for the specific part you have, and that process is well explained in the Tasmota documentation.
Once configured, the Tasmota web interface showed the three relays along with the temperature reading from the NTC. Toggling any of the relays from the interface switched them on and off immediately, which is exactly what I wanted.
Installing It in the Backyard
The final step was packing everything up, installing it under the tap in the backyard, and connecting the valves to the actual hoses. The two electrical boxes are wired in under the sink, with power coming in from the wall and the tap feeding water through the hose to the valves.
I did run into one hardware problem here. The original washing machine valve I planned to use had a stuck coil. One of the three sections would not open, most likely from sitting in storage for a long time, so I had to swap it for a different valve. With the new one in place and the system under pressure, everything worked.
Testing It Out
The garden is now split into three hoses coming off the valve, each feeding its own section of the yard. From the Tasmota web page, I can trigger any of the three valves, and the water starts flowing in that zone immediately. Toggle it off, and the drippers stop. Each zone runs independently, and because only one zone runs at a time, there is finally enough pressure to reach every part of the garden.
Conclusion
With that, the irrigation system upgrade is complete. The same NodeMCU that ran one valve for three years now controls three independent watering zones through an optically isolated relay board, runs Tasmota instead of ESPHome, and still reports the outside temperature through the NTC sensor. The pressure problem is solved, and there is even a spare relay waiting if I ever add a fourth zone.
If you enjoyed this build, head over to my Taste The Code YouTube channel and subscribe so you do not miss the next project.
Links and Resources
- NodeMCU ESP8266 Board: https://s.click.aliexpress.com/e/_c4PZVB9L
- NodeMCU ESP32 Board: https://s.click.aliexpress.com/e/_c3J4jFs1
- 4-Channel Optically Isolated Relay Board: https://s.click.aliexpress.com/e/_c4S60ke1
- 3-Way Washing Machine Solenoid Valve: https://s.click.aliexpress.com/e/_c4oeAkA1
- NTC Thermistor Probe: https://s.click.aliexpress.com/e/_c2ulFNZF
- Cable Glands: https://s.click.aliexpress.com/e/_c3npQogd
- Previous Video (HC-SR04 Ultrasonic Sensor with Tasmota on NodeMCU): https://youtu.be/9simFNsFohA
- Tasmota Firmware: https://tasmota.github.io/docs/