Inductive water meter

At the moment i’am running ESPHome on a WeMos D1 , with a connected NPN inductive sensor .
This sensor read’s the pulse on the Elster water meter .
I think al few others ( Dutch guys) running the same config , coud you help me sharing you’re sensor’s / config ?
I would be nice to read out this : current L used , L(iters) used today, and probably L/hour (flow).
At the moment i only get this last sensor running, using this in de yaml:

sensor:
  - platform: pulse_counter
    name: "waterverbruik L/hr"
    pin: GPIO4
    update_interval: 30s
    filters:
    - lambda: return (x / 27.0) * 60.0;
    unit_of_measurement: "L/hr"

There are other threads on this, please search.

i tried, but at the moment i only found an old topic with a non working config : inductive sensor config

Which would have no doubt led you here

i found this one, but that’s not the one i was looking for :smiley:

this code i found on the inductive topic:

esphome:
  name: sensor_01
  platform: ESP8266
  board: esp12e

wifi:
  ssid: "#####"
  password: "####"

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  password: "####"

ota:
  password: "####"

sensor:
  - platform: pulse_counter
    pin: GPIO5
    unit_of_measurement: 'Liter '
    name: 'Water meter'
    id: pulse
    update_interval: 60s
    filters:
      - multiply: 0.0001

  - platform: template
    name: "Water meter totaal"
    unit_of_measurement: 'Ltr'
    lambda: |-
      static float total_value = 0.0;
      total_value += id(pulse).state / 1000;
      return total_value;

  - platform: integration
    name: "Water total"
    sensor: pulse
    time_unit: min
 
  - platform: pulse_counter
    id: water_pulse
    pin: GPIO5
    internal: true
    name: "Water Counter 2"
    update_interval: 60s
    filters:
      lambda: |-
        static float total_pulses = 0.0;
        total_pulses += x * 1 / 60.0;
        id(lifetime_counter).publish_state(total_pulses / 17);
        return x ;
  
  - platform: template
    id: lifetime_counter
    name: "Water Total 2"
    unit_of_measurement: "L"
    
  - platform: template
    name: "Water Flow 2"
    id: water_flow_rate
    accuracy_decimals: 1
    unit_of_measurement: "L/min"
    icon: "mdi:water"
    lambda: return (id(water_pulse).state /17);
    update_interval: 60s

 

had everything i needed, but the code doesnt work :thinking:

“doesn’t work” - how do you expect help with that?

you’re absolutely right :slight_smile: .

To troubleshoot , i cut appart the code and started again :innocent:

sensor:
  - platform: pulse_counter
    pin: GPIO4
    id: waterusage
    unit_of_measurement: 'L/min'
    name: waterverbruik
  #  filters:
   #   - multiply: 0.06
  - platform: total_daily_energy
    name: tot_water_day
    power_id: waterusage
    filters:
    - multiply: 25
    unit_of_measurement: L
    
  - platform: template
    name: "Water meter totaal"
    icon: "mdi:water-pump"
    unit_of_measurement: 'Ltr'
    lambda: |-
      static float total_value = 0.0;
      total_value += id(waterusage).state;
      return total_value;

So the first part : pulse counter returns with some nice real team L/min used ( counted pulses)

The 2nd part: is just a total count from the pulses from part 1 .

The 3rd part is the test a did to return a better total count of pulses ( L a day) used , instead of the 25 multiplier . But this part isn’t working and gives a “nan” in the log files .

What did i want to know: the total L/min (part 1), total day usage , total weer usage, total usage overall

I think I see what you are trying to do in the third part, but I am not sure your logic is correct. Simply adding up your rate of usage is not going to work.

I think you should probably use home assistant to calculate that using the integration sensor or the utility meter sensor. https://www.home-assistant.io/integrations/integration/ or https://www.home-assistant.io/integrations/utility_meter/

i already started with this.
Entered this as a sensor (within my sensor.yaml)

  - platform: template
    sensors:
     todays_water_consumption:
        value_template: >
          {{ (float(states.sensor.waterverbruik.state) - float(states.input_number.midnight_water_consumption.state)) | round(3) }}
        unit_of_measurement: 'L'
        friendly_name: "Today's Water usage"

