The ESP32-based system uses timed watering pulses and sensor monitoring to prevent pump damage when faults occur.

Barcelona-based freelance developer Artur Puig developed an ESP32-based automatic plant watering controller that uses multiple safety checks to prevent pump damage when sensors fail, water runs out or the control system stops responding. The project uses a capacitive soil moisture sensor to control a low-voltage pump or solenoid valve. Instead of running the pump continuously until the soil reaches a target moisture level, it delivers short watering pulses and checks the sensor response between them.
The controller starts watering when soil moisture falls to 35 per cent. It runs the pump for five seconds, waits ten minutes for the water to spread through the soil and checks the reading again. This process can repeat up to four times, stopping when moisture reaches 45 per cent. In a simulated pot test, continuous watering took 55 seconds and raised moisture to 78 per cent, while three separate pulses used 15 seconds of pumping and reached 46 per cent. The design supports ESP32-C3 and ESP32-C6 development boards, with the sensor connected to GPIO3 and the MOSFET pump-control circuit connected to GPIO10.
The firmware takes 16 sensor samples in each reading burst, uses their median and rejects values outside a plausible range or with excessive variation. Invalid readings cannot trigger the pump. If the sensor remains invalid for more than ten seconds, the controller records a fault. It also detects a lack of moisture increase after a complete watering cycle, which could indicate an empty reservoir or a pump that is not delivering water. A default daily pump-time budget of 120 seconds provides another limit. Fault states and pump usage are stored in non-volatile memory, preventing a reboot from simply resetting the accumulated usage.
Pump control has additional safeguards. A one-shot timer is armed before the pump output is switched on, so it can end a watering pulse if the control task hangs. The task watchdog can reset the ESP32 if the software stops responding, while a watchdog routine drives the pump output low. A pull-down resistor keeps the MOSFET switched off before the firmware starts, and a fuse protects the pump supply line. The hardware setup also includes an N-channel MOSFET, a 1N5819 flyback diode and a separate power supply for the pump. The developer recommends testing the system with the pump outlet directed into a bucket before connecting it to a plant.
The firmware is available on GitHub under the MIT licence and uses ESP-IDF v6.1 rather than the Arduino framework. Puig reports 12 scenario tests covering sensor faults, empty reservoirs, leaking pots and fault persistence across reboots. A further test suite runs 300 simulated three-day scenarios, while another checks whether removing or weakening 13 safety mechanisms causes a test failure.
For more information, click here.



