Problems reading meter in home automation system (Home Assistant) using ESP32 board

Forum is open to all questions, answers, and discussions related to water meters, ours or others.
Post Reply
twyche
Posts: 2
Joined: Sun Feb 19, 2023 9:45 pm

Problems reading meter in home automation system (Home Assistant) using ESP32 board

Post by twyche »

I’m trying to connect a water meter my home automation system (Home Assistant) using a ESP32 board, but Home Assistant is showing continuous pulses from the water meter that are obviously wrong.

Setup:

Water meter - EKM SPWM-100-NSF

ESP32 board - MELIFE ESP-32S . See pinout in attached picture.

ESPHome yaml file:

Code: Select all

sensor:
  - platform: uptime
    name: "${esphome_name}_Uptime Sensor"
    
  - platform: wifi_signal
    name: "${esphome_name} WiFi Signal"
    update_interval: 60s

  - platform: pulse_counter
    pin:
      number: 4
      inverted: true
      mode:
        input: true
        pullup: true
    update_interval: 6s
    name: "water pulse"
    id: water_pulse

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

  - platform: pulse_meter
    pin: GPIO4
    name: "Water Pulse Meter"
    unit_of_measurement: "gallons/min"
    icon: "mdi:water"
    total:
      name: "Water Meter Total"
      unit_of_measurement: "ft³"
      id: water_meter_total
      accuracy_decimals: 3
    device_class: water
    state_class: total_increasing
    filters:
      - multiply: 0.748052
      
  - platform: template
    name: "Water Usage Gallons"
    id: water_flow_rate
    accuracy_decimals: 1
    unit_of_measurement: "Gallons/min"
    icon: mdi:water
    lambda: return (id(water_pulse).state * 10);
    update_interval: 6s  
I’m powering the ESP32 board with a USB cable and put together two mini breadboards to make the temporary connections while I’m testing this out. I’ve tried using the GND and GPIO4 pins on the right side of the board. I’ve also tried the GND and GPIO14 pins on the left side of the board. In both cases I get continuous pulses even with all the water in the house turned off and our well pump is not running.

Attached is a picture of the connections with the two wires from the water meter connected to jumper wires through Wago connectors:


Here is a log file from the ESP32:

Code: Select all

