I try to build a battery driven Water Meter. For it a have ordered me some ESP32_Bat_Pro devices from EzSBC. I want to track my water usage on the ZENNER ETKDI-N with preinstalled reed contact which counts ≥1L/Impuls. I connected it to the ESP between IO14 and GND.
The reed closes, when a Liter water passed the counter and opens again, when a new liter starts to pass the counter.
My first problem is, that the counting works not like I expect it. I had it already counting something, but it got not saved. I seams that ESPHome does not save the values from pulse_meter / pulse_counter (I tested both, but only got
pulse_meter working) when deep_sleep is used.
WakeUp is working, when GPIO14 get connected to GND, but it seams to me, that there are also two other problems/questions:
- is a pulse also counted, when he wakes up, or get those pulses dropped?
- the ESP goes to sleep also when water flows
- Save the state of pulse_meter before deep_sleep - maybe its not available in ESPHome right now - like it was on ESPEasy
Can somebody help?
I have currently the following setup:
esphome: name: "gwz-vorne" friendly_name: Gartenwasserzähler Vorne libraries: - "Wire" on_boot: priority: 600 then: - switch.turn_on: led_blue esp32: board: esp32dev framework: type: arduino # Enable logging logger: # Enable Home Assistant API api: encryption: key: "XXXX" services: - service: set_pulse_total variables: new_pulse_total: int then: - pulse_meter.set_total_pulses: id: water_meter value: !lambda 'return new_pulse_total;' ota: password: !secret ota_password on_begin: then: - switch.turn_on: led_red on_end: then: - switch.turn_off: led_red - switch.turn_on: led_green wifi: ssid: !secret wifi_ssid password: !secret wifi_password power_save_mode: HIGH # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Gwm1 Fallback Hotspot" password: "XXX" captive_portal: web_server: port: 80 local: true i2c: id: bus_a deep_sleep: run_duration: 30s sleep_duration: 60min wakeup_pin: GPIO14 wakeup_pin_mode: INVERT_WAKEUP sensor: - platform: lc709203f i2c_id: bus_a address: "0x0B" battery_voltage: name: Battery Volt battery_level: name: Battery Level icversion: name: IC Version cell_charge: name: Cell Charge update_interval: 3600s - platform: pulse_meter id: water_meter name: "Wasser Durchflussmenge" pin: number: GPIO14 inverted: False mode: input: True pullup: True internal_filter: 10ms unit_of_measurement: "liter/min" icon: "mdi:water" total: id: water_meter_total_m3 name: "Wasser Verbrauch" unit_of_measurement: "m³" accuracy_decimals: 3 device_class: water state_class: total_increasing filters: - multiply: 0.001 - platform: template id: water_usage_total_liter name: "Wasser Verbrauch" accuracy_decimals: 0 unit_of_measurement: "liter" icon: "mdi:water" device_class: water state_class: total_increasing lambda: return (id(water_meter_total_m3).state * 1000); update_interval: 10s switch: - platform: restart name: "Restart" - platform: gpio id: led_red name: LED Red internal: True pin: number: GPIO16 inverted: True - platform: gpio id: led_green name: LED Green internal: True pin: number: GPIO17 inverted: True - platform: gpio id: led_blue name: LED Blue internal: True pin: number: GPIO18 inverted: True