EmbeddedRelated.com

Hot Water Tank Leak Detector with Automatic Shut-Off Valve

A prototype leak-detection controller that senses water near a hot water tank and closes a valve when a leak is detected.

Intermediate Project — This is an intermediate prototype because it combines always-on sensing, safe actuator control, and inductive-load/power-fail handling, even though the core logic is simple.
Assumptions:
  • The valve is a normally-closed or power-to-open shutoff valve that can be driven by a relay or solenoid output.
  • The prototype can be mains-powered or wall-adapter powered; battery backup is optional but desirable for fail-safe behavior.
  • Leak detection is based on a simple conductive water sensor placed on the floor or in a drip tray near the tank, not on pressure or flow sensing.
  • The system only needs local autonomous operation; no remote app or cloud connectivity was requested.

Bill of Materials

Microcontroller
Top Pick STM32L431CCU6 STMicroelectronics From our database
STM32L431CCU6 is the best overall choice here because it is low-power, reliable for always-on monitoring, and has plenty of headroom for a safety-oriented state machine without the extra power draw of WiFi.
Mouser $4.44 (504 in stock) Digikey
Dev Board NUCLEO-L432KC STMicroelectronics
Ready-to-use board for prototyping with this chip
Mouser $11.80 (2,373 in stock) Digikey
SAMD21G18A Microchip From our database
Simple, well-supported Cortex-M0+ MCU with enough peripherals for a leak sensor input and relay/solenoid control. Good for a prototype if you want easy USB development and a broad Arduino-style ecosystem.
ESP32-DEVKITC-32E Espressif Systems From our database
Best if you want built-in WiFi for alerts or remote status later, while still being easy to prototype with USB power and programming. More power-hungry than the STM32L431CCU6, but very convenient for connected prototypes.
Leak Detection Sensor
Top Pick MTCH9010-E/REB Microchip Technology From our database
MTCH9010-E/REB is the best technical fit because it is specifically intended for conductive liquid detection, which matches the leak-detection use case better than a generic level sensor.
Mouser $0.50 (1,790 in stock)
13835 SparkFun Electronics From our database
A ready-to-use digital liquid level sensor module that is easy to prototype with and can be mounted where water would collect. Good for quick validation because it gives a simple digital leak-present signal instead of requiring analog threshold tuning.
DFRobot SEN0237 DFRobot
Commonly used water leak sensor probe/module for prototypes, with straightforward conductive leak detection and easy integration to a microcontroller input. Useful if you want a low-cost, widely understood leak sensor approach.
Actuator
Top Pick G6B-2114P-US-DC24 Omron From our database
G6B-2114P-US-DC24 is the safest general prototype choice because it provides galvanic isolation and straightforward on/off control, which is ideal when the exact valve type is still being finalized.
Mouser $9.25 (5,076 in stock) Digikey
SY21611FHC Silergy From our database
Integrated half-bridge driver for inductive loads such as solenoids, relays, and small motors. Useful if the shutoff valve is a DC solenoid and you want a compact driver stage rather than a mechanical relay.
AO3400A Alpha and Omega Semiconductor
A very common logic-level N-channel MOSFET for driving a DC solenoid valve or relay coil from a microcontroller. Good low-cost option if the valve is a DC load and you want a simple, efficient switch with fewer moving parts than a relay.
Power Supply
Top Pick R-78E5.0-0.5 RECOM From our database
R-78E5.0-0.5 is the best default for a prototype because it gives you an efficient, easy 5 V rail from a wall adapter, which is practical for driving a relay and powering the control electronics.
Mouser $3.30 (16,252 in stock) Digikey
MCP1700-33 Microchip Technology From our database
Very low quiescent current 3.3 V LDO, useful for battery-backed or always-on low-power sections. Good for the MCU and sensor rail if you want minimal standby drain.
MCP73871T-2CAI/ML Microchip From our database
Integrated single-cell Li-ion charger with power-path management, useful if you want battery backup so the leak detector still works during outages. Helps build a more fail-safe prototype by allowing charging and load sharing.

Compatibility Notes

  • STM32L431CCU6 runs at 3.3 V logic, so any relay or valve driver input should be compatible with 3.3 V control or use a transistor/driver stage.
  • G6B-2114P-US-DC24 is a 24 V coil relay, so the coil supply must be separate from the MCU rail; do not drive it directly from the MCU pin.
  • MTCH9010-E/REB and the STM32L431CCU6 are a good voltage match for a 3.3 V system.
  • If you use R-78E5.0-0.5 for 5 V generation, you may still need a 3.3 V rail for the MCU and sensor, either from the MCU board or a small LDO.
  • If the valve is a DC solenoid rather than a relay-switched valve, the SY21611FHC or AO3400A approach is electrically simpler and more efficient than a mechanical relay.

You'll Also Need

  • Valve hardware itself is not included; you still need the actual shutoff valve or solenoid valve matched to your plumbing and supply voltage.
  • You will need a proper enclosure, cable glands, terminal blocks, and waterproof sensor mounting hardware.
  • Flyback protection, fuse protection, and any required snubber/TVS parts are not listed but are important for inductive loads.
  • If using a relay, you may need a transistor driver and base/gate resistors depending on the exact relay module implementation.
  • A wall adapter or battery pack is still required; the power block only covers regulation/charging, not the source itself.
Estimated BOM Cost: $25-30 (based on live distributor pricing)

Design Considerations

Fail-Safe Valve Behavior
For a leak shutoff system, the safest architecture is usually fail-closed: loss of power should leave the water supply off rather than open. If you use a relay, choose contacts and wiring so the default state removes power from the valve on MCU reset or brownout. Test the power-fail case explicitly by unplugging the supply and verifying the valve returns to the safe state.
Leak Sensor Placement
A conductive leak sensor only works if water can physically reach it, so placement matters more than the electronics. Put the probe at the lowest likely pooling point near the tank, and consider using two sensors: one near the tank base and one near the floor drain path. That reduces false negatives from water wicking or uneven flooring.
False Trigger Immunity
Hot water tanks can create condensation, drips, and occasional splashes, so firmware should require a sustained wet condition before tripping the valve. A simple approach is to sample every 100-500 ms and require several consecutive wet readings, then latch the fault until manual reset. This avoids nuisance shutoffs from brief droplets while still reacting quickly to real leaks.
Inductive Load Protection
If the valve is a solenoid or the relay coil is driven directly, add flyback suppression and verify the driver can handle the coil current. Inductive kick can reset the MCU or damage the switch device if not handled. Keep the high-current loop short and separate from the sensor wiring to reduce EMI into the leak input.
Power Backup and Brownout Handling
A leak detector is most valuable during outages and brownouts, so consider battery backup or at least a hold-up strategy for the control electronics. The MCU should detect undervoltage and force the valve to the safe state before the rail collapses. If you add MCP73871T-2CAI/ML later, you can keep the controller alive long enough to close the valve cleanly.
Validation and Test Plan
Do not validate only with a wet finger on the sensor; test with real drip rates, standing water, and condensation over several hours. Also test the full chain: sensor trip, MCU response time, driver activation, and valve closure under the actual supply pressure. A good prototype should log or indicate whether the trip came from sensor fault, brownout, or genuine leak detection.

Want to customize this project or build something different?

Try the Project Advisor