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

which ESPHome YAML code is the most current in 2024?
when using the code form: Build a cheap water usage sensor using ESPhome and a proximity sensor - PieterBrinkman.com doesnt work anymore

1 Like

I recently used this one: https://github.com/geertmeersman/energie-meter/
I used a Wemos D1 clone as I already had it.
I dont have a gas meter, so left that one out.
Also, in the utility meter yaml example you need to specify the ESPhome sensor, not “sensor.water_used”.
After calibrating, works like a charm!

image

1 Like

@rda great, can you show me the yaml config for esphome.

And how dou you count the actual value of the watermeter?

Is it possible with this watermeter (M120 Elster I guess)

I got LJ18A3-8-Z/BX NPN?

I have a Badger Meter 62584-020 Recordall Transmitter Register.
Data sheet suggests magnetic (metal) disk nutates to transfer to other magnetic disk…etc
It detects metal, the copper pipes, the metal to the frame of my desk…etc.

But couldnt for the life of me figure out where the sensor/disk was. Is it possible the disk is not metal/magnetic? the Glass/plastic isnt as thick as I feared and was really really hoping this would work as my water bill spiked huge last bill and was hoping to get independent monitoring to corraborate and troubleshoot?

Do I possibly need the PNP one instead?

If this doesnt work, what other use cases can I repurpose this sensor???

1 Like

I uave a question on this.
I have a meter with 1 pulse per gal and its counts the gallons correctly, but the gallons per minute do just show 1 x 12 gal/min and then nothing again while water is running. And still counting the gallons up.
Here my code:

sensor:
  - platform: pulse_counter
    pin:
      number: GPIO14
      inverted: true
      mode:
        input: true
        pullup: true
    name: "${upper_devicename} Flow"
    unit_of_measurement: "gal/min"
    icon: "mdi:water"
    update_interval: 5s
    accuracy_decimals: 0
    internal_filter: 400ms
    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    filters:
      - lambda: return (x);
    total:
      name: "Total Water Consumption"
      unit_of_measurement: "gal"
      device_class: water
      state_class: total_increasing
      accuracy_decimals: 0
      icon: "mdi:faucet"

Is there anything obvious that i am doing wrong?
Thx gor any thoughts

Sorry for the late reply, missed the update I think.

Here is the code for watermeter.yaml:

packages:
  base: !include common/base.yaml
  base_global: !include common/base_global.yaml
  
substitutions:
  device_name: watermeter
  device_name_short: watermeter
  friendly_name: "Water Meter"
  esp_type: "ESP8266"
  impulsfactor_water: "0.001"
  impulsfactor_gas: "0.01"
  update_interval: 60s
  update_interval_sensor: 10s
  
esphome:
  name: ${device_name}
  friendly_name: ${friendly_name}
#  platform: ESP32
#  board: esp32dev
#  platformio_options: 
#    platform: espressif32
#    board: az-delivery-devkit-v4
#    board_build.mcu: esp32
#    board_build.f_cpu: 240000000L

esp8266:
  board: d1_mini
  framework:
    version: recommended

# # Enable logging
# logger:

# # Enable Home Assistant API
# api:
#   encryption:
#     key: "J4aOHwwXt4GpYe9w5gsjq6IzVtQuwvVlJLxtuq7LEwQ="

# ota:
#   password: "44699917877381d973c90764f474624f"

# wifi:
#   ssid: !secret wifi_ssid2
#   password: !secret wifi_pwd2

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

# captive_portal:
    

globals:
  - id: total_pulses_gas
    type: int
    restore_value: false
    initial_value: '0'
  - id: total_pulses_water
    type: int
    restore_value: false
    initial_value: '0'

binary_sensor:
  - platform: gpio
    id: internal_pulse_counter_water
    pin: GPIO2
    internal: true
    filters:
      - delayed_on: 100ms
    on_press:
      then:
        - lambda: id(total_pulses_water) += 1;

sensor:
  - platform: template
    name: "Water used"
    device_class: water
    unit_of_measurement: "m³"
    state_class: "total_increasing"
    icon: "mdi:water"
    accuracy_decimals: 3
    update_interval: ${update_interval_sensor}
    lambda: |-
        return id(total_pulses_water) * ${impulsfactor_water};

I did not change the common yaml files from the repository other than refering to my own secrets.

Seems like it, you have one with the metal plate, so try if the sensor led blinks if you hold the sensor above that one.

I thikn that if there is a metal disk, it would be deep inside, where an external sensor would not detect it. Also, it seems like this meter already has a digital output? Can’t you use that insted? Or search the web for an optical sensor solution which can detect the digits or other indicators on this meter.

I was hoping to find a comprehensive list of water meters that worked with this and also the placement of the sensor. I found several mentions of meters that it didn’t work on but also didn’t seem to be any replies as to how to make it work if at all. Apparently my meter (Elster C700) doesn’t. The manufacturer says this is an “oscillating piston type” but also says “The movements of the hub are sensed through the flow meter wall by a follower magnet”.
The small triangle spins rapidly when water is flowing and the needle moves more slowly. I tried placing the sensor near the triangle and also in every position around the dial - especially the needle. Can anybody corroborate that this is correct or that I’m wrong? If I’m wrong, where do I place the sensor? Thanks

