Esp32 watermeter, looking for an actually working method ;)

Hi, I have installed a inductive proximity sensor on my ‘dumb’ watermeter and the sensor itself seems to be working just fine.

Watermeter: 175_schedatecnica-mvm-en-v6_1622556944.pdf (maddalena.it)

As far as I can measure the wheel spins exactly 1x per liter and I can successfully register the metal part of the wheel passing my sensor.

sensor:
  - platform: pulse_meter
    pin: GPIO18
    name: '$friendly_name'
    internal_filter: 100ms
    filters:
      - throttle: 10s

binary_sensor:
  - platform: gpio
    pin: GPIO18
    name: "$friendly_name"
[19:33:19][D][binary_sensor:036]: 'Watermeter': Sending state ON
[19:33:19][D][sensor:113]: 'Watermeter': Sending state 9.58313 pulses/min with 2 decimals of accuracy
[19:33:24][D][binary_sensor:036]: 'Watermeter': Sending state OFF
[19:33:34][D][sensor:113]: 'Watermeter': Sending state 10.86169 pulses/min with 2 decimals of accuracy

I now want to be able to register liters used per event, day, week, month, year. I’m not really interested in the flow per minute.

The binary sensor goes on/off every time the wheel passes and one liter of water is used.

I have tried about all configurations I was able to find, but none of them seems to be accurately registering my water usage.

As others have probably death with the same kind of configuration, I would be thankful for anyone willing to share a verified working configuration.

I know :slight_smile:

1 Like

This is the one I use. Works well. I use an hmc5883l.

I use an external library because it gives me full control of all calculations, setup, etc. I plan to add a few more calculations to send out as values to HA at some point since right now, all it gives me are raw values.

Can you provide more details on your setup with the hmc5883i?

The hmc5883l is an i2c device so you connect the SDA /SCL/VIN(3.3) /GND lines to the SDA/SCL/3.3v/GND pins on the esp8266 or esp32 . I simply taped it to the side of my water meter.

Sorry should have updated/deleted the message doing some googling found a few blogs on using it.
I’m going to need to order some 5883 from Aliexpress/ebay…

I’m pretty sure I’m getting a knock at the door from the feds from all the stuff I have been ordering they are going to think I’m upto no good :slight_smile:

ha! I know the feeling. I used the hmc5883l because I had some on hand. Technically you could use any device that will detect the meter pulses. Of course, the setup code and output would need to be adjusted accordingly.
This is the original source of the idea and code. Good reading there.
http://seductiveequations.com/2015/11/09/water-meter.html

I’m using the pulse_meter as well (using a Wemos D1 mini instead of a esp32) and added a “total” to the yaml, which gives the total amount used in m3.

sensor:
  - platform: pulse_meter
    pin: 
      number: D5
      mode: INPUT_PULLUP
    name: "watermeter usage"
    icon: mdi:water
    unit_of_measurement: "L/min"
    accuracy_decimals: 1
    timeout: 1min

    total:
      name: "watermeter usage total"
      icon: "mdi:cube-outline"
      unit_of_measurement: "m³"
      accuracy_decimals: 3
      state_class: total_increasing
      filters:
        - multiply: 0.001

Then in HA add the “utility_meter” integration to your configuration.yaml and you have in HA most of your wanted data (not the event one)

utility_meter:  
  water_usage_quarter_hourly:
    source: sensor.watermeter_usage_total
    cycle: quarter-hourly
  water_usage_hour:
    source: sensor.watermeter_usage_total
    cycle: hourly
  water_usage_daily:
    source: sensor.watermeter_usage_total
    cycle: daily    
  water_usage_weekly:
    source: sensor.watermeter_usage_total
    cycle: weekly
  water_usage_monthly:
    source: sensor.watermeter_usage_total
    cycle: monthly
  water_usage_quarterly:
    source: sensor.watermeter_usage_total
    cycle: quarterly
  water_usage_yearly:
    source: sensor.watermeter_usage_total
    cycle: yearly   
2 Likes

Hi, Just tried your exact same config. The log is then spammed full:

