Esp32 water leak detector

I’m trying to build this project:

Other than the display being messed up, I have the hardware working. I see part of status of DRY and WET correctly. So the hardware seems to work.
The ESPhome configuration:

substitutions:
  devicename: basement_leak_detector
  friendly_name: Basement Leak Detector
  device_description: Leak detector in basement utility room

esphome:
  name: $devicename
  comment: ${device_description}
  platform: ESP32
  board: m5stick-c
  platformio_options:
    upload_speed: 115200

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: .lan

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Basement Leak Det. Fallback AP"
    password: !secret fallback_ap_password

  manual_ip:
    static_ip: x.x.x.x
    gateway: x.x.x.x
    subnet: x.x.x.x

captive_portal:

logger:

# Enable Home Assistant API & OTA Updates
api:
  password: !secret api_password
ota:
  password: !secret ota_password

status_led:
  pin:
    number: GPIO10
    inverted: True

spi:
  clk_pin: GPIO13
  mosi_pin: GPIO15

i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: True

esp32_touch:
  #setup_mode: True
  iir_filter: 10ms

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO37
      inverted: true
    id: button_a
    on_press:
      then:
        - switch.toggle: led1
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    id: button_b
    on_press:
      then:
        - switch.toggle: led1
  - platform: status
    name: "${friendly_name} Status"
  - platform: esp32_touch
    name: "${friendly_name} Sensor"
    device_class: moisture
    id: leak
    pin: GPIO33
    threshold: 30
    on_press:
      - while:
          condition:
            binary_sensor.is_on: leak
          then:
          - switch.turn_on: led1
          - delay: 200ms
          - switch.turn_off: led1
          - delay: 100ms
          - switch.turn_on: led1
          - delay: 200ms
          - switch.turn_off: led1
          - delay: 400ms
    on_release:
      then:
        - switch.turn_off: led1

sensor:
  - platform: uptime
    name: "${friendly_name} Uptime"

    # AXP192 power management - must be present to initialize TFT power on
  - platform: axp192
    address: 0x34
    i2c_id: bus_a
    update_interval: 30s
    battery_level:
      name: "${friendly_name} Battery Level"
      id: "m5stick_batterylevel"

  - platform: wifi_signal
    name: "${friendly_name} WiFi Signal"
    update_interval: 60s

text_sensor:
  - platform: version
    name: "${friendly_name} ESPHome version"

switch:
  - platform: gpio
    pin:
      number: GPIO10
      inverted: true
    id: led1

font:
  - file: 'OpenSans-Regular.ttf'
    id: font1
    size: 66

# built-in 80x160 TFT
display:
  - platform: st7735
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    rotation: 180
    lambda: |-
      if (id(leak).state) {
        it.print(38, -24, id(font1), ST77XX_RED, TextAlign::TOP_CENTER, "W");
        it.print(38, 32, id(font1), ST77XX_RED, TextAlign::TOP_CENTER, "E");
        it.print(38, 85, id(font1), ST77XX_RED, TextAlign::TOP_CENTER, "T");
      } else {
        it.print(38, -24, id(font1), ST77XX_GREEN, TextAlign::TOP_CENTER, "D");
        it.print(38, 32, id(font1), ST77XX_GREEN, TextAlign::TOP_CENTER, "R");
        it.print(38, 85, id(font1), ST77XX_GREEN, TextAlign::TOP_CENTER, "Y");
      }

My configuration is:

substitutions:
  devicename: kitchen_leak_sensor
  friendly_name: kitchen Leak Sensor
  device_description: Leak detector in under Kitchen sink

esphome:
  name: kitchen_leak_sensor
  platform: ESP32
  board: m5stick-c
  platformio_options: 
    upload_speed: 1500000

wifi:
  ssid: "xxxxxxxxx"
  password: "xxxxxxxxxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Kitchen Leak Sensor"
    password: "xxxxxxxxxxxx"

