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.
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.