substitutions:
  name: esp32-watermeter
  friendly_name: "Watermeter"

esphome:
  name: $name
  platform: ESP32
  board: mhetesp32minikit

captive_portal:

wifi:
  ssid: !secret esphome_wifi_ssid
  password: !secret esphome_wifi_password
  power_save_mode: light
  
api:
  password: !secret esphome_api_password

ota:
  password: !secret esphome_ota_password

web_server:
  port: 80

logger:

# Enable time component to reset energy at midnight
time:
  - platform: sntp
    id: my_time  

sensor:
  - platform: pulse_meter
    pin: 
      number: GPIO18
      mode: INPUT_PULLUP
    name: "$friendly_name"
    icon: mdi:water
    unit_of_measurement: "L/min"
    accuracy_decimals: 1
    timeout: 1min

    total:
      name: "$friendly_name totaal"
      icon: "mdi:cube-outline"
      unit_of_measurement: "m³"
      accuracy_decimals: 3
      state_class: total_increasing
      filters:
        - multiply: 0.001
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.09900 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 8571.42871 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.10600 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.11300 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.12500 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.13400 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.13900 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.15700 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.16900 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.17700 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 4000.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.18100 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.18800 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.19500 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.20000 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.20600 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.21300 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 8571.42871 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.22400 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.22900 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.23500 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.23800 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.24500 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.25400 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.26000 m³ with 3 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:23][D][sensor:113]: 'Watermeter totaal': Sending state 8.26800 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.27600 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.28500 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.28900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.29900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.30700 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.31500 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.32300 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.33300 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.34200 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.35900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.36300 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.36900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.37800 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 3333.33325 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.38500 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.39300 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.39800 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.40300 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.41100 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.42600 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.43200 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.43700 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 30000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.44500 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.45600 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.46800 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.47400 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.48900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.49400 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.49900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.50400 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.50900 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.51400 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.52400 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter totaal': Sending state 8.53300 m³ with 3 decimals of accuracy
[10:03:24][D][sensor:113]: 'Watermeter': Sending state 30000.00000 L/min with 1 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter totaal': Sending state 8.54600 m³ with 3 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter': Sending state 12000.00000 L/min with 1 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter totaal': Sending state 8.56200 m³ with 3 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter': Sending state 20000.00000 L/min with 1 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter totaal': Sending state 8.57700 m³ with 3 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter': Sending state 60000.00000 L/min with 1 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter totaal': Sending state 8.58600 m³ with 3 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter': Sending state 0.00000 L/min with 1 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter totaal': Sending state 8.59000 m³ with 3 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter': Sending state 15000.00000 L/min with 1 decimals of accuracy
[10:03:25][D][sensor:113]: 'Watermeter totaal': Sending state 8.59700 m³ with 3 decimals of accuracy

Any ideas why this happens?

This seems to only happen when the metal part of the watermeter passes (or remains below) the sensor. I suspect it keeps detecting and needs some debounce filter or something.

What happens if you try it without the

mode: INPUT_PULLUP 

For the pulse-meter I`m using the electronical scheme as described in P1-monitor watermeter – ZTATZ and I had to add

mode: INPUT_PULLUP 

to get it working.

Any update about the ESP32 watermeter. Also struggeling with it…
Please share your code when you have a good working integration.

(of course you could also consider the Toon Water watermeter. Ready build (so less fun :slight_smile: ) but has a simple API so you can get the values easy.)

Hi all, I will be repeating this message over mutliple threads.
My situation is that I cannot setup electricity next to the watermeter so am targeting a non-esp, zigbee solution. The sensors however are consuming anyhow, did anyone of you look at low-power sensors?
Thx

As an alternative, a power bank might help.

This is my solution: Connectix Smart Gateways Wifi Water Meter
By combining internal_filter: 200ms and internal_filter_mode: edge , i have a very reliable water measurement. 1 rotation equals 1 liter for me, so we have a similar situation.

1 Like

The new ESP32-S6 ESP32-C6 might be worth a try since it supports zigbee.
Another potential solution could be to combine an aqara door sensor with a pulse sensor.

1 Like