Build a water meter with ESPHome and proximity sensor (no soldering required)

Can confirm it works but with hall sensor.

I used this one: Hall Effect Sensor - Unipolar - 3V to 28V

Although config doesn’t work. Only 2 / 5 sensors are working

1 Like

I have a Sensus, but not sure the model. it’s a 25-30 year home, so could be original meter. Does anyone know if the pulse reader would work?

1 Like

For some reason I’m not able to install the configuration on my ESP32 (ESP-WROOM-32).
I’m allready using this ESP32 as a bluetoorth proxy, so it’s working.

I guess my problem is a newbie thing, but I’m not able to get around it.
This is my full configuration:

This is the error message I get:

What am I doing wrong?

EDIT: I did find the problem, missing spaces.

This may be a version of the problem I have: When the sensor is close to metal it counts continuously. When looking at the sensor output with a scope it looks like some kind of noise. There is more noise when the output is connected to an input on my esp32.
I have checked with two different sensors, same result.
Any idea how to fix this problem?
My sensor is a E2S-H4N1-5V.

Hi,
This may be the same problem I had. When metal was detected the sensor counted on its own. I found the ptoblem in two places: Electrical noise from the sensor and low voltage to the sensor.
When looking at the closed (detected) state in an oscilloscope there was a lot of noise in the signal, on top of that the voltage from the ESP32 was only 4,4v.
My solution was to connect a 200nF condensator (I did no calculations) between signal from the sensor and GND and instead of supplying power to the ESP32 via the USB-port, I connect the 5v from the USB directly to VIN on the board and supplied the sensor from the same source.
This got rid of most of the problem but still there was a few pulses every minute. To get rid of those phantom readings I did some filtering in the code:

sensor:
  - platform: pulse_counter
    pin: 
      number: 34
    use_pcnt: false
    count_mode:
      falling_edge: INCREMENT
      rising_edge: DISABLE
    internal_filter: 200ms
    update_interval : 6s
    name: "water pulse"
    id: water_pulse

  - platform: pulse_meter
    pin:
      number: 34
    internal_filter: 200ms
    name: "Water Pulse Meter"
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Total"
      unit_of_measurement: "liter"

  - platform: pulse_meter
    pin:
      number: 34
    internal_filter: 200ms
    name: "Water Pulse Meter"
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Meter Total"
      unit_of_measurement: "m³"
      id: water_meter_total
      accuracy_decimals: 3
      device_class: water
      state_class: total_increasing
      filters:
        - multiply: 0.001

Now the sensor have been in test detecting metal most of the time for about 24 hours without any false readings.

BTW, I’m using a different sensor for easy placement:
https://www.dfrobot.com/product-2025.html

HI, this looks like a good project to dip my toes into ESP…
IN Australia our water meters are located outside and not near any power supply. What would be the best way to power an ESP device in this situation??

New to HA and the ESP32 integration with Energy for water metering. I am trying to use Peter Brinkman’s guide with a water meter that has a pulse sensor ( dry contact sensor ). Each gallon of water has 1 pulse & closes the relay. I have connected the - output to ground on the ESP32 & the + to pin 32. I am attaching my configuration yaml & the add to the HA config. Hope someone can see how I can correct my problem. I have tried several sensor files but get very large ( incorrect ) amount of water but don’t see water pulse in " real time ".

sensor:

  • platform: pulse_counter
    pin: GPIO32
    update_interval : 6s
    name: “water pulse”
    id: water_pulse

  • platform: pulse_meter
    pin: GPIO32
    name: “Water Pulse Meter”
    unit_of_measurement: “gallon/min”
    total:
    name: “Water Total”
    unit_of_measurement: “gallon”

  • platform: pulse_meter
    pin: GPIO32
    name: “Water Pulse Meter”
    unit_of_measurement: “gallon/min”
    icon: “mdi:water”
    total:
    name: “Water Meter Total”
    unit_of_measurement: “m³”
    id: water_meter_total
    accuracy_decimals: 3
    device_class: water
    state_class: total_increasing
    filters:
    - multiply: 0.001

  • platform: template
    name: “Water Usage Gallon”
    id: water_flow_rate
    accuracy_decimals: 1
    unit_of_measurement: “l/min”
    icon: “mdi:water”
    lambda: return (id(water_pulse).state * 1);
    update_interval: 6s

