ESPHome Water leak detector With a D1 mini board

So I’ve been trying to make a simple water leakage detector to put under my kitchen sink.
It has been challenging as I don’t have a lot of background in electronics.
I’ve seen @tom_i Idea and he helped me a lot -

But I decided to make it even simpler and had a success with the analog pin of the D1 mini.
Next time maybe I will use something like a rain sensor instead of this probe, a good idea I think is to wrap it in a sponge so if there is a leakage you can know quick enough…
The problem with this probe is that it has to have a good contact with the water, so it’s not that sensitive.

Giving back to the community, here are the specs for this project:

Parts:

Schema:


(Notice that A0 is on the 7th pin and not the 8th like in the diagram)

YAML:

Sensitivity can be altered by changing this value:

return analog < 2.55;

You can see here my original article, I’ll try to keep it updated.

11 Likes

Looks a nice simple project! Will bookmark as I’ve been contemplating buying some water leak sensors. I wonder how long this would run on a battery for.

Also what software did you use to make the schema diagrams? That’ll be useful to document some of my other projects.

The software is Tinkercad

Many years ago I converted a smoke detector to a water leak sensor by just stripping of the plastic from two cables and taping them on the floor below the dish washer with a small distance between them then just hooking it to the test button connection.

3 Likes

Awesome idea :slight_smile: How much time did it held? Problem is with wires that with contact of water they get corroded pretty quick, a probe or a rain sensor will probably be more durable

Since we didn’t have any water leaks then it was no issue.
When it was decommissioned (10-12 years later) it was still working

That’s amazing!

Hello,

I have issue with Wemos ESP32 module in esphome (with ESP8266 everything fine): Allways 2.45V. Code part:

esp32:
board: wemos_d1_mini32
sensor:

  • platform: adc
    pin: 35
    #pin: A0
    icon: mdi:water-alert
    name: “Oraputes32 Nutekejimas”
    id: orapute32_nutekejimas
    update_interval: 5s
    filters:
    • multiply: 2.4
      binary_sensor:
  • platform: template
    id: Oraputes32_nutekejimo_statusas
    device_class: moisture
    name: “Oraputes32 apsemimo statusas”
    lambda: |-
    float analog = id(orapute32_nutekejimas).state;
    return analog < 2.05;

Always 2.45V if it is putted contacts in water or no. It doesn’t mater.

Hey @juavinas,
Please refer to the esp32 part in this documentation:

Cool. Done exactly the same😂

FYI, I used a similar probe to the one linked in the 1st post without the need of a resistor or the adc component. All I did was:

  • I soldered the water leak probe on 2 pins: GND and a compatible input GPIO pin
  • I added the following to my yaml
binary_sensor:
  - platform: gpio
    pin:
      number: D5
      inverted: true
      mode:
        input: true
        pullup: true
    name: Leak
    id: leak
    device_class: moisture

You don’t have to use D5. You can try others (before soldering) and ESPHome will complain if it isn’t compatible.

1 Like

You didnt need a resistor or to use ADC because you have a digital sensor and the other is analog. Some people want analog, sone want digital. Digital is pretty simple and straightforward but only allows for On/Off. Analog does On/Off and everything in-between. Or in other words, a digital sensor just tells you Wet/Not Wet and the analog tells you how wet it is. It could be a little wet, underwater, or was wet but is drying. This would be useful if you had a leak that triggered the sensor. Lets say you cant get it bone dry and its causing the digital sensor to keep displaying a false positive. You cant know if its its residual moisture triggering the sensor or if you sprung a new leak because its digital and just shows ON.

An analog sensor in that scenario you can tell 100% if its residual moisture, that its drying, the rate its drying at, and you can 100% tell the difference between false positives and a real positive.

Not needing this or needing ADC is subjective to each person and how they want their system to work and what feedback they want from it so, its not really a positive or negative detail about any sensor.

Do you have a link for the sensor you are using? I don’t want to use resistors either and most of the sensors i see in Alliexpress are rated for 12v-24v. Thank You.