Note: this has been edited to replace the ESP8266 internal Pullup at the GPIOs with a dedicated pullup resistor that alleviates some wet-dry issues due to currents in the water and electrolysis with too weak a pullup resistor (such as the internal one). I use a 47K Ohm between the 3.3V pin and each GPIO pin that is used for leak detection.
This design is for a simple low-cost leak detector that can be used to detect water leaks and send notifications when they are discovered. I designed this for use with ESPHome and Home Assistant.
This design accommodates M5x12 machine screws and M5 fastening nut. I recommend using stainless steel parts. The length of the screws offsets them a small distance from the bottom - you can use M5 washers if you want a greater offset. I placed these in my A/C and Water heater drain pans to detect when problems arise!
To wire these up to a microcontroller such as ESP8266 - Connect one end to GND and the other to the GPIO that you want to use to detect water. Add a 47K Ohm resistor between 3.3V and the same GPIO pin to act as a pullup. You can use multiple sensors by utilizing multiple GPIO ports. In my example I am using two of these.
In ESPHome the .yaml code looks like below for a dual sensor system. Easy to modify for less or more sensors.
binary_sensor:
- platform: gpio
name: "Leak Detector Kitchen A/C Pan"
pin:
number: GPIO5 # pick your GPIO pin This is D1
mode: INPUT # note that the internal pullup resistor is too small so do not use INPUT_PULLUP
inverted: True # so "ON" means water detected
device_class: moisture
filters:
- delayed_on: 100ms # must be wet for 100 ms before ON
- delayed_off: 5s # must stay dry for 5s before OFF
- platform: gpio
name: "Leak Detector Kitchen Water_Heater Pan"
pin:
number: GPIO4 # pick your GPIO pin This is D2
mode: INPUT # note that the internal pullup resistor is too small so do not use INPUT_PULLUP
inverted: True # so "ON" means water detected
device_class: moisture
filters:
- delayed_on: 100ms # must be wet for 100 ms before ON
- delayed_off: 5s # must stay dry for 5s before OFF
Model Kaynağı
