TapTrace: A Minimal Water Leak Sensor with Local Web UI (ESP32-C3)
Why this project
Water finds gaps. Electronics find ways to complain loudly about it. TapTrace is a minimal, local-only water leak detector made for people who want quick, reliable alerts without cloud subscriptions, complex setups, or toner-intensive documentation. It uses an ESP32-C3, a simple capacitive probe, and a tiny web UI served from the device. Power it from USB or a small LiPo battery and drop it where leaks matter.
What you get
- A low-power leak detector that reports presence/absence of water via a tiny webpage.
- Optional push notification via local UDP or MQTT if you already run a broker.
- Clear wiring and firmware you can flash in 10–15 minutes.
Parts
- ESP32-C3-Dev module (or other ESP32 family with Wi‑Fi).
- Small capacitive sensor probe or two stainless screws on a little PCB (cheaper).
- 1M resistor for pull-down if using resistive probe; optional.
- Thin wires, small enclosure, USB cable or JST plug for LiPo.
Principle
Capacitive sensing detects the presence of water by measuring the change in capacitance between probe traces. It's more tolerant of dirt and corrosion than simple conductivity probes. We’ll use the ESP32-C3’s GPIO toggling and timing to implement a crude capacitive sensor: charge a pad and time how long it takes to discharge. Shorter time = more capacitance = likely water.
Wiring (very small)
- Cut two short copper traces on a small perfboard or use two stainless screws spaced 10–20 mm apart as the probe.
- Connect one probe pad to a GPIO capable of input/output (e.g., GPIO6 on some modules — check your board pinout). Call it PROBE_PIN.
- Connect the other pad to ground.
- Optional: add a 1M resistor between pad and ground to stabilize readings in dry conditions.
Firmware overview
The firmware does three simple things:
- Poll the probe at a short interval and compute a running average.
- Decide if a leak exists based on threshold and hysteresis.
- Serve a tiny web page on the local LAN showing status and a simple JSON endpoint for integration.
Use the Arduino core or ESP-IDF. The pseudo-logic below is intentionally portable.
loop:
charge probe (set pin output HIGH briefly)
set pin input
measure time to read LOW
map time -> capacitance value
update exponential moving average
if avg > wet_threshold then state = WET else DRY
serve web page and /status.json
sleep or delay
Tiny web UI
The web UI is a single HTML page served from the ESP. Keep it local-only: no remote endpoints, no telemetry. The page polls /status.json every 2–5 seconds and shows a big green/red badge plus a timestamp. Minimal CSS embedded in the page keeps footprint tiny (<8 KB).
Power considerations
- For mains/USB: no problem; update interval can be 1–2 seconds for snappy UI.
- For battery: use deep sleep between samples. Wake, sample, serve a short window (10–20 s) for local checks, then sleep. Expect weeks on a 2000 mAh LiPo at one sample per minute.
Thresholds and calibration
Every probe will read different absolute values. Implement a simple calibration flow: on first boot serve a page that allows setting DRY and WET baseline values. Alternatively, auto-calibrate by recording a minute of dry readings then saving a wet_offset. Hysteresis prevents rapid toggling when readings sit near the threshold.
Troubleshooting
- If the sensor is always wet: increase distance between pads, add a larger resistor to ground, or raise the wet threshold.
- If sensor never reads wet: check probe wiring, ensure probe pad is not insulated, and reduce threshold.
- Intermittent false positives near mains: add a small capacitor or move wiring away from AC lines.
Extensions
- MQTT integration for home automation; keep it optional and local-only.
- Add an LED or buzzer for local audible alarm with a mute button on the device.
- Chain multiple probes to the same ESP using a multiplexor or time-multiplex the readings if you want coverage under a long appliance.
Privacy and reliability notes
This project is intentionally local. No cloud, no account, no sneaky offsite telemetry. Use HTTPS on your local network if you must, but for most home deployments a tiny LAN-only HTTP server and a static IP or mDNS name is sufficient. Battery-backed devices should log state transitions to nonvolatile memory sparingly to survive power cycles.
Keep it simple: a reliable alarm you can trust is better than a flashy one you can’t.
TapTrace is a useful little project that rewards trimming complexity. You’ll learn a lot about sensing, embedded low-power habits, and minimal web interfaces — and you might prevent a ruined floor. If you want code, pinouts, or a LiPo enclosure suggestion, tell me your board and I’ll sketch a minimal repo you can flash in minutes.