ota:

captive_portal:

# Enable logging
logger:
 level: info

status_led:
  pin:
    number: GPIO10
    inverted: True

spi:
  clk_pin: GPIO13
  mosi_pin: GPIO15

i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: True

esp32_touch:
  setup_mode: True
  iir_filter: 15ms

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO37
      inverted: true
    id: button_a
    on_press:
      then:
        - switch.toggle: led1
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    id: button_b
    on_press:
      then:
        - switch.toggle: led1
  - platform: status
    name: "${friendly_name} Status"
  - platform: esp32_touch
    name: "${friendly_name} Sensor"
    device_class: moisture
    id: leak
    pin: GPIO33
    threshold: 30
    on_press:
      - while:
          condition:
            binary_sensor.is_on: leak
          then:
          - switch.turn_on: led1
          - delay: 200ms
          - switch.turn_off: led1
          - delay: 100ms
          - switch.turn_on: led1
          - delay: 200ms
          - switch.turn_off: led1
          - delay: 400ms
    on_release:
      then:
        - switch.turn_off: led1

    # AXP192 power management - must be present to initialize TFT power on
sensor:
  - platform: axp192
    address: 0x34
    i2c_id: bus_a
    update_interval: 30s
    battery_level:
      name: "M5Stick Battery Level"
      id: "m5stick_batterylevel"

  - platform: wifi_signal
    name: "${friendly_name} WiFi Signal"
    update_interval: 60s
    
  - platform: uptime
    name: "${friendly_name} Uptime"

text_sensor:
  - platform: version
    name: "${friendly_name} ESPHome version"
    
switch:
  - platform: gpio
    pin:
      number: GPIO10
      inverted: true
    id: led1

font:
  - file: 'arial.ttf'
    id: font1
    size: 70

color:
  # name and values from https://www.w3.org/wiki/CSS/Properties/color/keywords

  # #8b0000
  # 139,0,0
  - id: COLOR_CSS_DARKRED
    red:   0.5451
    green: 0.0000
    blue:  0.0000
    white: 0.0000

  # #006400
  # 0,100,0
  - id: COLOR_CSS_DARKGREEN
    red:   0.0000
    green: 0.3922
    blue:  0.0000
    white: 0.0000

# built-in 80x160 TFT
display:
  - platform: st7735
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    rotation: 270
    update_interval: 5s
    lambda: |-
      if (id(leak).state) {
        it.print(38, 0, id(font1), COLOR_CSS_DARKRED, TextAlign::TOP_CENTER, "W");
        it.print(38, 32, id(font1), COLOR_CSS_DARKRED, TextAlign::TOP_CENTER, "E");
        it.print(38, 85, id(font1), COLOR_CSS_DARKRED, TextAlign::TOP_CENTER, "T");
      } else {
        it.print(38, -24, id(font1), COLOR_CSS_DARKGREEN, TextAlign::TOP_CENTER, "D");
        it.print(38, 32, id(font1), COLOR_CSS_DARKGREEN, TextAlign::TOP_CENTER, "R");
        it.print(38, 85, id(font1), COLOR_CSS_DARKGREEN, TextAlign::TOP_CENTER, "Y");
      }

When I compile the project, I get this error
ERROR No remote or local logging method configured (api/mqtt/logger)

My file, with the exception of defining some colors and font, I the same, so I don’t know what I need to do.

The alert entity has been created, but shows idle.

Any help provided would be appreciated.

Thanks

I am not sure but what happens when you add an extra space before level

I get the error: component not found level.

According to the documentation they should be capital letters.

logger:
  level: INFO

Thanks, I’ll change it

Are these 2 example of esphome configurations. The top being what you are copping from the linked post?

The second config is missing a way to report out. Either the api or mqtt needs to be added to the second config.

api:

or

mqtt:

The top one was the file I copied from.

Got it working. Appreciate the help.
My final yaml