and this as automation

- alias: Water Consumption at start of the day
  trigger:
    platform: time
    at: 00:00:00
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.midnight_water_consumption
      value: '{{ states.sensor.waterverbruik.state }}'

I just uploaded this on thingiverse for the Elster v200 meter: https://www.thingiverse.com/thing:4425795

2 Likes

You’re using a tcrt5000 sensor instead of the inductive one ?

Did you figure out the code?
I have a lt/min sensor and a total daily liters sensor that resets every night at 12, set up at an ESP and getting the values in HA.
I’m trying to set up an integration and a utility meter sensor, but im having some trouble understanding how they work.

i’m having troubles as well. I have a gallons/min sensor that i’m trying to track with a Utility Meter sensor, but the Utility Meter is not incrementing every minute by the state value of the gpm sensor… it’s also not linear, so i’m really confused on what it’s summing up.

I can’t specify what flow rate the Utility Meter is observing… perhaps it thinks my sensor is hourly?

here’s the utility meter:

and here’s the sensor the utility meter is supposed to be summing:

hmmm… so 222 gallons after 7 hours today is a rate of 30 gallons per hour (approximately)… i think the hourly might be right? Would love to hear anyone that has worked with the utility meter more closely weigh in…

otherwise i might create a template sensor that converts my Gallons/Minute to Gallons/Hour and have the utility meter track the latter

Created the per hours sensor and tracked it via the utility meter for a day. While the summed quantity in the Utility Meter looks closer to what i’d expect, it still seems like mostly a linear slope for the whole day, but from my sensor, it should have changed between 30 gpm, 20 gpm, and ~5 gpm depending on time of day…

I’ve re-read the documentation a few times and I’m assuming the utility meter should be taking the integral of the sensor I configured… but the docs dont’ explicitly state how it works. Anyone familiar with would be great to get some advice

On the tail end of my sensors, you can see the slope changing a bit… i’m going to watch it for another day or so and I can check back in (apologies for commandeering this thread if i’m off topic)… I’m also considering using a combination of the Integration sensor for finding the integral and a history stats sensor to compile what i thought Utility Meter was supposed to be doing for me (less tarrifs which i don’t need).

Seems gpm or gph are rates. Quantity per time period.

The utility meter example in the docs uses kilowatt hours. That is not a rate. Kw is rate. kwh is a quantity.

In other words I think you are feeding the wrong data.

Yeh - that makes sense and i was suspecting i was doing that wrong more and more. Thanks nickrout… I’ve created and integral sensor and am tracking new metrics for a day and will post back my conclusion – seems like this new setup is working properly.

Here’s where I ended up… I hope this helps others.

I have a sensor that detects the rate of water flow (out of a pump for my pool) in gallons per minute. Here’s what its past 24 hours looked like changing rates throughout the day:

image

I then needed to create an “integration sensor” to sum up the integral (the area under the GPM line) which will give me the quantity of gallons pumped:

- platform: integration
  name: pool_cycle_flow_integral
  source: sensor.pool_pump_flow_rate
  unit_time: min
  unit: "Gallons"
  round: 0

image

That number seemingly never resets (maybe on restarts?), so i needed a sensor that summed up the difference from midnight to now. Possibly could have done this with a combination of Statistics sensors and template sensors … but the Utility Meter did exactly what i needed:

pool_cycle_gallons_today:
  source: sensor.pool_cycle_flow_integral
  cycle: daily

The last thing I added was a “turn overs today” sensor which is just a simple template sensor with some algebra, but it’s based on top of all of these other sensors… so i thought i’d include it here:

- platform: template
  sensors:
    pool_cycle_turnovers:
      value_template: "{{ ((states.sensor.pool_cycle_gallons_today.state)|int / 13000)|int }}"

image

What is the sensor that you’re using?

1 Like

Hi Roumen on the thingiverse page your link to aliexpress is broken now. Which sensor are you using for Elster V200 water meter please?