
I know this project has been made like 3 billion times before, but it's my first and I'm excited to share and need your feedback 😁
I built a self-hosted soil moisture monitor with automated irrigation on an ESP32
Been working on this for a while and finally got it to a state I'm happy with. It's a fully self-contained smart irrigation system that runs on an ESP32 with no cloud, just a browser on your local network.
Components
- ESP32 WROOM-32 (4 MB flash)
- Capacitive soil moisture sensor (analog output on GPIO 34)
- 5V relay module (GPIO 26)
- Submersible mini pump
- 3.7V li-ion battery
What it does
The ESP32 reads the soil moisture every 60 seconds (adjustable), saves the readings to its internal flash storage, and automatically runs the pump when moisture drops below a configurable threshold.
The automation cycle works like this:
- Moisture drops below threshold → pump runs for a set duration
- Soak period — waits for water to absorb before re-checking
- Cooldown — prevents rapid re-cycling
- Re-evaluate and repeat if still dry
All timings and thresholds are adjustable live from the dashboard.
The dashboard
Accessible from any browser on the local network. No app needed.
- Overview tab — live moisture gauge + 48-hour history chart with date/time labels
- Pump tab — real-time pump status (ON / OFF / SOAKING / COOLDOWN) with progress bars, manual ON/OFF controls, auto mode toggle, and last run timestamp
- Settings tab — adjust low threshold, run duration, soak time, cooldown, and sample interval — all saved to flash and survive reboots
- Logs tab — live serial monitor pushed over WebSocket so you can watch the device in real time
The whole UI updates in real time via WebSocket — no polling.
Other features
- Supports 2 Wi-Fi networks with automatic fallback
- Over-the-air firmware updates — both via the web UI and Arduino IDE
- HTTP Basic Auth on all endpoints + token-based WebSocket auth
- Watchdog timer to recover from hangs
- Offline buffering — saves readings locally if Wi-Fi drops and flushes them when reconnected
Source code on GitHub: https://github.com/Basselfathy/esp32-soil-monitor-system