EmbeddedRelated.com

Automated Hot Water Tank Leak Detection and Shutoff System

A smart leak detection and prevention system for hot water tanks that triggers an automatic water shutoff valve and sends alerts via WiFi.

Assumptions:
  • The user will install the valve on the cold water inlet pipe of the hot water tank.
  • The leak sensor will be placed in a safety drain pan or on the floor at the base of the tank.
  • A 12V DC motorized ball valve is preferred over a solenoid to avoid water hammer and high holding power.
  • WiFi connectivity is desired for remote notification since hot water tanks are often in basements or closets.

Bill of Materials

Microcontroller
Top Pick ESP32-DEVKITC-32E Espressif Systems From our database
The ESP32 is the best choice because leak detection is only useful if you are notified. Its integrated WiFi enables easy integration with platforms like Home Assistant, Blynk, or simple email/push alerts.
Digikey $10.00 (938 in stock) Mouser $10.00 (1,045 in stock)
RASPBERRY PI PICO W Raspberry Pi From our database
Low cost, excellent documentation, and built-in WiFi. The dual-core processor can handle the sensor monitoring and network stack independently.
Digikey $6.00 (7,389 in stock) Mouser $6.00 (7,352 in stock)
Leak Detection Sensor
Top Pick MTCH9010-E/REB Microchip Technology From our database
The MTCH9010 is recommended for a professional-grade prototype because capacitive sensing avoids the electrochemical corrosion that eventually destroys cheap resistive probes exposed to moisture.
Digikey $0.41 Mouser $0.50 (1,800 in stock)
SEN-13322 SparkFun
Standard resistive water sensor breakout. Very easy to interface with an ADC and widely used in hobbyist leak detection projects.
Digikey $6.55 (118 in stock) Mouser $6.55 (31 in stock)
Temperature Sensor
Top Pick DS18B20 Maxim Integrated From our database
The DS18B20 is the winner due to the 1-Wire protocol (saving pins) and the availability of stainless-steel waterproof probes which are ideal for mounting against metal plumbing.
Digikey $5.26 (590 in stock) Mouser $7.46 (9,525 in stock)
LM35DZ/NOPB Texas Instruments From our database
Simple analog output (10mV/C). Easy to read with any MCU ADC without complex libraries.
Digikey $1.67 (12,822 in stock) Mouser $1.67 (6,907 in stock)
TMP36 Analog Devices From our database
Low-voltage analog sensor that works well on 3.3V systems like the ESP32, providing a linear voltage output proportional to temperature.
Digikey $1.78 (16,261 in stock)
Actuator
You need BOTH a motorized ball valve (like the USS-MSV00001) and a relay module (like the Parallax 27145 or a generic SRD-05VDC-SL-C) to complete this block.
27145 Parallax
Standard 5V Relay module. Essential for allowing the low-power microcontroller to switch the 12V required by the motorized valve.
Digikey $0.37 (71,669 in stock)
Power Supply
Use the 12V wall adapter as the primary source. Use a DC-DC buck converter to provide a stable 5V rail for the ESP32 and relay module.
GST25A12-P1J Mean Well From our database
Reliable 12V 2.08A wall adapter. Provides enough current to drive the motorized valve and power the electronics.
Digikey $13.70 (813 in stock) Mouser $13.70 (685 in stock)

Compatibility Notes

  • The ESP32 uses 3.3V logic. Ensure the Relay module used is either 3.3V compatible or use a logic-level shifter/transistor to drive a 5V relay coil.
  • The motorized valve requires 12V; ensure the relay contacts are rated for at least 2A at 12VDC (most are 10A, so this is safe).
  • If using the MTCH9010, refer to the datasheet for specific trace geometry if building a custom capacitive probe.

You'll Also Need

  • Plumbing fittings (NPT adapters) to splice the valve into the water line.
  • Enclosure (IP65 rated recommended due to proximity to water).
  • Wiring for the sensor (should be long enough to reach from the tank top to the floor).
  • Flyback diode (e.g., 1N4007) across the relay coil and valve motor to prevent inductive spikes.
Estimated BOM Cost: $35-40 (based on live distributor pricing)

Design Considerations

Fail-Safe Valve State
Choose a 'normally open' motorized valve that remains open without power but closes when the relay is energized, OR use a 2-wire auto-return valve that uses a capacitor to close itself if the main power fails. For a leak preventer, the system must be able to shut the water off even if a leak causes a local electrical short.
Sensing Reliability and False Positives
Hot water heaters are often in humid environments. Capacitive sensors like the MTCH9010 should be calibrated to distinguish between high humidity/condensation and actual standing water to avoid nuisance water shutoffs for the entire house.
Valve Maintenance (Exercising)
Motorized ball valves can seize if they are not moved for years. The firmware should include an 'exercise cycle' that partially closes and re-opens the valve once a month to ensure it remains functional when an actual leak occurs.
Power Resilience
Consider adding a small LiPo battery or Supercapacitor backup for the ESP32. If a major leak causes a circuit breaker to trip, the system needs enough stored energy to complete the valve closing sequence and send a final 'Emergency' WiFi alert.
Corrosion Mitigation
If using resistive probes, implement 'AC excitation' by toggling two GPIOs to reverse polarity across the probes. This prevents metal migration and oxidation that occurs when a DC voltage is constantly applied to electrodes in water.

Want to customize this project or build something different?

Try the Project Advisor