Git Product home page Git Product logo

gas-meter-esphome's Introduction

Gas Meter Sensor

This project implements a cheap and easy way to read out meter pulses from the Pipersberg G4 RF1 c gas meter via an Espressif ESP8266 micrcontroller and a PL-05N proximity sensor. The meter reading can be calculated and stored locally and used by a Home Assistant instance using ESPHome.

Prerequisites

Hardware

The following hardware is needed to implement this project

  • ESP8266 NodeMCUv3 (or similar, e.g. Wemos D1)
  • PL-05N NPN Contact DC Proximity Sensor Switch
    • Alternative: LJ12A3-4-Z/AY, but needs more space in front of gas meter. See NOTE in sensor holder for a suitable holder.

Software / Infrastructure

  • Home Assistant running on a server
  • ESPHome running on a server

Sensor holder

The 3D printing files for the sensor holder can be found in the holder folder or on Thingiverse.

NOTE: The design is a remix of a sensor holder for LJ12A3-4-Z/AY.

Render of the holder

PL-05N Sensor holder for Pipersberg G4 RF1 c

Photos of real setup

PL-05N Sensor holder for Pipersberg G4 RF1 c PL-05N Sensor holder for Pipersberg G4 RF1 c

PL-05N Sensor holder for Pipersberg G4 RF1 c PL-05N Sensor holder for Pipersberg G4 RF1 c

Wiring

The cable colors of (inductive) sensors, seem to deviate from the standard colors, especially with blue for GND and brown for (VIN) power supply. Please connect the sensor to the NodeMCU v3 as follows.

ESP8266 NodeMCU v3 PL-05N
VIN (5V) brown
GND blue
A0 (Analog) black

Wiring diagram

NOTE: The PL-05N is rated for input voltages from 10V to 30V. However, I found that it is working perfectly fine with the 5V voltage supply sketched above. If in doubt, please add a buck-boost converter to the brown cable to reach 10V.

Software

In the following sections, the software setup will be described.

ESPHome Sensor

One of the easiest ways to connect an ESP8266 to Home Assistant is using ESPHome. The basic firmware can be easily flashed from the browser connecting the device to the computer. Afterwards, the configuration can be easily updated over Wifi.

I am using

Please see the ESPHome configuration for PL-05N for all details.

NOTE: I tried using the GPIO binary sensor on a digital GPIO pin before but encountered a lot of misreadings. Even with different pullup and filters using delayed_on I was not able to fix them. Please check the esphome logs, in case of misredings.

Example esphome log file

...
[09:26:48][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.29883 V with 2 decimals of accuracy
[09:26:48][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.29883 V with 2 decimals of accuracy
[09:26:48][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.29883 V with 2 decimals of accuracy
[09:26:48][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
[09:26:48][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
[09:26:48][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
[09:26:49][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
...
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00098 V with 2 decimals of accuracy
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.00195 V with 2 decimals of accuracy
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.29590 V with 2 decimals of accuracy
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.29590 V with 2 decimals of accuracy
[09:26:51][D][sensor:093]: 'Internal pulse sensor voltage': Sending state 0.29590 V with 2 decimals of accuracy
...

Home Assistant

Home Assistant should automatically be able to find the new sensor when it is connected to the same network.

Conversion to energy and gas cost

To convert the gas meter reading in m³ to energy (kWh) and cost (€), please see packages/gas-meter.yaml.

Basically, the gas meter reading in m³ is converted to kWh via a factor which can be requested by the gas supplier or is part of the gas bill. The gas cost is calculated via the gas concumption in kWh multiplied by the gas price in €/kWh. The current gas price can be set via a input number.

Gas consumption statistics

With the meter reading in m³, kWh and € you can already use some basic built-in Home Assistant statistics. However, if you want to keep statistics for time frames such as yesterday, last week or last month, a bit more effort is needed.

See packages/gas_statistics.yaml for all details.

License

This project is under MIT license. See LICENSE.md.

gas-meter-esphome's People

Contributors

mspaehn avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.