Water flow energy sensor / heat meter DIY (not just water flow)

Hey friends,
help with this implementation challenge would be appreciated! For illustration:

I want to implement an “energy flow meter” or “heat meter” in ESPHome, for which in its core we need to multiply the water volume going trough a cycle loop with the back-minus-forth temperature difference (the effective energy loss). The resulting sensors in ESPHome should be:

  1. Water volume through the loop, total counter (Liter)
  2. Current water flow rate (Liter per minute)
  3. Current energy loss/investment rate (kW)
  4. Energy counter, today or total counter (kWh)

I have sensors for water flow (1 impulse per liter) and temperature sensors on the forward position and the return position of the loop (a°C - b°C = c K).

Any ideas how I can implement this? The pulse_counter and pulse_meter components seem not suited, because the multiplication must happen per water flow impulse under the temperature difference at this point. Do I need to resort to handle flow sensor signal edges myself or is there any other ESPHome component suited to solve this? Thanks

I think the pulse_counter is still suited to get the total flow and flow rate. This sensor isn’t providing an instantaneous flow rate so it will need some finite update interval to provide the average rate. Performing the multiplication per pulse would require extra logic to track time between pulses and some assumptions about the temperature change between pulses.

A template sensor can be used for the energy. The lambda for the template sensor would perform the multiplication constant * flow_rate * delta_T It’s update would get triggered when the flow rate gets updated and use the current flow and temperature values. The integration sensor could then be used to get accumulated energy usage from the energy sensor.

Hey @mulcmu and thanks for your answer.
This is kind of where it becomes muddy. You suggest to use the pulse_counter component but agree that it provides an averaged rate rather than total flow volumes over an aggregation interval. One could probably make my use case work this way, however, as I want to (ideally) compute the differential product of flow volume and temperature difference, it just feels way more intuitive and more accurate to do calculations on a per-impulse basis.
I will play around with the idea.

Pulse meter provides the current frequency and converts it to pulses/min. You can set update period to say a second or you can request an instantaneous number as and when requested. In addition, you can set it to count pulses over a period of time and then reset when needed. I also use the raw data from the sensor in say a sensor template to calculate something else. So I have 4 different values from the pulse meter.

I am assuming if you set the update interval to say 1 second, this would be sufficiently accurate enough to do your calculations … I have not set to less to 1 second but worth a shot!

Then set up a template to calculate your next step off this number.

Hey @JulianDH please correct my if I missed something.

This sounds like a binary sensor with extra steps and a bit of obscured timing manipulation. I could just define a Binary Sensor Component — ESPHome and define its on_press automation. Correct? I will give it a try.

You are correct it is a binary count reader, but I think you underestimate what it is trying to do. It provides you with a very accurate frequency which you can read when you want to. It was written for a specific purpose. I would read it first and all the posts on how it is used

I might use binary gpio and either on_click to use a lambda to calculate or template which updates on a change of the gpio. Bit of fiddling and I suppose dependent on how many Brora toons you are getting per second

Did you get this to work?

Yes! It was pretty easy after all.

My solution consists of four key entities, two generated by my microcontroller in ESPHome, two derived inside Home Assistant.

Entities:

  • Absolute increasing water volume (in L) - ESPHome
  • Absolute increasing energy consumption/production (in kWh) - ESPHome
  • Relative water flow (in L/min) - in Home Assistant
  • Relative average power (kW average over a moving window) - in Home Assistant

image

ESPHome

(Beware that I have everything twice. Could certainly be templated)

Home Assistant

Intermediary step:

sensor:
  - platform: derivative
    name: Heizungsregelung Heizkreis Volumenstrom ZWISCHENSCHRITT
    source: sensor.heizungsregelung_heizkreis_volumen
    unit_time: min
    time_window:
      seconds: 30
    round: 1

  - platform: derivative
    name: Heizungsregelung Heizkreis Leistung ZWISCHENSCHRITT
    source: sensor.heizungsregelung_heizkreis_energie
    unit_time: h
    unit: kW
    time_window:
      seconds: 60
    round: 2

The interesting entities for water flow and power

template:
  - sensor:
      - name: Heizungsregelung Heizkreis Volumenstrom
        unique_id: uniqueid__heizungsregelung_heizkreis_volumenstrom_l_min
        unit_of_measurement: "L/min"
        icon: mdi:waves-arrow-right
        state_class: measurement
        #device_class: water_rate  # doesn't exist
        state: >
          {{ states('sensor.heizungsregelung_heizkreis_volumenstrom_zwischenschritt') | float(0) }}
        availability: >
          {{ states('sensor.heizungsregelung_heizkreis_volumenstrom_zwischenschritt') not in [ 'unavailable', 'none', 'unknown' ] }}

      - name: Heizungsregelung Heizkreis Leistung
        unique_id: uniqueid__heizungsregelung_heizkreis_leistung
        unit_of_measurement: kW
        state_class: measurement
        device_class: power
        state: >
          {{ states('sensor.heizungsregelung_heizkreis_leistung_zwischenschritt') | float(0) }}
        availability: >
          {{ states('sensor.heizungsregelung_heizkreis_leistung_zwischenschritt') not in [ 'unavailable', 'none', 'unknown' ] }}

Daily energy consumption:

utility_meter:
  heizungsregelung_heizkreis_energie_daily:
    name: Heizungsregelung Heizkreis Energie täglich
    unique_id: uniqueid__heizungsregelung_heizkreis_energie_daily
    source: sensor.heizungsregelung_heizkreis_energie
    cycle: daily

Hope this helps! Let me know in case you need more details

1 Like

Impressive! Thank you for sharing this! :slight_smile:

Looks like just the thing I hope to accomplish with my heating system. I want to track
energy “produced” and energy “consumed”. See this thread if you like: Calculate energy consumption used for heating from hot water storage tanks? - #9 by Ih8rain2

Thing is that it seems that I need to know the flow, and the manufacturers of the pumps aren’t that helpful, and the flow will ofc vary, depending on several factors.

So I figured I would like to install flow meters and get their data, then I found your brilliant project here.

What kind of hardware do you have? The thing I struggle with is to find flow meters that will fit my existing pipes (pipes will have to be cut ofc), withstand heat up to ~90°C AND be able to solder to some kind of ESPHome micro controller.

Let us know how it goes!!

I am using this device, there are versions in all sizes and conventions, for cold and hot water, etc. Hope you can buy something similar where you live.

Hi All,
I know this is old now, but i’m very curious about your results.
How did these work out for you all?
did ye get good information?

Which detail are you interested in?
The solution works perfectly, as good as it possibly can. I’m getting the total amount of water in 0.25 liter steps. The energy calculation is as good as the formula physically can be, and the deravative sensors generated in Home Assistant are quite useful in UI and automations…

Hi @ThomDietrich,
thanks for this awesome Project.
I already have the Zenner Watercounter with 1L Impulse.
I’m able to dectect the consuming water, but i want to create a sensor was tell me the water ist flowing or not. I want to detect if a water tap is forget to close or a hose is come off.
Your Solution works but only show me the last rate in l/min it freeze in last value and not going down to zero.
Thanks