Help Required - Analog Dial 'Dumb' Gas Meter Monitor (for a 1991 UGI Gas Meters Ltd analog meter)

Hi Will,

I used the ESPHome add-on for HA. I don’t know if you are familiar with ESPHome, but it is a fantastic way to create custom sensors for your Home Assistant setup. I bought some ESP32 WiFi/Bluetooth-enabled microcontrollers from Amazon and used these with other sensors to feed back into HA. You upload code etc to the ESP32 module using the ESPHome add-on. Sounds complicated, but it isn’t really in practice. If I can do it, anybody can! :roll_eyes:

BTW I added a few more thoughts to your initial post on the thread you created earlier.

Cheers,

Mike.

1 Like

I currently have a couple of Kauf bulbs, a couple of Kauf plugs, and a couple of Athom plugs, so have an exposure to ESPHome (and have updated .yaml files, etc), so that’s one very interesting option. Thanks for the tip!

1 Like

I have the exact same gas meter as you, except mine is from 1986 :slight_smile:

I am probably going to try to reproduce your set up, except I will use C++ and a RPi Pico because I prefer to work with that.

Your problem of turning the analog signal into a series of events is a standard signal processing task. Typically you would simply low pass filter the signal and look for maximums (peaks). This is pretty much identical to the solution you found.

Do you have any advice on sensor positioning and mounting? And approximately how fast does the dial turn at maximum? (Thinking about how often I need to sample in order to never miss rotations.)

edit: I’ve been reading up about gas meters and the one we have is called “U6 UGI Black Spot”. Apparently these are known for over-reporting.

Hi Alistair,

Congrats on your “choice” of gas meter!!! :laughing:

In answer to your questions on positioning, see attached photo of where the sensor is located on mine. The red circles I have drawn on are the IR Tx & Rx LED’s… I tried to get them at the 3 O’clock position as this would still enable me to read the meter in order to check the reliability of the logging. (so far, it’s not missed a beat!) and also, on the clear plastic faceplate there is a small, raised perimeter upstand which prevented the 3D-printed sensor housing from moving further over to the right.

Regarding the speed of dial turning… here is a screen grab of the voltage peaks when the burner is on full. You should be able to work out the peak to trough time from the timings logged at the bottom of the graph. I get it to be about 5 or 6 seconds, assuming each step is about two seconds.

I hope that helps, and do feel free to shout up if you need further info - more than happy to help where I can! :+1:t2:

Cheers,

Mike.

1 Like

Are you not using the built in energy dash on HA? I’m trying to work out how to add costs for my meter but need to convert it to kWh first from ft3.

Hi,
Yes, I use the HA Energy Dashboard in addition to my own custom, “at a glance” dashboard.

If using the HA Energy Dashboard it will automatically convert from ft3 into m3, but when you add costs you have to calculate the cost per m3 of gas for it to accurately reflect your usage, although here in UK we get charged by the kWh (this is also another reason why I designed my own dashboard).

In order to get kWh and Cost I put some additional yaml ‘sensors’ in my configuration file to calculate these. If you want me to post the yaml for these, let me know.

Cheers,

Mike

Hi Mike,

Yes please, if you wouldn’t mind!

Morning…

I created a number of 'Helper ’ Meters to track various elements of gas usage and cost, so their results could be shown in my custom dashboard… some of these I did after putting the new yaml code into the configuration file.


Note: The one which says just “Gas Meter” tracks the actual meter reading, and is easy to calibrate by pasting the following into the Developer Tools > Services section of HA and then hitting the ‘Call Service’ button.

service: utility_meter.calibrate
target:
  entity_id: sensor.gas_meter #Change this to your Gas Meter Reading helper sensor
data:
  value: '199870' #Change this to your meter reading