According to Google AI, Flume uses a “patented technology to detect water usage by reading the magnetic field of a home’s water meter. Most water meters have a spinning magnetic disc, and the speed of its rotation corresponds to the amount of water being used. The Flume sensor measures the disc’s magnetic field and sends the data to a bridge using RF wireless technology. The bridge then uses Wi-Fi to send the data to the cloud, where it can be accessed through a mobile app”
So same concept but somehow “patented”. I was thinking possibly it sends a signal and reads the response - like sonar - since it suppoosedly can read to .01 gallons. My meter has a small wheel that rotates at .1 gallons per revolution (I think)

Hello Pieter,

When i copy/paste your code I get thé followîng when trying to install. Note i’m using q d1 mini.

Hi @familiedkrul , I had the same.
Because of a change in ESPhome about ‘listing’ it is now more strict to how you line up the lines and indents.
‘-Platform…’ start from the beginning of the line with 1 space in front.
The next lines have 3 spaces. And when adding another list inside add an extra space(4 and on) in front of that.
In another post I tried to paste the exact code, but the forum software just ruins it. Also when using the ‘code’. But I will try it again here;

sensor:
 - platform: pulse_counter
   pin:
    number: GPIO12
    allow_other_uses: true
   update_interval : 6s
   name: "water pulse"
   id: water_pulse

 - platform: pulse_meter
   pin:
    number: GPIO12
    allow_other_uses: true
   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: GPIO12
    allow_other_uses: true
   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

@pbrink , thanks for the ideas and input to get starting.
Instead of an LJ18A3-8Z/BX I got an LJ12A3-4-Z/BX. Although the first one is mentioned to run from 5V Input, looking at the datasheet it still mentions 6-36V, just like the latter.
Anyway. Both seem to run on 5V, while my red led does blinks when the watermeter iron arrow passes.
In your blog post you say you don’t needed any resistores, leds, conductors or voltage regulators. But the ESP8266 allow 3.3 to max 3.6V input on it’s GPIO pins. Dit you connect the black wire straight to the GPIO?
If not, can you share what you used? There are so many options I have seen.

More people having troubles to get the “pulse counter” part to work ?
The piece "Water Pulse Meter"is working fine, but the pulse counter stays on 0.

here’s the code i use:


substitutions:
  name: meterkast
  friendly_name: "Meterkast"
  
esphome:
  name: meterkast
  platform: ESP8266
  board: d1_mini
#  on_boot:
#    priority: -10
#    then:
#    - script.execute: publish_states
# Enable logging
logger:
# Enable Home Assistant API
api:
  id: api_apiserver
#  services:
#    - service: meterstand_water
#      variables:
#        meter_value: float
#      then:
#        - globals.set:
#            id: initial_water_usage
#            id: totalWaterUsage
#            value: !lambda "return ( meter_value ) ;"
ota:
    - platform: esphome


one_wire:
    - platform: gpio
      pin: GPIO14


wifi:
  ssid: !secret SSID
  password: !secret WiFi_Password
  fast_connect: true
#  use_address: watermeter.local
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Watermeter Fallback Hotspot"
    password: "4Ejkhjkhuixa4M"
captive_portal:




sensor:
  - platform: pulse_counter
    pin: 
      number: GPIO04
      allow_other_uses: true
    update_interval: 6s
    name: "water pulse"
    id: water_pulse
  - platform: pulse_meter
    pin: 
      number: GPIO04
      allow_other_uses: true
    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
    device_class: water





  - platform: dallas_temp
    address: 0x8E0416C005A0FF28
    name: "Temperatuur meterkast"
  - platform: dallas_temp
    address: 0x730416381E33FF28
    name: "Temperatuur in serverkast"

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO12
      mode: INPUT_PULLUP
      inverted: True
    device_class: window
    name: "deurbel"  
  - platform: gpio
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
    name: "meterkast open-dicht"
    device_class: door
    internal: true

web_server:
  port: 80
1 Like

Hey guys,

thanks for this great and insightful thread and initial explanation / setup @pbrink

I own the following Meter: Maddalena DS TRP series (model number TCM 142/08-4604).

It actually lists an accessory called reed switch TRP (REED SWITCH TRP - PULSER), which means that it should have a magnet somewhere reporting a pulse, however I have not been able to read any pulses neither with a simple reed switch or the LJ18A3-8Z/BX proximity sensor. The simple reed switch and the sensor have worked on magnets / metallic surfaces, however it doesnt seem to work on the water meter.

Do you guys have any idea / hint? I mean worst case I can buy the official accessory, but since I had all the other items lying around I thought I would give it a try :slight_smile:

Thanks
Seb