An automatic plant watering system built on the ESP-01S (ESP8266) module. It monitors soil moisture via a water level sensor and drives a 5V pump through a relay. Everything is configurable through a built-in web interface — no need to re-flash for parameter changes.
- Automatic watering — triggers the pump when the sensor detects dry soil for a configurable duration
- Manual watering — one-click watering from the web UI
- Web interface — adjust parameters, view logs, and trigger watering from any device on the network
- Configurable parameters — inactivity cooldown, pump duration, sensor polling interval, counter threshold
- Persistent configuration — settings are saved to LittleFS and survive reboots
- Timestamped logging — watering events are logged with NTP-synced timestamps
- OTA firmware update — upload new firmware directly through the web UI
- mDNS support — access the device at
http://plantwatering.local
| Component | Example / Notes |
|---|---|
| ESP-01S module | ESP8266-based, 2 usable GPIOs |
| 5V Relay module | Single-channel, triggered on HIGH |
| Water level sensor | Wanma WMSR-CL-02 (or compatible) |
| 5V DC water pump | Small submersible pump |
| 5V power supply | Must power the ESP-01S, relay, sensor, and pump |
| ESP-01S adapter | 3.3V breadboard adapter or custom PCB |
| ESP-01S Pin | Connected To | Description |
|---|---|---|
GPIO 0 (IO0) |
Relay IN | Controls the relay (HIGH = pump ON) |
RX (GPIO 3) |
Sensor DATA | Reads water level (LOW = water present, HIGH = dry) |
VCC |
3.3V | Power supply for the ESP-01S |
GND |
GND | Common ground |
The relay acts as a switch in the pump's power circuit. The ESP-01S does not power the pump directly — the relay simply connects/disconnects the pump to the 5V supply.
5V Power Supply
┌──────┴──────┐
│ +5V GND │
│ │ │ │
└──┼───────┼──┘
│ │
┌───────┘ │
│ │
Relay COM │
│ │
Relay NO │
│ │
Pump (+) ──── Pump (−)
- Relay COM → 5V power supply positive (+)
- Relay NO (Normally Open) → Pump positive (+) terminal
- Pump negative (−) → Power supply GND
- When
GPIO 0goes HIGH, the relay closes and the pump runs
Note: The relay module itself is powered from 5V (VCC/GND). The ESP-01S only drives the relay's signal/IN pin through
GPIO 0.
- VCC → 5V power supply
- GND → Common GND
- DATA/OUT → ESP-01S
RX(GPIO 3) - Outputs LOW when water is present, HIGH when dry
Open Arduino IDE and install the following libraries via Library Manager:
ESP8266WiFi(included with ESP8266 board package)ESP8266WebServer(included with ESP8266 board package)ESP8266mDNS(included with ESP8266 board package)NTPClientby Fabrice WeinbergTimeLib(Time library by Paul Stoffregen)LittleFS(included with ESP8266 board package)
Make sure you have the ESP8266 board package installed:
File → Preferences → Additional Board Manager URLs → add:
https://arduino.esp8266.com/stable/package_esp8266com_index.json
Then install esp8266 from Tools → Board → Board Manager.
Edit arduino_secrets.h and fill in your network credentials:
#define STASSID "your_ssid"
#define STAPSK "your_password"- Select Generic ESP8266 Module in Tools → Board
- Set Flash Size to match your ESP-01S (usually 1MB with LittleFS)
- Connect your ESP-01S via a USB programmer
- Upload the sketch
Once connected to WiFi, open your browser and navigate to:
http://plantwatering.local
Or use the IP address printed to the Serial Monitor (9600 baud).
The web UI provides:
- Parameter adjustment — set inactivity cooldown (hours), main loop delay (seconds), pump duration (seconds), and counter time range (seconds)
- Manual watering — trigger an immediate watering cycle
- Log viewer — view timestamped watering event history
- Log cleanup — clear the log file
- OTA update — upload a new
.binfirmware file
| Parameter | Default | Unit | Description |
|---|---|---|---|
inactivityDuration |
1 | hours | Cooldown period between watering cycles |
mainLoopDelayDuration |
1 | seconds | Delay between sensor readings |
pumpingDuration |
1.5 | seconds | How long the pump runs per cycle |
counterTimeRange |
5 | seconds | Time window for consecutive dry readings before triggering |
Parameters can be changed at runtime through the web UI and are persisted to flash storage.
This project is licensed under the MIT License.