Gas meter monitoring with Hall effect sensor

Hi all.

I'd like to monitor a gas meter with an emonTX. The gas meter has a rotating ring with a magnet as described here. See this thread for the pictures of the meter.

There seems to be two kinds of device to detect the magnet : the hall effect sensor and the reed switch. The reed switch has a bouncing issue the hall effect sensor does not. See this page,or this one for a comparison. There's a thread here discussing the bouncing issue and how to deal with it. Anyway, the page on gas meter monitoring suggests a hall effect sensor, which suits me.

I understand that all I need to do is get myself a sensor then, through a breakout board, solder it to a jack cable as indicated in the design reference. What about resistor R8 ? Should it be used or not ? It needs to be removed when using TSL257 optical sensor, but I didn't understand why.

I don't have the emonTX yet. I wanted to anticipate any hardware adaptation need before ordering the kit and doing the soldering. In fact, I expected more difficulties, but after all, as long as the sensor delivers a raising or falling edge to the IRQ pin, it shouldn't be different that the LED flashing counting.

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

R8: The data sheet says:  "Single open drain output."  If you look at the data sheet, you will see that it clearly shows a pull-up resistor to Vdd. If you look at the emonTx circuit diagram, you'll see R8 is a pull-down resistor, so it is in the wrong place and you must not have it.

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Thank you Robert for answering.

Electronics is definitely not my field. I've been doing a little bit of reading and I understand the role of the pull-up resistor.

Should I understand that if I use this sensor, I need to add a pull-up resistor somewhere between its output and Vcc (or the center contact of SJ1) ?

Or is there a property of the ATMega IRQ input pin that wakes that unneeded ?

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

I see you need to learn how to read and interpret data sheets ;-)

Correct, you need to remove R8.  A pull-up resistor instead is needed - between Vcc and the output pin as you again correctly say. Download the Atmel data sheet and look at Page 314. It states that there is an internal pull-up resistor with a value between 20 k and 50 k Ohms.

Download the RS data sheet and look beneath the diagram. It states "RL is the pull-up resistor, the recommended resistance is 10kOhm ~ 100kOhm."

So it is quite likely that the internal pull-up is sufficient.

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Hi Robert, and thank you for your reply. I didn't have time to look into it, hence the delay.

I did not understand how the port could have both a pull-up (internal) and a pull-down (on our board) resistor. You answer makes it clear : the pull-up is internal but optional and software controlled. I now realize this must be obvious for someone familiar with Arduino...

I found more info on this tutorial, as well as on the DigitalPins page of the Arduino reference and on the Arduino forum.

attachInterrupt(0, CountPulse, RISING);//turn on interrupt for flow sensor on pin 2
digitalWrite(2, HIGH);  //turn on pull up resistor for flow sensor on pin 2

It should be as simple as adding a digitalWrite(2, HIGH) in the setup() of emonTx_Pulse.ino. I would add it before the call to attachInterrupt(), though.

I ordered a kit a few days ago. Once I get it, I'll try to have the "reference" setup working, that is temperature and CT measuring. Then, I hope to try the gas monitoring.

Cheers.

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Hi.

I finally went into it.

I ordered a few hall effect sensors. I chose SS451A, from Honeywell. I got them from Farnell's. Those are omnipolar, as suggested in the doc, open drain and thru-hole, which makes them easier to use : no need for a breakout board.

I describe the connection and the test code on my profile.

The gas meter is an actaris g4 gallus 2000 (specs, installation guide).

I've been testing and unfortunately the rotation of the wheel is not detected.

A common fridge magnet triggers an interrupt, so I know the code works, but I don't detect anything from the gas meter. I've been trying several positions, and for each one I've been waiting for a complete round of the least significant digit wheel. Nothing.

Here's the magnet :

I tried several positions :

Even silly ones :

The spec seems to indicated the gas meter does have a magnet in the wheel, but it is likely that the sensor is not sensitive enough.

Indeed, the two sensor proposed on the gas monitoring page can be triggered by lower magnetic fields:

SS451A (mine):

SS451A

The two other sensors:

Basically, it takes about 100 Gauss for the SS451A to get triggered, and about 40 Gauss for the two others.

Should I try with a more sensitive sensor ? Or am I wrong about the magnet in the meter ?

