ESPHome Water meter: convert liter/min to liters per day

What I did to get most “false counts” away is in ESPHome at the sensor I’ve added “internal_filter”:

sensor:
  - platform: pulse_counter
    pin: D2
    name: "Water Meter"
    update_interval : 60s
    accuracy_decimals: 0
    internal_filter: 200ms

So in this case: all the counts that are less as 200ms long are not counted.

@RedWheiler, thanks for your comment, I will try that also

Edit: Nevermind, even after all these changes I get wrong counts.

Hi all, I am building this exact setup at the moment.
My hardware is a Wemos D1 Mini and I have the LJ12A3-4-Z-BX-5V. I placed a logic level shifter in between the D1 and the sensor, as the D1 is 3,3V and the sensor runs at 5V. Main advantage of this setup is that you can use the D1 Power Shield and plug in almost any 6-24V adaptor.

I now have to put it in place which is kind of hard as I do not have a piece of metal to mount it on at the moment. So I will let you guys once I am done… :wink:

So… I’m back after some while, with for me a solution for measuring my water.

I don’t need to know how many liters are currently flowing at all… Well it’s still possible with my previous post but not too accurate sometimes, but it can give a good indication.

Instead, I just want to see what I use each day… And that’s pretty easy in the end.

My ESPHome yaml file gets an entry like this:

binary_sensor:
  - platform: gpio
    pin: D4
    name: "watermeter"

So this will just show ‘on’ or ‘off’ when the sensor detects the metal piece in the meter.

And then ofcourse I want it every day, so I have something like this in my sensors.yaml:

  - platform: history_stats
    name: Waterdaily
    entity_id: binary_sensor.watermeter
    state: 'off'        #Or on, you can choose...
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

This will just count the times a day the sensor registered on (off).

In the end HA just writes all my daily numbers (electricity usage, gas-consumption, solar-panel numbers,…) to a csv-file around 23:59:50 at night.

There are almost no miscounts (normally like 1 liter a day cause you can have the first count being missed), maybe when you are resetting HA a lot cause of checks and so on it will be more (will add one if the state is on (off).)

1 Like

Thanks, with the binary sensor it’s a lot easier compared with the pulse counter on the ESP!

Hello with this schema the P1sensor position 3 isn’t cable ???

You will need to connect it to 12V

Like this ?


Like this ?

Yes. That’s correct.

Don’t forget to enable the pull-up resistor for GPIO D5.

Hello Tom Thank you for your time and knowledge :slight_smile:
I Create now the code for the esp
Thanks

Hello
I Have create the yaml

esphome:
  name: water_meter
  platform: ESP8266
  board: d1_mini_pro

wifi:
  ssid: "xxxxxxxx"
  password: "xxxxxxxxxxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Water Meter Fallback Hotspot"
    password: "xxxxxxxxxxx"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: pulse_counter
    pin: 
     number: 14
     mode: INPUT_PULLUP
    name: "Water Meter"
    update_interval : 60s
    accuracy_decimals: 0
    internal_filter: 200ms

and here the result

[11:35:28][C][wifi:307]:   Hostname: 'water_meter'
[11:35:28][C][wifi:311]:   Signal strength: -77 dB ▂▄▆█
[11:35:28][C][wifi:315]:   Channel: 6
[11:35:28][C][wifi:316]:   Subnet: 255.255.255.0
[11:35:28][C][wifi:317]:   Gateway: 10.0.0.1
[11:35:28][C][wifi:318]:   DNS1: 10.0.0.1
[11:35:28][C][wifi:319]:   DNS2: (IP unset)
[11:35:28][C][logger:185]: Logger:
[11:35:28][C][logger:186]:   Level: DEBUG
[11:35:28][C][logger:187]:   Log Baud Rate: 115200
[11:35:28][C][logger:188]:   Hardware UART: UART0
[11:35:28][C][pulse_counter:147]: Pulse Counter 'Water Meter'
[11:35:28][C][pulse_counter:147]:   Unit of Measurement: 'pulses/min'
[11:35:28][C][pulse_counter:147]:   Accuracy Decimals: 0
[11:35:28][C][pulse_counter:147]:   Icon: 'mdi:pulse'
[11:35:28][C][pulse_counter:148]:   Pin: GPIO14 (Mode: INPUT_PULLUP)
[11:35:28][C][pulse_counter:149]:   Rising Edge: INCREMENT
[11:35:28][C][pulse_counter:150]:   Falling Edge: DISABLE
[11:35:28][C][pulse_counter:151]:   Filtering pulses shorter than 200000 µs
[11:35:28][C][pulse_counter:152]:   Update Interval: 60.0s
[11:35:30][C][captive_portal:169]: Captive Portal:
[11:35:30][C][ota:029]: Over-The-Air Updates:
[11:35:30][C][ota:030]:   Address: water_meter.local:8266
[11:35:30][C][api:095]: API Server:
[11:35:30][C][api:096]:   Address: water_meter.local:6053

How can I test if it’s work before installing it ?

I try to slowly add metal under the P1 sensor the led become red i remove but my sensor in esphome don’t change it’s always 0 Normal ?
thanks

Hello Every One after try the last schema
image

I receive no value for the sensor.

I try this schema

And now it’s working fine

What is the model of the pulse counter sensor, where can I get it a compatible sensor that works with esphome?
Thanks

I have used a ‘lj12a3-4-z/bx’ sensor.

1 Like

And how do you power up Wemos in this modified schema?

I have used an Wemos DC-Power Shield to power the WEMOS and all components.