The yaml code for the various other sensors is noted below…


      - name: "Daily Gas Consumption kWh"
        unique_id: daily_gas_usage_kwh
        state: "{{ ((((states('sensor.gas_consumption_daily_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6)|round(2) }}"
        availability: "{{ states('sensor.gas_consumption_daily_v2')|is_number }}" 
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total

      - name: "Daily Gas Cost"
        unique_id: daily_gas_cost
        state: "{{ (((((states('sensor.gas_consumption_daily_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6) * 0.09835)|round(2) }}"
        availability: "{{ states('sensor.gas_consumption_daily_v2')|is_number }}" 
        unit_of_measurement: "£"
        device_class: monetary
        state_class: total
  
      - name: "Weekly Gas Consumption kWh"
        unique_id: weekly_gas_usage_kwh
        state: "{{ ((((states('sensor.gas_consumption_weekly_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6)|round(2) }}"
        availability: "{{ states('sensor.gas_consumption_weekly_v2')|is_number }}" 
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total

      - name: "Weekly Gas Cost"
        unique_id: weekly_gas_cost
        state: "{{ (((((states('sensor.gas_consumption_weekly_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6) * 0.09835)|round(2) }}"
        availability: "{{ states('sensor.gas_consumption_weekly_v2')|is_number }}" 
        unit_of_measurement: "£"
        device_class: monetary
        state_class: total

      - name: "Monthly Gas Consumption kWh"
        unique_id: monthly_gas_usage_kwh
        state: "{{ ((((states('sensor.gas_consumption_monthly_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6)|round(2) }}"
        availability: "{{ states('sensor.gas_consumption_monthly_v2')|is_number }}" 
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total

      - name: "Monthly Gas Cost"
        unique_id: monthly_gas_cost
        state: "{{ (((((states('sensor.gas_meter_monthly_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6) * 0.09835)|round(2) }}"
        availability: "{{ states('sensor.gas_meter_monthly_v2')|is_number }}" 
        unit_of_measurement: "£"
        device_class: monetary
        state_class: total

Obviously, you will need to change the sensor names to match your existing sensor names, or it won’t work!!

As you can see above the kWh conversion use the ‘standard’ conversion from ft3 to kWh as is printed on UK gas bills… the only items which are liable to change are the calorific value of the gas, the 39.9 figure. This is an average of the calorific values from my last 12 months’ gas bills, so will give a very close approximation to the amount used, but it won’t be to the penny.

Also on the costs… the last number in the ‘state’ line of yaml (0.09835 in my case) is the cost per kWh of gas from your gas Co in pence, and you will need to change it to match your cost per kWh from your recent gas bill… additionally, do bear in mind that this would also need to change when they increase their kWh costs too (very unlikely it will ever reduce :roll_eyes: - but we’ll not get into that bone of contention eh?)

The other thing I haven’t got around to doing is adding the Daily Standing Rip-Off Charge, and then tax at 5%… it’s an easy amendment to the yaml code to achieve this.

I hope this helps and is useful in creating your own custom dashboard :+1:t2:

Cheers,

Mike.

1 Like

That’s great, thank you.

I have followed this, and your other thread, and have built and installed it, but am unsure about the pin connections / GPIO between the TCRT5000 and ESP32. Can you advise please?

Hi,
Apologies for the delay, I’ve been on holiday for a few days!

I’m using GPIO32 on the ESP32 (you will see this noted in the yaml code at the beginning of this thread) this pin uses a built-in ADC on the ESP32 and has the name “Gas Meter Analog Value”. It reports back the voltage that the IR sensor is sending out. This voltage will vary according to what is under the IR LED’s.

There could be either three or four pins on your TCRT5000, there are 4 on mine. They should be positive and negative power feeds to power the IR sensor, both of these are taken from “+3.3V” on the ESP32 and the “Gnd” connection on the ESP32. The other remaining outputs on the TCRT5000 are a digital output and an analogue output and are marked accordingly, AO for analogue output and DO for digital output. Just ignore the digital output as it is of no use to us, and connect the Analogue Output (AO) pin to GPIO32 of the ESP32 - this will feed the varying voltage output from TCRT5000 into the ESP32.

That is pretty much all there is to connect, just three pins +ve, -ve and AO

Just shout if you need any more assistance. :+1:t2:

Cheers,

Mike