Water leak sensor

Probes under the washing machine or sink; a siren and a Telegram message the moment water appears.

Safety Board: ESP32-C3 SuperMini Level: ●○○ ⏱ 1 h

🛒 Ready kit in the shop

A probe that does not eat itself

The simplest leak sensor are two bare electrodes: water closes the gap. With constant DC the electrodes electrolyse and corrode within weeks. Power the probe from a GPIO only for a few milliseconds when measuring, or use stainless steel or gold-plated contacts.

Where to put it and how to test it

Water finds the lowest point, so put the probe on the floor under the washing machine, the dishwasher, the water heater and below the sink, with the contacts a millimetre above the floor. The ESP32-C3 on a battery sleeps most of the time and wakes on a GPIO level, so the alarm does not depend on the network.

  • Add a local buzzer and a Telegram message. Either alone is weaker.
  • Test the sensor with a spoon of water once a month, and put the reminder in your calendar.
  • An obvious upgrade is a motorised ball valve that closes the water. It is powerful and dangerous: it needs a fail-safe design and a manual override.

Components

  • ESP32-C3 SuperMini
  • Water leak sensor module (comparator) × 2
  • Active buzzer module 5V
  • Dupont jumper wires (M-F, M-M)

Wiring

Module Module pin ESP32 pin Note
Leak module VCC / GND 3V3 / GND
Leak module DO digital GPIO27 LOW = water (check your module)
Buzzer + signal GPIO25

Code

#include <WiFi.h>

const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";

bool connectWiFi(uint32_t timeoutMs = 20000) {
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  uint32_t t0 = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
    delay(250);
    Serial.print(".");
  }
  Serial.println();
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("IP: ");
    Serial.println(WiFi.localIP());
    return true;
  }
  return false;
}
#include <WiFiClientSecure.h>
#include <HTTPClient.h>

const char* TG_TOKEN = "123456:ABC-YOUR-BOT-TOKEN";   // from @BotFather
const char* TG_CHAT  = "YOUR_CHAT_ID";

// Keep the text free of double quotes and line breaks (it is inserted into JSON).
bool telegramSend(const String& text) {
  if (WiFi.status() != WL_CONNECTED) return false;
  WiFiClientSecure client;
  client.setInsecure();   // simple; pin the certificate for production
  HTTPClient http;
  String url = String("https://api.telegram.org/bot") + TG_TOKEN + "/sendMessage";
  if (!http.begin(client, url)) return false;
  http.addHeader("Content-Type", "application/json");
  String body = String("{"chat_id":"") + TG_CHAT + "","text":"" + text + ""}";
  int code = http.POST(body);
  http.end();
  return code == 200;
}
const int PIN_LEAK = 27, PIN_BUZ = 25;
bool alarmSent = false;
void setup() {
  pinMode(PIN_LEAK, INPUT_PULLUP); pinMode(PIN_BUZ, OUTPUT);
  Serial.begin(115200);
  connectWiFi();
}
void loop() {
  bool wet = digitalRead(PIN_LEAK) == LOW;
  digitalWrite(PIN_BUZ, wet ? HIGH : LOW);
  if (wet && !alarmSent) { alarmSent = telegramSend("Water leak detected!"); }
  if (!wet) alarmSent = false;
  if (WiFi.status() != WL_CONNECTED) connectWiFi(5000);
  delay(500);
}

Build tips

  • Place the probe flat on the floor near the washing machine or boiler.
  • Use a good 2xAAA or 18650 cell with a low-quiescent regulator for months of runtime.

What you need

Buy the parts kit · Estimated total: $6.50

ESP32-C3 SuperMini × 1
$2.50
Buy at AliExpress Buy at Amazon.com
Water leak sensor module (comparator) × 2
$2.00
Buy at AliExpress Buy at Amazon.com
Active buzzer module 5V × 1
$0.50
Buy at AliExpress Buy at Amazon.com
Dupont jumper wires (M-F, M-M) × 1
$1.50
Buy at AliExpress Buy at Amazon.com
🇺🇦 Ukraine🌍 Other countries

Other countries: order these parts on AliExpress with the links below.

Some links are affiliate links: we may earn a commission at no extra cost to you.

Related ideas

⛔ High risk

Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.

Sump or well pump backup monitor

Watches the pit for water, tells you when the mains is gone and the backup is running, and rings an alarm before the pit overflows.

  • Board ESP32-C3 SuperMini
  • Level ●●○ Intermediate
  • Build time 2–3 h
Pick parts / kit

Water outage notifier

A pressure sensor on the inlet tells you when the water is cut off or comes back, with a message and the time.

  • Board ESP32-C3 SuperMini
  • Level ●●○ Intermediate
  • Build time 1–2 h
Pick parts / kit
⚠ Caution

Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.

Cold-chain temperature logger

A battery logger with display and alerts for fridges, freezers and cold storage, keeps recording through blackouts.

  • Board ESP32-C3 SuperMini
  • Level ●●○ Intermediate
  • Build time 1–2 h
Pick parts / kit

← All module ideas →

Comments

No comments yet. Share your experience or ask a question.

Comments are moderated.