Wifi Water Leak Detector

Parts:

1x ESP32 board (or ESP8266, but see extra parts required below)
1x Leak probe. I found these on Aliexpress but there are many ways to DIY this. Just dont use metal for the probes that corrodes easily.
1x LED (optional) and current limiting resistor
1x 5V power supply

The connections are pretty simple for the ESP32 board. Just connect one of the sensor wires to a touch capable input and the other sensor wire to ground. Connect the LED (and current limiting resistor) to any other pin (I used GPIO13). Connect the power and you’re done with the wiring.

Flash the config file:

esphome:
  name: laundry_leak
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "SSID_Here"
  password: !secret wifi_pwd
  manual_ip:
    static_ip: 10.1.1.88
    gateway: 10.1.1.1
    subnet: 255.255.255.0

logger:
  level: WARN

api:
  password: !secret api_password

ota:
  password: !secret esp_pwd

esp32_touch:
#  setup_mode: True
  iir_filter: 10ms

binary_sensor:
  - platform: status
    name: "Laundry Leak Status"
  - platform: esp32_touch
    name: "Laundry Leak"
    id: leak
    pin: GPIO27
    threshold: 100
    on_press:
      - while:
          condition:
            binary_sensor.is_on: leak
          then:
          - switch.turn_on: status_led
          - delay: 200ms
          - switch.turn_off: status_led
          - delay: 100ms
          - switch.turn_on: status_led
          - delay: 200ms
          - switch.turn_off: status_led
          - delay: 400ms
    on_release:
      then:
        - switch.turn_off: status_led

sensor:
  - platform: wifi_signal
    name: "Laundry Leak WiFi Signal"
    update_interval: 15s
    filters:
      - sliding_window_moving_average:
          window_size: 15
          send_every: 15
          send_first_at: 15
    icon: mdi:wifi

switch:
  - platform: gpio
    id: status_led
    pin:
      number: GPIO13

Mount the board in an enclosure and place the sensor where it is likely to get wet if there is a leak.

NOTE for more than one sensor or ESP2866 boards

I also tried a version of this with two touch sensors for possible leaks in my kitchen. This did not work. (See update at the end).

As a work around I just used binary sensors with very weak physical pull up resistors (3.9M Ohm) and 0.1uF noise bypass capacitors to ground on each of the used inputs. This circuit can be used on the ESP8266 board that has no Touch sensor inputs.

Annotation%202019-08-14%20030618

ESP32 config for two binary sensors (change GPIOs for ESP8266 boards):

esphome:
  name: kitchen_leak
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "SSID_Here"
  password: !secret wifi_pwd
  manual_ip:
    static_ip: 10.1.1.87
    gateway: 10.1.1.1
    subnet: 255.255.255.0

logger:
  level: WARN

api:
  password: !secret api_password

ota:
  password: !secret esp_pwd

binary_sensor:

  - platform: status
    name: "Kitchen Leak Status"

  - platform: gpio
    pin:
      number: GPIO27
      inverted: True
    name: "Sink Leak"
    id: sink_leak
    on_press:
      then:
      - switch.turn_on: status_led
    on_release:
      then:
        - switch.turn_off: status_led

  - platform: gpio
    pin:
      number: GPIO32
      inverted: True
    name: "Dishwasher Leak"
    id: dishwasher_leak
    on_press:
      then:
      - switch.turn_on: status_led
    on_release:
      then:
        - switch.turn_off: status_led

sensor:
  - platform: wifi_signal
    name: "Kitchen Leak WiFi Signal"
    update_interval: 15s
    filters:
      - sliding_window_moving_average:
          window_size: 15
          send_every: 15
          send_first_at: 15
    icon: mdi:wifi

switch:
  - platform: gpio
    id: status_led
    pin:
      number: GPIO13

UPDATE: As per the conversation below you may have to use a 100K Ohm resistor for ESP8288 boards.

Also removing the iir_filter: completely from this:

esp32_touch:
#  setup_mode: True
  iir_filter: 10ms

in the ESP32 version should allow more than touch sensor to be used. No need for the capacitor and resistor workaround.

19 Likes

Thanks for share and very interesting for rooms with leak risk such as dishwasher, washing machines, water heater but how do you physically install the sensor ? Only way I see it to work well is to get it vertical against ground but how to fix it efficiently that way ?

Screwed to the base board with the probes on the floor. I’d take a picture of it installed but I can’t be bothered moving the washing machine or dishwasher tonight.

there are also sensors that lie flat on the floor like this. It’s best if you cover them with a bit of sponge so the water wicks up onto the PCB if it is not likely to fall directly on it.

