RD-01

Leak sentinel

An ESP32 that watches a water sensor on the floor, sounds a buzzer and publishes an MQTT alert when water appears under a tank, pump or washing machine.

Draft. Wiring and firmware outline written. Bench validation pending.

Where it fits

  • Water tanks and pump rooms
  • Under washing machines and water heaters
  • Server and electrical rooms

Power: A 5 V USB adapter. The node stays awake, so it is not a battery design.

Parts list

PartQtyRole
ESP32 DEVKIT V11Controller and Wi-Fi
Water Sensor1Detects water on the floor
Active Buzzer1Local alarm
2N2222 NPN Transistor1Drives the buzzer
Resistor, 1 kΩ1Transistor base
Relay Module 2 Channel 5VOptional1Switches a valve or pump
Breadboard 400 Point1Bench assembly

Wiring

SignalConnect toWhy
Water sensor S (analog out)GPIO34ADC1 channel 6, which keeps working while Wi-Fi is on.
Water sensor +GPIO25Powered only while reading, to slow corrosion of the traces.
Water sensor −GND
Buzzer +5 V (VIN)
Buzzer −2N2222 collector; emitter to GND, base to GPIO26 through 1 kΩThe buzzer draws more than a GPIO should supply, so the transistor switches it.
Relay IN1 (optional)GPIO27Check that your module switches reliably from 3.3 V logic.

Firmware outline

Written for ESP-IDF. The same steps work in Arduino with the matching calls.

  1. Configure ADC1 channel 6 in one-shot mode with 12 dB attenuation and a calibration scheme.
  2. Every 2 s, drive GPIO25 high, wait 10 ms, average 8 samples, then drive it low again.
  3. Treat three wet readings in a row as a leak: sound the buzzer and publish to site/<name>/leak with QoS 1 and the retained flag set.
  4. Publish a heartbeat every 5 minutes so a dead node is noticed, not mistaken for a dry floor.
  5. Keep the wet threshold in NVS so it can be tuned without reflashing.

Design notes

Why GPIO34
On the ESP32, ADC2 cannot be read while Wi-Fi is running. Every analog input on this board goes on an ADC1 pin, GPIO32 to GPIO39.
Why switch the sensor's power
The sensor's exposed traces corrode quickly with DC on them all the time. Powering it only for a 10 ms reading every 2 s keeps it working far longer.
Why three readings
A single splash should not trigger an alarm. Three wet readings 2 s apart filter that out and still react within seconds.
Why a retained message
A dashboard or phone that connects later still sees the last leak state instead of waiting for the next change.

Limits

  • It detects water where the sensor sits. It will not find a slow leak inside a wall.
  • It is not a certified safety device.