substitutions:
  devicename: kitchen_leak_sensor
  friendly_name: kitchen Leak Sensor
  device_description: Leak detector in under Kitchen sink

esphome:
  name: kitchen_leak_sensor
  platform: ESP32
  board: m5stick-c
  platformio_options: 
    upload_speed: 1500000

wifi:
  ssid: "Hall 2.4G"
  password: "xxxxxxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Kitchen Leak Sensor"
    password: "TyarI8qMyPO2"

ota:

# Enable Home Assistant API
api:

captive_portal:

# Enable logging
logger:
 level: INFO

status_led:
  pin:
    number: GPIO10
    inverted: True

spi:
  clk_pin: GPIO13
  mosi_pin: GPIO15

i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: True

esp32_touch:
  setup_mode: True
  iir_filter: 15ms

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO37
      inverted: true
    id: button_a
    on_press:
      then:
        - switch.toggle: led1
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    id: button_b
    on_press:
      then:
        - switch.toggle: led1
  - platform: status
    name: "${friendly_name} Status"
  - platform: esp32_touch
    name: "${friendly_name} Sensor"
    device_class: moisture
    id: leak
    pin: GPIO33
    threshold: 30
    on_press:
      - while:
          condition:
            binary_sensor.is_on: leak
          then:
          - switch.turn_on: led1
          - delay: 200ms
          - switch.turn_off: led1
          - delay: 100ms
          - switch.turn_on: led1
          - delay: 200ms
          - switch.turn_off: led1
          - delay: 400ms
    on_release:
      then:
        - switch.turn_off: led1

    # AXP192 power management - must be present to initialize TFT power on

# Enable Web server.
web_server:
  port: 80

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: "${friendly_name} ESPHome version"
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: kitchen_leak_sensor IP
    ssid:
      name: kitchen_leak_sensor SSID
    bssid:
      name: kitchen_leak_sensor BSSID

sensor:
  # Uptime sensor.
  - platform: uptime
    name: "${friendly_name} Uptime"

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: "${friendly_name} WiFi Signal"
    update_interval: 60s

  - platform: axp192
    address: 0x34
    i2c_id: bus_a
    update_interval: 30s
    battery_level:
      name: "M5Stick Battery Level"
      id: "m5stick_batterylevel"
    
# Exposed switches.
switch:
  - platform: gpio
    pin:
      number: GPIO10
      inverted: true
    id: led1

font:
  - file: 'arial.ttf'
    id: font1
    size: 70

color:
  # name and values from https://www.w3.org/wiki/CSS/Properties/color/keywords

  # #8b0000
  # 139,0,0
  - id: COLOR_CSS_DARKRED
    red:   0.5451
    green: 0.0000
    blue:  0.0000
    white: 0.0000

  # #006400
  # 0,100,0
  - id: COLOR_CSS_DARKGREEN
    red:   0.0000
    green: 0.3922
    blue:  0.0000
    white: 0.0000

# built-in 80x160 TFT
display:
  - platform: st7735
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    rotation: 270
    update_interval: 5s
    lambda: |-
      if (id(leak).state) {
        it.print(38, 0, id(font1), COLOR_CSS_DARKRED, TextAlign::TOP_CENTER, "W");
        it.print(38, 32, id(font1), COLOR_CSS_DARKRED, TextAlign::TOP_CENTER, "E");
        it.print(38, 85, id(font1), COLOR_CSS_DARKRED, TextAlign::TOP_CENTER, "T");
      } else {
        it.print(38, -24, id(font1), COLOR_CSS_DARKGREEN, TextAlign::TOP_CENTER, "D");
        it.print(38, 32, id(font1), COLOR_CSS_DARKGREEN, TextAlign::TOP_CENTER, "R");
        it.print(38, 85, id(font1), COLOR_CSS_DARKGREEN, TextAlign::TOP_CENTER, "Y");
      }
1 Like