Home Assistant config YAML
utility_meter:
util_water_usage_hourly:
source: sensor.water_total
cycle: hourly
util_water_usage_daily:
source: sensor.water_total
cycle: daily
util_water_usage_monthly:
source: sensor.water_total
cycle: monthly
util_water_usage_yearly:
source: sensor.water_total
cycle: yearly

I’ve made the watermeter with a AZ Delivery esp32 wroom 32 ESP-32 Dev Kit C az-delivery.de – AZ-Delivery

I use GPIO19 and adjusted it in the sensor code. All goes well to install but i get no readings at all. The sensor is not yet installed on my watermeter but i try to trigger it with a small magnet. But nothing comes up.

This is my ESPhome code

esphome:
  name: water-meter

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "eXAznB37EbPYrtcuV91/PNpFv6JdIbYGQy3wMx03380="

ota:
  password: "b4dc7b21d89dc9a16ecede0d0f5555db"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

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

captive_portal:

sensor:
  - platform: pulse_counter
    pin: GPIO19
    update_interval : 6s
    name: "water pulse"
    id: water_pulse

  - platform: pulse_meter
    pin: GPIO19
    name: "Water Pulse Meter"
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Total"
      unit_of_measurement: "liter"

  - platform: pulse_meter
    pin: GPIO19
    name: "Water Pulse Meter"
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Meter Total"
      unit_of_measurement: "m³"
      id: water_meter_total
      accuracy_decimals: 3
      device_class: water
      state_class: total_increasing
      filters:
        - multiply: 0.001

  - platform: template
    name: "Water Usage Liter"
    id: water_flow_rate
    accuracy_decimals: 1
    unit_of_measurement: "l/min"
    icon: "mdi:water"
    lambda: return (id(water_pulse).state * 10);
    update_interval: 6s
    

I have a Sensus model PMM MJ. I cannot get the pulse meter to pulse.

1 Like

How do you power the ESP board? I read the article from @pbrink but I don’t see how to provide power. I am totally new to this ESP thing. Is it using battery? Special power supply? How do you do that?

Usually a USB cord. I tried running one off a cheap 4-AA battery box with USB output, and it didn’t last a full day. I know there are all kinds of power-saving and sleep features, maybe that would extend the time, but I have yet to find an application where that’s effective.

1 Like

Indenting line 15 till 28 will solve your problem

Solar and battery might be an option otherwise a long USB cable to nearest power source. I’m looking into this aswell (Aus) but is there any regulation when it comes to covering the numbers for the inspections (meter readers)?

Thanks @MJV !

This solves the “mapping values are not allowed here” error, which is still in the script that @pbrink has on his website.

Hello all !

I’ve been following the guide on how to install this proximity sensor to monitor my water consumption.
Everything is working fine expect the pulse_counter

When water is running, is get correct values for

  • sensor.esphome_water_pulse_meter
  • sensor.esphome_water_meter_total

But nothing from the 3 others sensors.

Everything is exactly like the configuration on head of this article. I followed instructions from pieterbrinkman’s blog.

The ESP8266 is powered by USB but I also tried via pins and it wasn’t better.

Is there something i’m doing wrong ?

Thank’s in advance for the help you will provide.

Leor

Did you ever get this to work? I have the same meter and I wasn’t able to get it to register the pulses. Where did you place the sensor?

1 Like

My installation is fresh new, I just completed the build yesterday.
I never get the pulses to work, that’s why I came here, on the original post.

Here is a picture of how I installed the sensor :

I did not, I could never get the sensor to register anything no matter where it was placed. Oddly, I have a flume and it detects it fine.

1 Like

Yeah, you need to be way up close to the magnet and I think the plexiglass is just to far away to register. Pity, I thought you found a solution. Oh well, looks like it’s AI on the edge for me

1 Like

Good day,

I am trying to install a water meter as well, so far progress as expected. But struggeling with some code. Using the code as in this topic, why is the “Water Pulse Meter” sensor doubled in the code? Could anybody explain me that, thanks. JJ

  • platform: pulse_meter
    pin: 21
    name: “Water Pulse Meter”
    unit_of_measurement: “liter/min”
    icon: “mdi:water”
    total:
    name: “Water Total”
    unit_of_measurement: “liter”

  • platform: pulse_meter
    pin: 21
    name: “Water Pulse Meter”
    unit_of_measurement: “liter/min”
    icon: “mdi:water”
    total:
    name: “Water Meter Total”
    unit_of_measurement: “m³”
    id: water_meter_total
    accuracy_decimals: 3
    device_class: water
    state_class: total_increasing
    filters:
    - multiply: 0.001