Search for an "ESPHome water leak detector" build and you'll find three completely different projects wearing the same name: someone taping two screws to the floor under a sink, someone splicing a flow meter into their main water line, and someone bolting a motorized valve onto the pipe so the house shuts itself off. Almost nobody tells you which one your house actually needs — so people buy parts for the build that flashed past first, then discover it doesn't cover their actual leak.
This guide picks between the three approaches before you buy anything. Each one is a real, documented ESPHome build with a parts list, a config you can flash today, and — just as important — the honest list of leaks it will never catch. All three talk to Home Assistant, all three are local (no cloud account, no subscription), and they stack: many houses end up with two of them.
Which build fits your house?
Answer these in order — the first one that matches is your path:
| # | Question | If that's you → |
|---|---|---|
| 1 | Do you rent, or can't touch the plumbing? | Path A — contact probes. No pipe work, runs off USB, comes back off the floor with you. |
| 2 | Do you need the water to physically stop while you're away (vacations, second home, burst-hose fear)? | Path C — shutoff valve. A and B only notify; a human still has to turn a handle. |
| 3 | Is your main line accessible — and are you (or a plumber you'll pay) willing to cut pipe? | If no: Path A (plus the AquaPing comparator below for behind-wall leaks). |
| 4 | Is your goal whole-house silent leak detection — a running toilet, a tap left on, a hidden drip? | Path B — flow sensor on the main (ideally B + C so detection can act). |
| 5 | Not sure, smallest first step? | Path A. Cheapest, least commitment, one afternoon. |

Two sentences of honesty before the parts lists, because this is where most guides oversell:
Probes only catch water that reaches them. A leak inside a wall, under flooring, or three feet from the probe is invisible to Path A.
Flow sensors have a floor. The brass sensor in Path B doesn't register anything below 2 L/min — a slow drip never shows up. Flow is whole-house coarse detection; probes are point detection. That's why the paths stack rather than compete.
If you're new to ESPHome itself, our ESPHome voice assistant guide walks the toolchain end to end, and our ranked ESPHome projects are all beginner-scaled.
Path A — contact probes (does water touch this spot?)
What it is
Two bare conductors on the floor where leaks pool — stainless screws, a commercial 2-wire probe, or runs of conductive tape. Dry, the gap is high impedance and the GPIO pin reads high; wet, the water bridges the probes, resistance drops, and the pin reads low. ESPHome exposes it as a binary_sensor with device_class: moisture, which means Home Assistant's built-in leak handling and automations recognize it instantly.
This is the common denominator of the whole field. The popular esphome.io cookbook builds a capacitive variant on the ESP32's touch pins (no DC across the probes, so far less electrode corrosion — but it needs an ESP32, per-install threshold calibration, and its M5StickC PLUS2 host board is end-of-life at M5Stack, so we don't recommend building that route today). The resistive GPIO build below works on any ESP32 or ESP8266 board and is what we'd start with.
When it fits
You rent, you can't (or won't) touch plumbing, you want the cheapest first step, or you want to blanket the known danger spots: under the water heater, behind the washing machine (a burst supply hose is the number-one home flood cause), under the kitchen sink, behind toilets, and the sump pit. Five probes cover a typical three-bedroom home in the valve-build author's experience — "Five probes cover a typical 3-bedroom home."
Parts (per detector point; prices checked 2026-11-29)
| Part | Qty | Approx price | Price basis |
|---|---|---|---|
| ESP32 DevKitC-style board (generic) | 1 | ~$5 | builder's BOM (Botmonster) |
| Resistive leak probe, 2-wire (stainless electrodes or commercial 2-wire cable probe) | 1 per spot | ~$3 each (bare electrodes) | builder's BOM (Botmonster) |
| 10 kΩ resistor (external pull-up) | 1 | <$1 | maker's parts list (garrettheath4) |
| 1N4001 diode (only if 2+ probes share one board) | 1 per extra probe | <$1 | maker's parts list (garrettheath4) |
| USB wall charger + USB data cable | 1 | ~$8 | maker's parts list (garrettheath4) |
| Optional: 4 mm conductive fabric tape for perimeter runs | ~2× wall length | ~$10/roll | maker's parts list (garrettheath4) |
| Optional: DC buzzer | 1 | ~$2 | maker's parts list (garrettheath4) |
Sub-total: ~$15–20 for one point, ~$3 per additional probe on the same board. One board can watch several spots: each probe needs its own GPIO and its own 1N4001 diode so a wet probe can't back-feed the others.
Wiring
One probe terminal to GND, the other to the GPIO — no polarity.
Enable the internal pull-up and add the external 10 kΩ. garrettheath4 tested this: the board's programmable internal pull-ups "seem to be insufficient for this use case based on my testing" — the ESP32/ESP8266's internal pull-ups are weak (~30–45 kΩ), and the external resistor gives a solid high and a predictable wet/dry swing.
Debounce in config, not hardware:
delayed_onrejects mop-water splashes,delayed_offholds the alarm a few seconds after the probe dries.For perimeter coverage, run two parallel strips of the conductive tape along a wall/floor edge instead of point probes.
ESPHome config (one probe)
esphome:
name: leak-detector-kitchen
esp32:
board: esp32dev
wifi: { ssid: !secret wifi_ssid, password: !secret wifi_password }
api:
ota: { platform: esphome }
binary_sensor:
- platform: gpio
name: "Kitchen Sink Leak"
device_class: moisture
pin:
number: GPIO4
inverted: true
mode:
input: true
pullup: true # plus external 10k to 3.3V
filters:
- delayed_on: 1000ms # reject splashes
- delayed_off: 10000ms
Home Assistant side
The moisture binary_sensor auto-appears in HA's leak dashboards. Add a device-trigger automation on type: moist → notify for the simple version, or the esphome.io cookbook's alert: + Pushover group for a nagging alert that re-fires every 30 minutes until someone acknowledges it.
Pitfalls (the honest list)
Probes corrode. DC across wet electrodes is electrolysis; expect oxidation, and in damp spots a 6–12 month service life per probe — buy spares and inspect quarterly. (The capacitive touch variant mostly avoids this; that's its real advantage.)
Point coverage only. Water has to reach the probe. A wall cavity or under-floor leak elsewhere is invisible.
Detection, not mitigation. Water keeps running until a human acts. Wi-Fi, Home Assistant and your phone are all in the alert chain.
Pure/deionized water barely conducts — an RO drain or aquarium spill can fool a resistive probe. Capacitive probes ($8–15) cover those spots, at the cost of calibration against room humidity.
A probe that goes wet and stays wet reads on indefinitely — schedule a periodic dry-off test so you notice a probe that never dries.
Path B — flow sensor on the main (is water moving when it shouldn't be?)
What it is
A hall-effect turbine sensor spliced into the main supply line emits pulses proportional to flow; ESPHome turns pulse timing into liters per minute, and Home Assistant watches for water moving at the wrong times — nobody home, every tap off, 3 AM. This is the only DIY path that catches hidden, continuous leaks: mrahmadt's build (the reference for this path) says it "complements traditional floor-based water sensors" by "detecting hidden leaks like toilet tank leaks, faulty taps, or pipe issues."
When it fits
You own, your main line is accessible, and you want whole-house coverage instead of five lucky floor spots. Note the trade up front, from the same builder: "This solution requires some plumbing work. Alternative solutions, such as ultrasonic sensors, were either unreliable or costly in my testing." You (or a plumber) will shut the main, cut pipe, and fit the sensor — flanked by shut-off valves so you can service it later without killing the house water.
Sensor choice matters more than the board. The plastic YF-S201 (1/2″, ~$5) suits a branch line like a water-heater inlet; the SERP-proven main-line part is the brass/steel YF-B10-S (G1″), which costs more but survives main-line pressure. Match the fitting to the pipe — a community build logs the classic mistake: a DN40 meter bought for a DN25 line and an afternoon lost to adapter hunting.
| Sensor | Approx price (checked 2026-11-29) | Size | Range | Pulses/L | Rating |
|---|---|---|---|---|---|
| YF-S201 | ~$5 | 1/2″ | 1–30 L/min | 450 | plastic, cheap |
| YF-B10-S | ~$10–25 | G1″ (DN25) | 2–50 L/min | 476 | brass/SS304, 17.5 bar, 3.5–24 V |
Parts (prices checked 2026-11-29)
| Part | Qty | Approx price | Price basis |
|---|---|---|---|
| ESP32 DevKitC-style board | 1 | ~$5 | builder's BOM (Botmonster) |
| YF-B10-S flow sensor, G1″ (or YF-S201 1/2″ for a branch) | 1 | ~$10–25 | mrahmadt build + Tinytronics listing |
| Thread adapters + couplers to your pipe (PEX/copper/PE) | 2–4 | ~$5–15 | both builds' BOMs |
| 1 kΩ + 2 kΩ divider resistors (hall output swings to the 5 V rail; ESP32 pins are not 5 V-tolerant) | 1 set | <$1 | hardwarematrix wiring guide |
| 5 V USB supply (sensor power) + enclosure (IP65 if plant room/pit) | 1 | ~$10 | hardwarematrix wiring guide |
| Shut-off valves flanking the sensor (so you can service it without killing the house water) | 2 | ~$10 | standard plumbing practice (Botmonster install notes) |
Sub-total: ~$30–60 depending on valve and fitting count, plus a plumber if you don't solder or crimp.
Wiring
Red → 5 V, Black → GND, Yellow (signal) → GPIO through a 1 k/2 k divider — the hall output swings to the 5 V rail and ESP32 GPIOs are not 5 V-tolerant. (The YF-B10 can run 3.5–24 V; at 5 V the same divider applies.)
Any pulse-capable GPIO, input + internal pull-up.
Where it splices: after the main shut-off valve, before the manifold/branch split, so every fixture passes through it. Roof-tank/gravity feeds: at the tank outlet.
ESPHome config
esphome:
name: water-flow-main
esp32:
board: esp32dev
wifi: { ssid: !secret wifi_ssid, password: !secret wifi_password }
api:
ota: { platform: esphome }
sensor:
- platform: pulse_meter
pin:
number: GPIO27
mode: { input: true, pullup: true }
name: "Main Water Flow"
unit_of_measurement: "L/min"
device_class: water
state_class: measurement
timeout: 10s # default is 5 min — wrong for a tap; drops to 0 after 10 s dry
filters:
- lambda: return x / 476.0; # YF-B10: 476 pulses/L; YF-S201: 450
total:
name: "Main Water Total"
unit_of_measurement: "L"
filters:
- lambda: return x / 476.0; # keep k-factor consistent with the rate sensor
Three details that bite people: pulse_meter beats pulse_counter here because it times gaps between pulses — exactly the low-flow regime leak detection lives in (the two can't share one pin); the timeout default of 5 minutes means a tap left running reads as zero for five minutes, so it's cut to 10 s; and the pulses-per-liter constant must match your sensor (YF-B10 = 476, YF-S201 = 450) and must be the same in the rate and total filters.
Home Assistant side — this is where the detection actually lives
The sensor just reports flow; your automations decide what's wrong:
The 30-minute rule: water running continuously for ~30 minutes while presence says nobody's home → assume leak, alert (and close the valve, if you built Path C).
Allowlist normal long flows — morning irrigation, long showers, pool fills — so the rule doesn't false-alarm. A 15–30 minute grace window absorbs a sprinkler cycle.
mrahmadt's repo ships the HA automation YAML for exactly this: flags taps left running and slow toilet-tank leaks by watching flow when everything should be off.
Pitfalls (the honest list)
It misses small drips by design. The YF-B10's range starts at 2 L/min; a two-drops-per-second leak is far below that floor and community builders report it never shows on the meter. Treat flow as coarse whole-house detection and probes as point detection — they complement, not replace.
Accuracy is not billing-grade. YF-S201 readings swing by more than 10% with pressure, mounting angle and flow rate, and users report units that stopped pulsing after a few weeks; the YF-B10 is ±3–5%. If you need real totals, pay for a paddle-wheel or turbine meter.
A dead turbine reads as zero flow — which looks like no leak. Pulses just stop. Alert on total-pulse staleness, or compare against your utility meter periodically.
Detection, not mitigation — same as Path A: it tells you, it doesn't stop anything.
Path C — automatic shutoff valve (detect and stop)
What it is
Path A's probes plus a 3-wire motorized ball valve on the main line and a two-channel relay board. When a probe goes wet, the ESP32 itself closes the valve — on-device, with no Home Assistant, Wi-Fi or cloud in the safety loop. This is the Botmonster build's pitch: local smart leak detection that shuts your main water within seconds of a puddle, with "no cloud account, no $5/month fee, and no vendor lock-in."
Why a motorized ball valve and not a solenoid: a solenoid draws current the entire time it's open and can "run hot enough to cook themselves" — a couple of years of life. A motorized ball valve draws power only during its 3–5 second travel and then nothing; the builder's estimate is that it "should last a decade." The 3-wire scheme (common / open / close) is the failsafe: power one direction or the other to move the valve, and cut power and it stays put — zero draw at rest, position held through outages.
When it fits
You own, you can cut the main, and the point is mitigation: vacation mode, a second home, or simply not wanting a burst washing-machine hose to run for six hours while you're at work. Sweet spot per the source build: a U.S. Solid or HSH-Flo 3-wire brass ball valve, 9–24 V DC, sized to the main (3/4″ is typical for a single-family house).
Parts (3 probe zones; prices checked 2026-11-29)
| Part | Qty | Approx price | Price basis |
|---|---|---|---|
| ESP32 DevKitC board | 1 | ~$5 | builder's BOM (Botmonster) |
| Resistive leak probes (stainless electrodes) | 3–5 | ~$3 each | builder's BOM (Botmonster) |
| 3-wire motorized ball valve, brass, 9–24 V DC (U.S. Solid 3/4″) | 1 | $30–50 | builder's BOM (Botmonster) |
| 2-channel relay module, 5 V, opto-isolated | 1 | ~$4 | builder's BOM (Botmonster) |
| 12 V DC power supply, 1 A | 1 | ~$6 | builder's BOM (Botmonster) |
| Jumpers, project box, pull-up resistors | — | ~$5 | builder's BOM (Botmonster) |
| Optional: USB power bank with passthrough (keeps ESP32 alive in outages) | 1 | ~$20 | builder's BOM (Botmonster) |
| Optional: plumber to fit the valve | 1 | $150–250 | builder's estimate (Botmonster) |
Sub-total: ~$60–90 DIY (the valve dominates) + $150–250 if a plumber fits it.
Wiring
The valve's three wires go to the two relay channels (open, close) switching the 12 V feed. The
interlockin the config below is mandatory — both relays firing at once on a 3-wire valve stalls the motor or blows a fuse.Each relay auto-offs after ~6 s, matching the valve's travel time; the valve then holds position unpowered.
Want closed-on-power-loss (default is hold-last-position)? Wire the 12 V feed through a normally-open relay driven by a mains-sensing input, so an outage commands CLOSED. With the ESP32 on a passthrough power bank, the build rides out 6–12 h outages.
The $25 Tuya-valve-reflash route works too, but most Tuya valves have no real position sensor — firmware guesses state from the last command, and a power blip can open a valve that should stay shut. Configure restore-on-boot carefully if you go there.
ESPHome config (3 zones + valve; one probe shown)
esphome:
name: water-guardian
esp32:
board: esp32dev
wifi: { ssid: !secret wifi_ssid, password: !secret wifi_password }
api:
ota: { platform: esphome }
binary_sensor:
- platform: gpio
name: "Water Heater Leak"
pin:
number: GPIO32
mode: { input: true, pullup: true }
inverted: true
device_class: moisture
filters:
- delayed_on: 300ms
- delayed_off: 10s
on_press: # ON-DEVICE failsafe: no HA/network needed
then:
- switch.turn_on: valve_close
# (repeat per zone on GPIO33, GPIO25...)
switch:
- platform: gpio
id: valve_open
name: "Valve Open"
pin: GPIO26
interlock: [valve_close] # never both relays at once
on_turn_on:
- delay: 6s # valve travel time, then drop power
- switch.turn_off: valve_open
- platform: gpio
id: valve_close
name: "Valve Close"
pin: GPIO27
interlock: [valve_open]
on_turn_on:
- delay: 6s
- switch.turn_off: valve_close
The on_press → switch.turn_on: valve_close line is the whole point of this path: the device closes the valve itself, whether or not anything upstream is alive.
Home Assistant side
Entities auto-discover; moisture sensors land in HA's leak dashboards. Push notifications with priority: high and ttl: 0 to beat Android Doze. An auto-reopen automation (trip and clear within 60 s = probably a splash) is opt-in only — the source build's caution: "If you are not sure it was a splash, leave the valve shut until a person checks."
Pitfalls (the honest list)
It inherits every probe limit. A corroded probe can miss the leak that should have closed the valve — the probe maintenance schedule from Path A is part of this build.
Valves seize sitting in one position, worse with hard-water scale. Schedule a monthly 3 AM open/close exercise and alert if the cycle takes over 10 s.
Power loss is not closure by default — see the wiring note if you need closed-on- outage.
No position feedback on cheap 3-wire valves: state is inferred from the last command. The premium DIY route reads the valve's limit switches.
Insurance: DIY rigs sit on no insurer's approved list. Several insurers discount monitored commercial detection 3–15% — a DIY write-up sometimes works, but ask before counting on it.
Side by side
| Criterion | A: Contact probes | B: Flow sensor | C: Shutoff valve |
|---|---|---|---|
| Renter-friendly | ✓ (no plumbing) | ✗ (must splice the line) | ✗ (must cut the main) |
| Owner, accessible main | ✓ | ✓ | ✓ |
| No pipe cutting | ✓ | ✗ | ✗ |
| Budget band | ~$15–20 first point, +$3/probe | ~$30–60 + plumbing | ~$60–90 + $150–250 plumber option |
| Detects hidden/behind-wall leaks | ✗ (point coverage) | ~ (whole-house, ≥ 2 L/min) | ✗ (inherits probe limits) |
| Mitigates (stops water) | ✗ | ✗ | ✓ (local, seconds, network-independent) |
| Install difficulty | Low (solder-free possible) | Medium (plumbing splice + wiring) | Medium-high (plumbing + relay wiring) |
| Ongoing maintenance | Quarterly probe inspection | Watch for silent turbine death | Monthly valve exercise + probe checks |
| Wi-Fi/HA down | Alerts lost | Detection logic lost | Valve still closes locally |
The paths stack: A + B is the classic pair (point + whole-house detection); A + C or B + C is the away-proof house. If the decision tree above still leaves you torn, that's usually the signal to build A this weekend and plan C for when you can get a plumber.
When to just buy one
Honesty cuts both ways — sometimes the commercial product is the right call:
AquaPing ($99, checked 2026-11-29, in stock): open-source, battery-powered, stand-off acoustic detection — it hears pressurized leaks behind walls, with no contact and no plumbing. It's the one thing none of the DIY paths above does (flow only coarsely covers it). It works with ESPHome/Home Assistant (it's in the ESPHome devices database). Detection only — no shutoff.
Zooz ZAC36 Titan ($199.95): a motorized actuator that clamps onto your existing quarter-turn valve, with a wired-probe failsafe, over local Z-Wave. The closest commercial cousin to Path C without cutting pipe.
Moen Flo ($500–800 + $5/month) and Phyn Plus ($700–850): whole-house flow sensing plus automatic shutoff — commercial versions of B + C, with vendor cloud and subscription.
The DIY case per the valve-build author: the same local behavior for under $60 in parts and no subscription — but you own the QA, and there's no insurance paperwork. That's a fair trade only if you'll actually do the maintenance rows in the table above.
What we verified, and what we didn't
We verified, on 2026-11-29: every source link in this guide resolves; the three ESPHome configs compile cleanly (ESPHome 2026.11.0, esp32dev target, Arduino toolchain — the same YAML you see above, byte-identical); and every quoted line appears verbatim in the maker's own page or repository. We did not wet-test any hardware: flow-rate accuracy, probe service life and valve travel times are the makers' and community builders' claims, attributed as such throughout. Prices are approximations from each build's own parts list, not offers — expect drift, especially on marketplace-only parts like the brass flow sensors and motorized valves.
Keep going
Build an ESPHome voice assistant — the same ESP32 boards, used as always-on voice satellites for Home Assistant.
Easy ESPHome projects for Home Assistant, ranked — seven beginner-scaled builds to grow the fleet your leak detectors joined.
ESPHome wake-word voice assistants — the project page where many readers first meet ESPHome's always-on audio pipeline.
