Water level sensor for coffee machine

My espresso machine doesn’t have a water level sensor, and when running out of water it starts making horrible noises that don’t sound healthy at all. Since I keep forgetting to check the tank, I decided to make a sensor and send low water level notifications to my phone.

I ordered a cheap capacitive sensor (M03 variant, up to 5 V) and used a ESP32-based microcontroller running ESPHome-based code. Wiring was super easy: “+” to 5V, “-” to GND and “O” to a digital signal pin, e.g. GPIO1.

The biggest challenge was to calibrate the sensor. The sensitivity is not adjustable (at least not without switching the PCB components) so I tried to add capacity by inserting various coins between the sensor and the plastic water tank until water detection became reliable. 5 euro cent coin turned out to be just the right size.

Here’s the ESPHome config I used (board-specific sections omitted). To avoid accidental false positives due to momentary sensor glitches, I added a “debounce” filter:

esphome:

[...]

binary_sensor:
  - platform: gpio
    name: Water
    pin:
      number: GPIO1
      inverted: true
    filters:
      - delayed_on_off: 3s

In Home Assistant, the new ESPHome device was automatically discovered. I then created a rule which would send a notification when the sensor stops detecting water:

alias: Coffee machine water level warning
description: "Notify on low level"
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.water_level_water
    to: "off"
actions:
  - action: notify.send_message
    data:
      message: Coffee machine is out of water.
      title: ☕ Coffee Machine
    target:
      entity_id: notify.ha
mode: single

Now I get low water level warnings even before the last drop is in the cup. 🙂

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *