Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Gas Meter Reading Using a Magnetometer

Gas Meter Reading Using a Magnetometer

Scheduled Pinned Locked Moved My Project
77 Posts 10 Posters 23.3k Views 12 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dynamiteD dynamite

    @dpcr Hi, I need to recalibrate to see if the reading is still OK. Somewhere during a total reset I have lost track. But it is on my to do list to get everything up and running again.
    As far as I could recollect an overshoot had no influence on my code as the number of pulses for a total cycle is consistent within my code.

    On the Y reading from the sensor I do have a running average smoothing.
    Basically every cycle is splitted into rising and falling part. Each splitted into a fixed number of steps. Based on the current reading of y the number of pulses is calculated within that step. So the amount of pulses within a rise or fall can never be more than the number of steps within that cycle.

    I am thinking of making the code more simple and only give a pulse on the changes and maybe one in the middle. That would give me about 4 pulses per cycle.

    dpcrD Offline
    dpcrD Offline
    dpcr
    wrote on last edited by
    #63

    @dynamite Makes sense, how would you measures the flow when it gets real low?

    dynamiteD 1 Reply Last reply
    0
    • dynamiteD dynamite

      @Ed1500 The magnetometer is picking up a change in the magnetic field. Normally the sensor itself is moving and so changes in x,y and z etc can be detected. In case of the gas meter the sensor is stationary but the change in magnetic field due to the rotating magnet on the dial is detected. This will give you a snow wave.

      I presume In case no magnet still small changes can be detected due to rotating parts within the meter.

      E Offline
      E Offline
      Ed1500
      wrote on last edited by
      #64

      @dynamite thanks, i know pretty well how the magnetometer works, but I guess i was thrown off by the statement 'no magnet', but I guess it must be weak magnetization of the various parts then

      1 Reply Last reply
      0
      • dpcrD dpcr

        @Ed1500 As Dynamite said, it measures the change in the magnet field produced by the movement inside of the meter. I believe all ferris metals can have some sort of effect as well as an electrical field (something like that produced by an AA battery) on the sensor. There is no magnet in my gas meter (Rockwell 250). I used an app on my phone to determine the best possible location of the sensor. Look at the first post.

        E Offline
        E Offline
        Ed1500
        wrote on last edited by
        #65

        @dpcr Thanks, yes i read how you did it with locating the sweet spot, but I was thrown off by the 'no magnet' statement.
        'connecting' my meter is also still in the cards, no idea if it has a magnet or not (in which case i may use a Hall sensor), otherwise i may try the magnetometer

        dpcrD 1 Reply Last reply
        0
        • E Ed1500

          @dpcr Thanks, yes i read how you did it with locating the sweet spot, but I was thrown off by the 'no magnet' statement.
          'connecting' my meter is also still in the cards, no idea if it has a magnet or not (in which case i may use a Hall sensor), otherwise i may try the magnetometer

          dpcrD Offline
          dpcrD Offline
          dpcr
          wrote on last edited by
          #66

          @Ed1500 Good luck on on your project, keep us updated on your progress. I'm also thinking about trying to measure our electricity consumption using CT's rather than at the meter.

          E 1 Reply Last reply
          0
          • dpcrD dpcr

            @Ed1500 Good luck on on your project, keep us updated on your progress. I'm also thinking about trying to measure our electricity consumption using CT's rather than at the meter.

            E Offline
            E Offline
            Ed1500
            wrote on last edited by
            #67

            @dpcr thanks, indeed, I am using a CT as well, adding a dc bias, still balancing between just measuring the amplitude of the sinus, or measuring all along the sinus. I think i will have an attiny 25 or ideally an attiny13 do this as a dedicated I2C slave and have that read by an ESP8266. Ofcourse there is the sonoff Touch, but thats a tadd too much to put on a large number of devices.

            YveauxY 1 Reply Last reply
            0
            • E Ed1500

              @dpcr thanks, indeed, I am using a CT as well, adding a dc bias, still balancing between just measuring the amplitude of the sinus, or measuring all along the sinus. I think i will have an attiny 25 or ideally an attiny13 do this as a dedicated I2C slave and have that read by an ESP8266. Ofcourse there is the sonoff Touch, but thats a tadd too much to put on a large number of devices.

              YveauxY Offline
              YveauxY Offline
              Yveaux
              Mod
              wrote on last edited by
              #68

              @Ed1500 the ic used in the sonoff pow (HLW8012) costs less than $1 and can do it all for you. Maybe that's an idea...

              http://yveaux.blogspot.nl

              E 1 Reply Last reply
              0
              • dpcrD dpcr

                @dynamite Makes sense, how would you measures the flow when it gets real low?

                dynamiteD Offline
                dynamiteD Offline
                dynamite
                wrote on last edited by dynamite
                #69

                @dpcr the more steps you choose of course the more accurate it gets. At this moment I have divided the Total cycle in 20 steps. I have made this a parameter in my code.

                E 1 Reply Last reply
                0
                • YveauxY Yveaux

                  @Ed1500 the ic used in the sonoff pow (HLW8012) costs less than $1 and can do it all for you. Maybe that's an idea...

                  E Offline
                  E Offline
                  Ed1500
                  wrote on last edited by
                  #70

                  @Yveaux yes, As a matter of fact I looked into that one, I think they can be had for 60cts, but the 'problem' is they need a galvanic connection to the grid and to the esp as well. I want it to be completely isolated from the grid

                  1 Reply Last reply
                  0
                  • dynamiteD dynamite

                    @dpcr the more steps you choose of course the more accurate it gets. At this moment I have divided the Total cycle in 20 steps. I have made this a parameter in my code.

                    E Offline
                    E Offline
                    Ed1500
                    wrote on last edited by
                    #71

                    @dynamite indeed, that is why i was looking at yr code. On the other hand, if the frequency is known and you know the amplitude, you can make a calculation.... but then again, in order to know the amplitude you need a series of measurements.
                    Thats why i was thinking to let a dedicated attiny do that: all it needs to do is to measure and put the result in its I2C registers. The esp8266 then can do a hoist of other things and just pull the powerparameters when needed

                    dynamiteD 1 Reply Last reply
                    0
                    • E Ed1500

                      @dynamite indeed, that is why i was looking at yr code. On the other hand, if the frequency is known and you know the amplitude, you can make a calculation.... but then again, in order to know the amplitude you need a series of measurements.
                      Thats why i was thinking to let a dedicated attiny do that: all it needs to do is to measure and put the result in its I2C registers. The esp8266 then can do a hoist of other things and just pull the powerparameters when needed

                      dynamiteD Offline
                      dynamiteD Offline
                      dynamite
                      wrote on last edited by dynamite
                      #72

                      @Ed1500 The amplitude is quite simple it is just measuring the (max) top and (min)bottom if the direction of your signal changes.This is quite consistent during the readings and if due to temperaturen or whatever cause it is changing the max and min are adjusted. However the period / frequency of the curve is not consistent as this is directly related to the consumption.
                      I think the linear approach to the curve is already quite accurate. But if you have a better routine in mind I love to hear. Basically I just have to adjust the array in which the different steps are calculated.

                      I like the idee of having a dedicated attiny as I know from my sketch that in case of high volume the changes is the y are quite fast and the is (almost) no time to communicate with the gateway etc.

                      E 1 Reply Last reply
                      0
                      • dynamiteD dynamite

                        @Ed1500 The amplitude is quite simple it is just measuring the (max) top and (min)bottom if the direction of your signal changes.This is quite consistent during the readings and if due to temperaturen or whatever cause it is changing the max and min are adjusted. However the period / frequency of the curve is not consistent as this is directly related to the consumption.
                        I think the linear approach to the curve is already quite accurate. But if you have a better routine in mind I love to hear. Basically I just have to adjust the array in which the different steps are calculated.

                        I like the idee of having a dedicated attiny as I know from my sketch that in case of high volume the changes is the y are quite fast and the is (almost) no time to communicate with the gateway etc.

                        E Offline
                        E Offline
                        Ed1500
                        wrote on last edited by
                        #73

                        @dynamite yes i do not see a problem in measuring the amplitude. I am not sure if, when measuring current through a CT, the frequency will change, as that is just the grid frequency, but probably you were referring to its use in measuring gas flow.

                        My idea to use a dedicated attiny is simply so the ESP will be freed of the burden of calculation/measuring, as this will be a rather continuous process. The code will probably fit an attiny13, but I have never tried i2c on an attiny13, but I have on an attiny85, so i am pretty sure it will work on the 25 and 45 as well. The 13 I still have to try

                        1 Reply Last reply
                        0
                        • pihomeP Offline
                          pihomeP Offline
                          pihome
                          wrote on last edited by
                          #74

                          @dpcr, @dynamite how you powering your node? Do you supply constant power from some
                          Power supply (mobile charger) or running on batteries?

                          PiHome - Smart Heating Control

                          dynamiteD dpcrD 2 Replies Last reply
                          0
                          • pihomeP pihome

                            @dpcr, @dynamite how you powering your node? Do you supply constant power from some
                            Power supply (mobile charger) or running on batteries?

                            dynamiteD Offline
                            dynamiteD Offline
                            dynamite
                            wrote on last edited by
                            #75

                            @pihome Hi i am powering it with adapter. So no batteries used.

                            1 Reply Last reply
                            0
                            • pihomeP pihome

                              @dpcr, @dynamite how you powering your node? Do you supply constant power from some
                              Power supply (mobile charger) or running on batteries?

                              dpcrD Offline
                              dpcrD Offline
                              dpcr
                              wrote on last edited by
                              #76

                              @pihome I power mine with an adapter as well. This node sends too much information to be battery powered. I was researching solar because the sensor sits outside on the south side of our home but never followed up on it. Maybe for another day.

                              pihomeP 1 Reply Last reply
                              0
                              • dpcrD dpcr

                                @pihome I power mine with an adapter as well. This node sends too much information to be battery powered. I was researching solar because the sensor sits outside on the south side of our home but never followed up on it. Maybe for another day.

                                pihomeP Offline
                                pihomeP Offline
                                pihome
                                wrote on last edited by
                                #77

                                I was thinking to have it powered with battery and solar charger but lot can go wrong with this setup, may be best to have it powered via proper power supply, i have ordered sensor and i will build this once i get that delivered and report back, i was thinking to calculate co2 footprint as well for gas usage.

                                @dpcr said in Gas Meter Reading Using a Magnetometer:

                                @pihome I power mine with an adapter as well. This node sends too much information to be battery powered. I was researching solar because the sensor sits outside on the south side of our home but never followed up on it. Maybe for another day.

                                PiHome - Smart Heating Control

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                22

                                Online

                                11.7k

                                Users

                                11.2k

                                Topics

                                113.1k

                                Posts


                                Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • MySensors
                                • OpenHardware.io
                                • Categories
                                • Recent
                                • Tags
                                • Popular