I just have the Nodemcu ESP8266 board. Doesnt seem to have any touch pin.
So i guess i need to get the ESP32 to make it work?

I covered that scenario up there ^

Thank you for the quick reply!
And im gonna go shamless to bed for not reading the last part of your post :expressionless:

Thanks for posting this!

I’ve just tried copying it on a D1 mini (ESP8266), using the circuit you outlined and the same probe you linked to. Everything looks good, except I can’t get it to actually sense water. What am I missing? What can I measure to troubleshoot?

Sorry for the delay. Does it sense anything when you short the probe tips together with metal instead of water?

Hey, thanks for putting this together, as soon as my parts arrive, I’ll be using these all over the house.

One question - where’d you get that enclosure?

Thanks!

From my junk box. I had half a dozen or so of them left over from shucking PoE injectors I had to add to some Redport Iridium terminals.

Ah, makes sense, it just fit in there so perfectly! - thanks for the quick reply!

Hey @tom_l, thanks for this awesome information!
I have a bunch of those leak probes, I’ve connected one of them with a D1 mini - like you suggested to do with esp8266 boards.
Problem is - it’s always on. I couldn’t understand when it changes the state,
I don’t know what’s in this probe - did you have a chance to look inside of it? are those just 2 probes connected with 2 wires or are there some resistors / transistors inside?
It just doesn’t seems to work, also tried to connect it to analog input - it just throws numbers, sometimes high when I touch it but never high with water contact.

Do you have any insights on this? I really want to make this work as I have a bunch of D1 minis and those probes that were originally bought for this prepose.

Made a small arduino project for testing it, sometimes it’s always high, sometimes always low. shorting the probes randomly generates HIGH/LOW, but almost never.

#include <Arduino.h>
void setup(){
    
Serial.begin(115200);    
pinMode(D5, OUTPUT); // probe
pinMode(D2, INPUT); // led + buzzer
}
void loop(){
int sensor=digitalRead(D2); 
Serial.println(sensor);   // should print 1 on HIGH or 0 on LOW
if(sensor==HIGH){
    digitalWrite(D5, HIGH); // turn on led/buzzer
}else{
    digitalWrite(D5, LOW); // turn off led/buzzer
}
delay(250);
}

Thanks!

The probes I have are just straight through wires.

You have to use the alternative circuit for the ESP8266 boards I showed above. The input will held high by the very weak pull-up resistor (3.9M Ohm) until shorted to ground by water.

Wow that was a quick reply,
Yup that’s exactly what I’ve did.
It’s always held high but I can’t get it to low with water, not even with my fingers/screwdriver/wires shorting the probes tip.
I’ve tried a different probe, same issue.
I’m going insane as this is a very simple circuite.
Can you think of other ways we can test it?
I guess it will benefit more people who want to do this little project.

Attaching an image of the circuite on a breadboard (though I don’t really know if it’s useful or understandable like this)

super thanks!

You don’t have this circuit wired up correctly:

423fcd17155931827f642d3c6d679d06ac7a3eb5

You appear to have this:

423fcd17155931827f642d3c6d679d06ac7a3eb5

The easiest way to hook it up is this:

Connect one end of the capacitor to ground.
Connect the other end of the capacitor to the resistor.
Connect the other end of the resistor to 3.3V.
Connect the probe across the capacitor (in parallel).
Connect the GPIO to the junction of the capacitor and resistor.

THANK YOU for your easy instructions brother! I hook it up like you’ve instructed and was able to make it “blink” when shorting it with a wire (I think that’s what it should do, to simulate a momentary switch click?)
BUT - IT JUST DOESNT WORK ON WATER.
any ideas of ways to investigate?

Thanks again!

just posting my wiring again, if it somewhat helps to anyone (splited my resistors so I could check them independently as i thought one of them is dead, but they are chained)

That still does not look right, but it’s hard to tell. Can you take a better picture?

Close up of the breadboard will do. I can tell where the wires go from this photo.

It actually looks like you have this now:

circuit

Which will definitely blink the led as you will be shorting out the 3.3V supply when you short the probe with a wire.

Sorry, I’ve made a sketch by the image so it will be clearer:

(I’ve removed the led part so it will be less confusing)

Move the brown and purple wires. The 3.3V should be the only wire connected to the resistor. The probe should be across the capacitor. Everything else is ok.

f47d1cd0d6d3e1593c809fd19ec0d12ab771fd55_2_543x500

By the way, what did you draw this with?

1 Like