Categories
homeautomation power

ESP32 Water and Gas Utility Meter

The recent release of Home Assistant’s energy dashboard inspired me to restore my gas and water utility meter monitors. I lost the measurements when I removed my Brultech GreenEye energy meters in favor of Sense energy monitors.

To recap, my local city and utilities do not allow any connections in any form to their utility meters, but I am allowed to install my own meters downstream, as long as the meter models are approved for local use, i.e. the exact same model as used by the local utilities. I installed the same model water and gas meters as used by the utilities but with dry-contact metering.

I already have a couple ESP32/8266 devices in my home, so I built a ESP32 based counter integrated with HA using ESPHome. I used a ESP32-DevKitC-32UE variant of the ESP32, because that’s what I had on hand, with a transparent waterproof case with two grommets, an external antenna, and solder-protoboard. Really any ESP32-WROOM-32 and case and protoboard should work. I used a 5V PSU with a switch, cutting the MicroUSB plug off and feeding it through the grommet into the case. I fed the shielded twisted pair wire from the meters through the other grommet. I connected power and sensor wires using spring terminal blocks, and added an LED. No other components are needed, the reed switches are pulled high by the ESP32, and pulled to ground when closed.

Below are pictures of the finished case and the utility meters:

The ESPHome code uses the pulse_meter sensor, with the total sensor being measured by the HA utility_meter integration. The sensor produces flow rate measurements and incrementing absolute consumption, and it is the consumption, not flow rate, that is needed for the utility meter integration.

ESPHome:

sensor:
  - platform: pulse_meter
    pin:
      number: GPIO32
      mode: INPUT_PULLUP
    unit_of_measurement: 'gal/min'
    name: 'Water Meter'
    icon: 'mdi:water'
    filters:
      - multiply: 10
    total:
      name: 'Water Meter Total'
      icon: 'mdi:water'
      unit_of_measurement: 'gal'
      filters:
      - multiply: 10
  - platform: pulse_meter
    pin:
      number: GPIO33
      mode: INPUT_PULLUP
    unit_of_measurement: 'ft³/min'
    name: 'Gas Meter'
    icon: 'mdi:fire'
    filters:
      - multiply: 10
    total:
      name: 'Gas Meter Total'
      icon: 'mdi:fire'
      unit_of_measurement: 'ft³'
      filters:
      - multiply: 10

Home Assistant:

utility_meter:
  daily_water_total:
    source: sensor.water_meter_total
    cycle: daily
  monthly_water_total:
    source: sensor.water_meter_total
    cycle: monthly
  daily_gas_total:
    source: sensor.gas_meter_total
    cycle: daily
  monthly_gas_total:
    source: sensor.gas_meter_total
    cycle: monthly

HA Dashboard:

The HA energy dashboard currently only tracks power, but I hope other measurements would be added over time.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.