Tasmota Irrigation Controller Build With a NodeMCU and Relay Board

by taste_the_code in Circuits > Remote Control

124 Views, 1 Favorites, 0 Comments

Tasmota Irrigation Controller Build With a NodeMCU and Relay Board

DIY 3-Zone Smart Irrigation with Tasmota and a Washing Machine Valve

Three years ago I built a WiFi irrigation controller that opened a single washing machine valve to water my backyard drip system. It worked great until the garden grew and one zone could no longer deliver enough water pressure everywhere. In this project, I upgrade that controller to drive a three-way valve so three garden zones can be watered independently, and I switch the firmware to Tasmota so everything is controlled from a simple web interface. To follow along, you will need a handful of common parts, most of which can be salvaged, so let's look at the supplies first.

Supplies

  1. NodeMCU ESP8266 Board: https://s.click.aliexpress.com/e/_c4PZVB9L
  2. NodeMCU ESP32 Board: https://s.click.aliexpress.com/e/_c3J4jFs1
  3. 4-Channel Optically Isolated Relay Board: https://s.click.aliexpress.com/e/_c4S60ke1
  4. 3-Way Washing Machine Solenoid Valve: https://s.click.aliexpress.com/e/_c4oeAkA1
  5. NTC Thermistor Probe: https://s.click.aliexpress.com/e/_c2ulFNZF
  6. Cable Glands: https://s.click.aliexpress.com/e/_c3npQogd
  7. Previous Video (HC-SR04 Ultrasonic Sensor with Tasmota on NodeMCU): https://youtu.be/9simFNsFohA
  8. Tasmota Firmware: https://tasmota.github.io/docs/

How the System Works

MVI_3107.MP4.00_00_35_04.Still002.jpg
MVI_3108.MP4.00_00_09_18.Still001.jpg

The idea is simple. Water comes from a tap into the three-way valve, and each of the valve's three outputs feeds a separate drip hose covering one section of the garden. Each valve coil is switched by one relay on the relay board, and the relays are driven directly by three GPIO pins on the NodeMCU. Because the relay board is optically isolated and accepts 3.3V logic, the microcontroller can control it directly with no transistor circuit in between, which is exactly the part I had to hand-build in my original single-relay version. Running one zone at a time means the full water pressure goes to a single hose, which solves the problem of far or elevated zones not getting enough water.


A word of warning before you start: if you use a mains-powered valve like mine, you are working with voltage that can kill you. Only do this if you know exactly what you are doing, keep the mains side completely separated from the low voltage side, and never connect USB and mains at the same time. The 12V DC valve route avoids this risk entirely.

Prepare the Controller Board

MVI_3105.MP4.00_00_51_08.Still001.jpg
MVI_3121.MP4.00_01_39_02.Still001.jpg

If you are starting fresh, you can skip the teardown, but I began by gutting my old controller. I removed the old relay, the transistor switching circuit, and all the wires connected to them so I had a clean slate. I kept the NTC thermistor and the resistor that forms its voltage divider, since the temperature sensor still earns its place. The goal is a NodeMCU with nothing connected except the 5V supply input, the NTC on the analog pin, and free GPIO pins for the relay signals.

Wire the Signal Cable

MVI_3117.MP4.00_00_03_22.Still001.jpg
MVI_3119.MP4.00_00_15_17.Still001.jpg
MVI_3122.MP4.00_01_34_22.Still001.jpg
MVI_3124.MP4.00_01_47_13.Still001.jpg
MVI_3123.MP4.00_00_22_07.Still001.jpg
MVI_3125.MP4.00_00_08_01.Still001.jpg

The controller and the relay board live in two separate boxes, connected by a UTP network cable. UTP has eight wires, so five carry our connections and three remain spare for future expansion. I used the brown wire for 5V, white-brown for ground, and three more wires for the relay control signals. Drill holes in both boxes and fit cable glands so the cables are gripped firmly and protected.


On the controller side, solder the 5V wire to the board's VIN point, ground to any ground pin, and the three signal wires to pins D1, D2, and D6. The pin choice matters more than it looks. Many ESP8266 pins pull low during boot, which would briefly fire the relays every time the power comes on. D1, D2, and D6 stay safe through boot, so the valves only open when you tell them to.


On the relay board side, strip the other end of the cable and solder the wires to a female pin header so the whole connection just plugs onto the relay board's control pins, with VCC on one end and ground on the other.


Wire the Valve Side

MVI_3107.MP4.00_00_00_00.Still001.jpg

Connect the incoming supply for the valve to all the common terminals of relays one, two, and three. Each relay's switched output then goes to one coil of the three-way valve, reusing the original valve wiring if you salvaged it from a washing machine. Relay four stays unused and ready for a possible fourth zone. If your valve is mains powered, do this part with everything unplugged, double check every connection, and make sure no bare conductors are exposed once the box is closed.

Flash and Configure Tasmota

With nothing connected on the mains side, plug the NodeMCU into your computer over USB and flash Tasmota. Any standard Tasmota build for the ESP8266 works. Once it boots and you join it to your WiFi, open its web interface and go to the module configuration. Select the Generic module type, then assign D1, D2, and D6 as Relay 1, Relay 2, and Relay 3. Set them as inverted relays, because this type of board triggers when the signal goes low. If you added the NTC, set the analog pin A0 to ADC Temperature, then calibrate it for your specific thermistor following the Tasmota documentation.


After saving, the Tasmota main page shows three toggle buttons and the temperature reading. Each button controls one zone.

Test It

MVI_3126.MP4.00_00_14_22.Still001.jpg
MVI_3130.MP4.00_00_38_27.Still001.jpg
MVI_3129.MP4.00_00_28_22.Still002.jpg
MVI_3130.MP4.00_00_59_04.Still002.jpg

First test on the bench with no water connected. Toggle each relay from the Tasmota web page and listen for the click, and if you are using a mains valve, confirm each coil actuates. Then install the boxes somewhere dry and sheltered, connect the tap to the valve input and the three hoses to its outputs, and put the system under pressure. Toggling a zone in Tasmota should start water flowing through that zone's drippers immediately, and toggling it off should stop it. Mine had one surprise here: the original salvaged valve had a coil stuck shut from sitting in storage, so I had to swap in a different valve. If a zone does not open, check the valve before blaming the electronics.

Conclusion

MVI_3136.MP4.00_00_05_07.Still002.jpg
MVI_3127.MP4.00_00_29_27.Still001.jpg
MVI_3139.MP4.00_00_03_15.Still001.jpg

The result is a three-zone smart irrigation controller built largely from salvaged parts. Each garden section now gets watered independently with full pressure, the whole thing is controlled from any browser through Tasmota, and the spare fourth relay leaves room to grow. From here you could add timers and schedules with Tasmota rules, or integrate it into a home automation platform. If you build one, I would love to hear how it goes, and you can follow more projects like this on my Taste The Code YouTube channel.