INFO Reading configuration /config/esphome/basement_esp32.yaml...
WARNING 'basement_esp32': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
INFO Detected timezone 'America/Denver'
WARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Starting log output from basement_esp32.local using esphome API
INFO Successfully connected to basement_esp32.local
[19:46:08][I][app:102]: ESPHome version 2023.2.2 compiled on Feb 19 2023, 16:31:02
[19:46:08][C][wifi:504]: WiFi:
[19:46:08][C][wifi:362]:   Local MAC: [redacted]
[19:46:08][C][wifi:363]:   SSID: [redacted]
[19:46:08][C][wifi:364]:   IP Address: 192.168.1.160
[19:46:08][C][wifi:366]:   BSSID: [redacted]
[19:46:08][C][wifi:367]:   Hostname: 'basement_esp32'
[19:46:08][C][wifi:369]:   Signal strength: -74 dB ▂▄▆█
[19:46:08][C][wifi:373]:   Channel: 11
[19:46:08][C][wifi:374]:   Subnet: 255.255.255.0
[19:46:08][C][wifi:375]:   Gateway: 192.168.1.1
[19:46:08][C][wifi:376]:   DNS1: 192.168.1.1
[19:46:08][C][wifi:377]:   DNS2: 0.0.0.0
[19:46:08][D][sensor:127]: 'Water Pulse Meter': Sending state 6411.87451 gallons/min with 2 decimals of accuracy
[19:46:08][D][sensor:127]: 'Water Meter Total': Sending state 7069.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][logger:293]: Logger:
[19:46:09][C][logger:294]:   Level: DEBUG
[19:46:09][C][logger:295]:   Log Baud Rate: 115200
[19:46:09][C][logger:296]:   Hardware UART: UART0
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7079.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7085.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][switch.gpio:076]: GPIO Switch 'basement_esp32-Onboard-LED'
[19:46:09][C][switch.gpio:084]:   Inverted: YES
[19:46:09][C][switch.gpio:099]:   Restore Mode: restore defaults to OFF
[19:46:09][C][switch.gpio:031]:   Pin: GPIO2
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7095.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][uptime.sensor:031]: Uptime Sensor 'basement_esp32_Uptime Sensor'
[19:46:09][C][uptime.sensor:031]:   Device Class: 'duration'
[19:46:09][C][uptime.sensor:031]:   State Class: ''
[19:46:09][C][uptime.sensor:031]:   Unit of Measurement: 's'
[19:46:09][C][uptime.sensor:031]:   Accuracy Decimals: 0
[19:46:09][C][uptime.sensor:031]:   Icon: 'mdi:timer-outline'
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7105.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][template.sensor:023]: Template Sensor 'Water Usage Gallons'
[19:46:09][C][template.sensor:023]:   State Class: ''
[19:46:09][C][template.sensor:023]:   Unit of Measurement: 'Gallons/min'
[19:46:09][C][template.sensor:023]:   Accuracy Decimals: 1
[19:46:09][C][template.sensor:023]:   Icon: 'mdi:water'
[19:46:09][C][template.sensor:024]:   Update Interval: 6.0s
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7113.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][homeassistant.time:010]: Home Assistant Time:
[19:46:09][C][homeassistant.time:011]:   Timezone: 'MST7MDT,M3.2.0,M11.1.0'
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7119.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][restart:076]: Restart Switch 'basement_esp32-restart'
[19:46:09][C][restart:078]:   Icon: 'mdi:restart'
[19:46:09][C][restart:099]:   Restore Mode: restore defaults to OFF
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7126.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][pulse_counter:160]: Pulse Counter 'water pulse'
[19:46:09][C][pulse_counter:160]:   State Class: 'measurement'
[19:46:09][C][pulse_counter:160]:   Unit of Measurement: 'pulses/min'
[19:46:09][C][pulse_counter:160]:   Accuracy Decimals: 2
[19:46:09][C][pulse_counter:160]:   Icon: 'mdi:pulse'
[19:46:09][C][pulse_counter:161]:   Pin: GPIO4
[19:46:09][C][pulse_counter:162]:   Rising Edge: INCREMENT
[19:46:09][C][pulse_counter:163]:   Falling Edge: DISABLE
[19:46:09][C][pulse_counter:164]:   Filtering pulses shorter than 13 µs
[19:46:09][C][pulse_counter:165]:   Update Interval: 6.0s
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7145.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][pulse_meter:074]: Pulse Meter 'Water Pulse Meter'
[19:46:09][C][pulse_meter:074]:   State Class: 'measurement'
[19:46:09][C][pulse_meter:074]:   Unit of Measurement: 'gallons/min'
[19:46:09][C][pulse_meter:074]:   Accuracy Decimals: 2
[19:46:09][C][pulse_meter:074]:   Icon: 'mdi:water'
[19:46:09][C][pulse_meter:075]:   Pin: GPIO4
[19:46:09][C][pulse_meter:077]:   Filtering rising edges less than 13 µs apart
[19:46:09][C][pulse_meter:081]:   Assuming 0 pulses/min after not receiving a pulse for 300s
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7155.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][pulse_meter:074]: Pulse Meter 'Water Pulse Meter'
[19:46:09][C][pulse_meter:074]:   Device Class: 'water'
[19:46:09][C][pulse_meter:074]:   State Class: 'total_increasing'
[19:46:09][C][pulse_meter:074]:   Unit of Measurement: 'gallons/min'
[19:46:09][C][pulse_meter:074]:   Accuracy Decimals: 2
[19:46:09][C][pulse_meter:074]:   Icon: 'mdi:water'
[19:46:09][C][pulse_meter:075]:   Pin: GPIO4
[19:46:09][C][pulse_meter:077]:   Filtering rising edges less than 13 µs apart
[19:46:09][C][pulse_meter:081]:   Assuming 0 pulses/min after not receiving a pulse for 300s
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7166.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][mdns:108]: mDNS:
[19:46:09][C][mdns:109]:   Hostname: basement_esp32
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7170.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][ota:093]: Over-The-Air Updates:
[19:46:09][C][ota:094]:   Address: basement_esp32.local:3232
[19:46:09][C][ota:097]:   Using Password.
[19:46:09][W][ota:103]: Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7178.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][api:138]: API Server:
[19:46:09][C][api:139]:   Address: basement_esp32.local:6053
[19:46:09][C][api:143]:   Using noise encryption: NO
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7186.00000 ft³ with 3 decimals of accuracy
[19:46:09][C][wifi_signal.sensor:009]: WiFi Signal 'basement_esp32 WiFi Signal'
[19:46:09][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[19:46:09][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[19:46:09][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[19:46:09][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7194.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7198.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7201.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7204.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7206.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7209.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7214.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7218.00000 ft³ with 3 decimals of accuracy
[19:46:09][D][sensor:127]: 'Water Meter Total': Sending state 7224.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7228.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7234.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7238.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7242.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7246.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7250.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7254.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7258.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7263.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Pulse Meter': Sending state 0.00000 gallons/min with 2 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Meter Total': Sending state 7267.00000 ft³ with 3 decimals of accuracy
[19:46:10][D][sensor:127]: 'Water Pulse Meter': Sending state 5610.39014 gallons/min with 2 decimals of accuracy

Can someone help me figure out why I’m getting continuous pulses from this setup?

Thank you for your help.
Attachments
20230219_143436.jpg
20230219_143436.jpg (353.55 KiB) Viewed 25026 times
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Problems reading meter in home automation system (Home Assistant) using ESP32 board

Post by Jameson »

Hello Twyche, cool project!! (thanks for the pic!)

The water meter has a tiny reed switch in it. The reed switch closes once per revolution of the magnetic dial on the water meter. This is very similar to just touching 2 wires together. What result do you get on your ESP32 if you replace the water meter pulse output with 2 wires and then touch the 2 wires together 10 times?

You can also test the water meter pulse output with a handheld multimeter. Just look for continuity between the pulse output wires of the water meter (you should hear an audible beep for each revolution of the magentic dial on the water meter).

Are you saying that even when your water meter magnetic dial is turning, that you always have continuity? What is the voltage and amperage of your pulse counting circuit? You want to limit the pulse counting circuit of your ESP32 to no higher than 20mA and 24V.
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
twyche
Posts: 2
Joined: Sun Feb 19, 2023 9:45 pm

Re: Problems reading meter in home automation system (Home Assistant) using ESP32 board

Post by twyche »

Thank you for responding.

I changed out the original power supply to the ESP32 board. Now everything seems to be working well. I don't know if there was too much current, not enough or maybe the original power supply was providing dirty power.

I'll do testing later to better understand how this all works and what was wrong with my original setup that was showing multiple pulses per second even when there was no water flowing through the meter.
Post Reply