Anyone has tried any other sensor with success ?

Does the sensor have to be omnipolar ?

I chose the SS451A for practical reasons: it is easier to connect (thru-hole) and it was available. I didn't find any other thru-hole omnipolar sensor, and I didn't find any other shop that would sell both one of the two SMT sensors above and a breakout board (I'd rather avoid ordering from two different shops, because ot the shipping costs).

I see people here using reed switches. I understand there are bouncing issues. Or perhaps are they using a hardware with debouncing included. For instance, the FLS02-F1, as seen here. For the price, I suppose it does debouncing. I don't mind paying 10€ for a sensor, but it would be nice to identify a cheap one the OEM shop could sell as an option to the TX (like the temp sensor).

Could the needed sensitivity vary depending o the gas meter ?

 

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

I have an Actaris meter and it does have a magnet in the fastest wheel - N is at 7.5 and S is at 2.5 (tested with a compass).

To try to get an estimate of the field strength, I put the compass in the centre of a rectangular coil measuring approx 35 x 45 mm and with 50 turns, and with approx 1 A flowing, it balanced the magnet in the meter at a distance of approx 15 mm from the window (meaning at ¾ A, it didn't reverse the needle and at 1½ A, it did).

I think that's about 10 mT (100 Gauss) according to here  [edit] but according to here and treating the coil a single turn carrying 50 A, it is about 1 mT (10 Gauss).

So if my estimates and the first reference is correct, your sensor should work, and if the second, it will not.

[Disclaimer: I was at the top of a stepladder balancing a power supply on the too narrow meter shelf and holding compass and coil in one hand, and twiddling the current limit knob with the other hand. The measurement may thus be a little imprecise.]

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Hi Robert. Thanks for answering.

Please don't try to take a picture of your experiment. You (supposedly) only have two arms, and I wouldn't like you to get hurt.

It took me a few readings but I think I understand what you mean. You're applying a magnetic field to your compass and you determine the maximum field the meter magnet can defeat.

I can't comment on the conclusions, but if the meter magnet only develops 1 mT (10 Gauss), then none of the other sensors would work anyway.

Where would you place the sensor ? I tried both on the front (window) and in the hole under the wheels (see pictures).

(I also wonder what that thing on the right of the wheels is. Looking at it I would expect a LED to flash from times to times, but this does not happen.)

 

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

My meter has the registers in a clear plastic box protruding from the front of the meter case (post above edited to add a picture), and the fastest wheel is accessible from underneath with a cut-away section that comes very close (about the same distance as the main window - 2 mm or so - from the wheel), so that's where I would put a sensor so as not to obscure the register. But in your case, it needs to be right in front of the wheel. As far as I know, there is no electricity of any sort in my meter, so I don't expect to see a LED.

If you have an ordinary (walkers) magnetic compass, you could at least tell whether there is a magnet there or not.

The principle of my test was to impose an equal but opposite magnetic field from the coil, so that the compass needle swung freely. That proved impossible in practice, so the best I could do was ramp up the current and note when the needle flipped, then ramp down the current and note when it flipped back. The 15 mm was the radius of the compass case, so the case was touching the window.

I don't have any experience of working directly with magnetic fields, I haven't got a feel for the numbers so I'd limit my comment on the conclusions to saying (1) that a more precise measurement is needed, (2) what I've done seems to indicate that you probably need the most sensitive detector that won't latch under the Earth's magnetic field (said to be about 0.5 Gauss) and any residual magnetism in the meter's metal case, and (3) something 20 or so times the Earth's field sounds not unreasonable.

I'm almost certain that the field strength will vary somewhat between examples of the same meter model, and even more between manufacturers.

[Edit]

Reading the data sheet on your sensor, it appears to say it might operate at 35 Gauss, but it requires 135 Gauss to guarantee operation; and it requires the field to fall to 10 Gauss to guarantee it will release.

fluppie007's picture

Re: Gas meter monitoring with Hall effect sensor

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Hi.

Thank you for your answers.

@fluppie007: Yes, I saw this one. As I said at the end of an earlier comment, I'd like to identify a cheap sensor that would work "everywhere". OEM could even re-sell in the shop. It would make a common setup for everyone, thus facilitating code sharing, and making it easier to obtain (all elements from the same shop).

Yet, I'd like my setup to finally work and it is not expensive. I posted on the forum to know if it would work.

@Robert: It might not be obvious from the pictures, but I have the same kind of hole under the wheel. And I don't think my meter is powered either.

My compass was at my office, but I checked with a compass application on a friend's phone, and the meter does move the "needle", so there definitely is something there. I also checked the water meter for the same conclusion: it has influence on the compass, but does not trigger the hall effect sensor. (This time, I was myself in turn in a precarious position, so I wouldn't swear it does not work, but I'm pretty sure.)

It is a bit more difficult than I expected, as the sensor needs not only to get triggered by the magnet when this one passes by, but also to get released when the wheel turns. As you pointed out, my sensors may be too lousy in its specs to guarantee correctness.

I should try with one of the two sensors proposed in the documentation page. I liked the one I picked for its availability, and its thru-hole connection. I guess I'll have to go through the retail websites again, and hope to find one with both the sensor and the breakout board.

I can't figure out to which extend I'm entering unknown territory, here. Hence this post, to know what people here actually use (and eventually get a pointer to something easily available).

electrocoolman's picture

Re: Gas meter monitoring with Hall effect sensor

Hi,

There's some info about gas meters here    http://www.bes.co.uk/products/031.asp

my meter is a standard U6 type and I just purchased the pulse module and lead......(yes a rip-off price) but it just fitted straight on to the meter and is secured with the screw supplied.

With regards to pull up resistor, in the Arduino there is an internal pull up that can be activated.....you then switch the input to 0v to make it active.  Also it's easy to debounce the input in software.

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Hi. Thanks for the pointer. (Although I'd rather not sell a kidney for a sensor.)

Yes, I know about the internal pull-up. See Robert's answers at the beginning of the thread. I documented my code modifications on my profile, until I get something fully working.

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

Capitalising on that and this Gas Meter Pulse Reading, I've discovered that one of these works with my Actaris meter. It gives two pulses per revolution when positioned below the fastest register wheel, as in the picture.

 

johny5_uk's picture

Re: Gas meter monitoring with Hall effect sensor

Thanks for this info Robert, looks to be a massive saving from the pulse block if all that is required is a reed switch.

Have you managed to connect this up? will it just be a case of connecting the reed switch directly to an emontx?

 

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

I don't think it is absolutely plug and play.

The connection should not be difficult. The switch closes when exposed to a magnetic fields. I think you just have to solder it to a two-wire cable such that one end connects to Vcc (tip) and the other end to the interrupt pin (ring).

Conversely, you could connect it to GND (sleeve) and IT pin (ring) and activate the internal pull-up resistor in the code. I don't know which is best.

Also, reed switches generate bouncing: when changing open/close state, they can open/close a few times quickly, thus generating several interrupts when you would expect one. I hope I'm making myself clear. You can deal with the debouncing in the code with a tempo. You'd find people in this forum who did that already or at least planned to.

Thank you Robert for the hint.

I'm ordering a few Hall effect sensors and Reed switches tomorrow to make some tests. I paid more attention to activation and release magnetic field and I hope to get better results (and give feedback about which work better). The issue for such cheap parts is the shipping cost, so I'm buying several, and I managed to group my command with someone from my hacklab. I hope this time I can get it to work.

 

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

As Jérôme writes, it does need some work. The reed switch needs to be attached to the meter in a way that will not cause the energy supplier to object, and the switch needs wiring to the emonTx. There's some information about pulse inputs in Building Blocks. I don't think the internal pull-up will overcome R8, so if you want to use the internal pull-up, leave R8 out. I would keep R8 and wire the switch Tip-Ring, and I would use a twisted pair of wires if the switch is any distance from the emonTx, to minimise any induced voltages. The reed switch will indeed need de-bouncing and this is easy to do in software - but the pulse rate is quite low so a simple R-C filter may be good enough.

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

Hi.

I ordered a few Hall effect sensors and Reed switches. Here are the results I get from my tests.

Basically, although all of them would detect a fridge magnet, none would be triggered by the meter, except for the Standex ORD324-1015 Reed switch.

Hall effect sensors
Honeywell SS451 No
Diodes Inc. AH180-PL-B No
Diodes Inc. AH180N-ZG-7 No
Reed switches
Standex ORD324-1015 Yes
Coto tech. 15-40 AT SPST No

 

I guess it depends on the meters because the AH180N is said to work on other meters.

I'm a bit surprised.

 

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

I'm not too surprised at your results. The Standex reed has a smaller body and the contact rating @ 10 VA is the same as the Spiratronics one that worked for me.

Jérôme's picture

Re: Gas meter monitoring with Hall effect sensor

I'm surprised about the AH180N not working.

Robert Wall's picture

Re: Gas meter monitoring with Hall effect sensor

The very rough measurements that I did showed the field to be somewhere between 10 G and 100 G. Those Hall effect devices need 50 G or 60 G to operate, the geometric mean of my estimates is 30 G so I think it must be on the edge of operating, and just failing. Is it possible to put another magnet behind the Hall device to bias it? Ideally, it would be about the same strength as the wheel magnet. The wheel presents N & S poles at diametrically opposite points, therefore by adjusting the distance you can trim the auxiliary magnet so that the two fields add when the wheel is in the correct position and when the wheel has turned 180° the two fields exactly cancel. That way you get one pulse per revolution, not two.

dmb's picture

Re: Gas meter monitoring with Hall effect sensor

For anyone interested in gas monitoring, I tried lots of ideas to get data from my meter and having finally succeeded thought I'd post here as this thread gave me some good ideas, so I thought someone else might find this useful :) The meter is some kind of Schlumberger meter, I think it's an old (1999 ?) version of an Actaris. It has a reflective dot on the zero and using a pocket compass I found a rotating magnet point as indicated by the arrow below:

I built a little circuit based around a 55100 hall effect sensor that I bought here http://spiratronics.com/hall-effect-sensor-en.html, after trekking around lots of sites that wanted more for postage than the parts cost :) The circuit also has an LED that turns on when the magnet comes around, so I can see it's working (could also use this to drive a pulse block if you wanted to use an EnviR with an optical sensor like a GaSmart or OptiSmart).

The LED comes on when "7" comes up on the right most wheel, as shown in the photo, and turns off at "8"-ish, so one pulse per 0.01m3.

The circuit I used is as shown, I connected it up to a Raspberry Pi Model B Rev 1 that I also use with emonhub to record a bunch of emonTH modules:

Finally I ran up some python code using the GPIO library to count revs per 5 minutes and log them to my server (data is stored in a mysql database and forwarded to emoncms on the same server):

#!/usr/bin/python
#
# Count gas meter revs per 5 minutes, convert to watts and kWh
#
# 1) Number of units used (n)
# 2) Multiply by volume correction factor (Vc=1.022640)
#       The correction factor is used to take account of the temperature
#       and atmospheric conditions at a site. It is generally of the order
#       of 1.02264, so we have defaulted to this
# 3) Multiply by calorific value (CV=39.3)
#       The calorific value (CV) is a measurement of the amount of energy
#       contained in the gas. CV is usually quoted in megajoules per cubic metre
#       (MJ/m3). Gas delivered to your premises will have a CV of between
#       37.5 MJ/m3 and 43.0 MJ/m3. This is continually measured by Transco
#       for each Local Distribution Zone and passed to your gas supplier daily
# 4) Divide by kWh conversion factor (3.6)
#
# 1 m3 gas is approx 10 kWh
#
# E(kWh) = n * Vc * CV / 3.6
# P(W) = (1000 * E(kWh)) / t(hr) = (3600 * 1000 * E(kWh))) / t(s)
# E(kWh) = P(W) * t(hr) / 1000
#

# Read more: http://www.ukpower.co.uk/home_energy/gas_meter_readings#ixzz3RXckREUQ
#

import RPi.GPIO as GPIO
import os
from time import sleep
from datetime import datetime

revs=0
interval=300

# print a log message
def printMsg(msg):
    i = datetime.now()
    print i.strftime('%Y/%m/%d %H:%M:%S') + ' ' + msg

# triggered when the GPIO pin goes low (meter magnet comes around)
def eventHandler(channel):
    global revs

    printMsg("Port " + str(channel) + " is 0/LOW/False - LED ON")
    revs = revs + 1

# log the kWh consumed in the last interval
def logConsumption():
    units = revs / 100.0        # units consumed in interval, 1 rev = 0.01m3
    VC=1.022640                   # Volume correction factor
    CV=39.3                              # Calorific value

    kWh = (units * VC * CV) / 3.6;                            # kWh consumed in interval
    power = 3600 * 1000 * kWh / interval;       # Power (W) consumed in interval

    printMsg("log " + str(kWh) + " kWh");

#    do whatever you want with the data

#    Note: the following lines failed: if I called an external script, no further interrupts were generated ???????? Instead I wrote the python equivalent of the logging script

#    cmd = "perl -f /data/bin/loggas.pl GASC " + str(kWh) + " 'Gas consumption'"
#    os.system(cmd)

def main():
    global revs                 # revs counted in the current interval

    # read input from 55100 on pin 18, GPIO 24
    cmdPin = 24

    GPIO.setmode(GPIO.BCM)

    # Pull the pin up to stop false signals
    GPIO.setup(cmdPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    # now the program will do nothing until the signal on port 24
    # starts to fall towards zero. This is why we used the pullup
    # to keep the signal high and prevent a false interrupt

    GPIO.add_event_detect(cmdPin, GPIO.FALLING)
    GPIO.add_event_callback(cmdPin, eventHandler)

    try:
        while True:            # this will carry on until you hit CTRL+C
            revs = 0
            sleep(interval)
            printMsg("Detected " + str(revs) + " revs in the last " + str(interval) + " seconds")
            logConsumption()
    except KeyboardInterrupt:
        GPIO.cleanup()       # clean up GPIO on CTRL+C exit

main()

 

Phil_S's picture

Re: Gas meter monitoring with Hall effect sensor

Hello dbm

Looks just like my set-up. Iguess looking at the moulding on the left-hand side (your arrow), it is actually intended to have some sort of pulse detector fitted as an accessory. I used a AL112UA-T (Allegro unipolar) which works a treat - the position mine is in fires the Hall device between 56 and 75 on the last dial. I used Hall as I had 5-V available permanently, but for a radio link, a reed works just as well (doing the same thing on the water meter). I made up a two enclosure box to screw on using the existing moulded screw hole just to make it look better.

I haven't looked at your code etc., but I guess you have sorted the problem of when the dial stops for a long time at the Hall firing position. I did a little CMOS Schmitt circuit that does a short 100-mS pulse when it gets the rising(or falling) edge from the Hall (probably old hat to the experienced). For info, I'm using Zigbee for the meshing capability. Taken well over a year to get the pulses back on the PC, but very satisfying, and accurate to date.

All I need now is for BG to come along and change the meter

dmb's picture

Re: Gas meter monitoring with Hall effect sensor

Hi !

Yes, it does look like there should be an 'off the shelf' pulse detector, in fact I think having scoured the internet that it's the one here http://www.thecodestore.co.uk/shop/details/1300/pulse-block-metur-008.html. However when I spoke to these guys they thought this was an optical pulse block, and there's definitely no light on the meter ! I gave up looking at that point and decided to roll my own :)

The code just sleeps for five minutes at a time, then counts the number of interrupts that came in during that interval as an indicator of how much gas was used. One interrupt is generated on the falling edge from the Hall, so it's fine if the dial sits on the firing position for ages - no gas usage gets counted until it goes around again and generates a new interrupt. I'm still trying to figure out whether to report in m3, kWh, watts or just revs ! I'd like to convert m3 usage into watts so I can compare gas and electricity usage across the day, but I'm not convinced I have the conversion right yet - seems like 1 rev = 0.01m3 = 1400W which sounds like a lot of watts !!

Great to have some data coming in anyway, next to find out what's using all that gas ...

dBC's picture

Re: Gas meter monitoring with Hall effect sensor

I think you might be confusing energy and power a bit there.  The energy in 1m³ of gas varies a bit, but 37MJ seems to be a common estimate.  So in 0.01m³ there's 0.37MJ, which is 0.103 kWH.

dmb's picture

Re: Gas meter monitoring with Hall effect sensor

I think you're right !

1 rev = 0.01m3 = 0.37MJ

P(W) = E(J)/t(s)

so for say 4 revs in 5 minutes that's (0.04 * 3700000) / 300 = 493W

​Sounds much more like it !

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.