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
| Part | Qty | Role |
|---|---|---|
| ESP32 DEVKIT V1 | 1 | Controller and Wi-Fi |
| Water Sensor | 1 | Detects water on the floor |
| Active Buzzer | 1 | Local alarm |
| 2N2222 NPN Transistor | 1 | Drives the buzzer |
| Resistor, 1 kΩ | 1 | Transistor base |
| Relay Module 2 Channel 5VOptional | 1 | Switches a valve or pump |
| Breadboard 400 Point | 1 | Bench assembly |
Wiring
| Signal | Connect to | Why |
|---|---|---|
| Water sensor S (analog out) | GPIO34 | ADC1 channel 6, which keeps working while Wi-Fi is on. |
| Water sensor + | GPIO25 | Powered 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) | GPIO27 | Check 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.
- Configure ADC1 channel 6 in one-shot mode with 12 dB attenuation and a calibration scheme.
- Every 2 s, drive GPIO25 high, wait 10 ms, average 8 samples, then drive it low again.
- 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.
- Publish a heartbeat every 5 minutes so a dead node is noticed, not mistaken for a dry floor.
- 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.
