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. Hardware
  3. Fun with magnetometer / digital compass sensors

Fun with magnetometer / digital compass sensors

Scheduled Pinned Locked Moved Hardware
7 Posts 3 Posters 5.1k Views 5 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.
  • F Offline
    F Offline
    fleinze
    wrote on last edited by
    #1

    A few days ago I got a HMC5883L magnetometer from China. I do not post the link as it is the reseller is offline due to Chinese new year.

    Now I can think of two applications for it:

    1. Replacement for hall-sensors
      I have one of these cheap Chinese hall-sensors using a 3144 or 44e hall switch. They are not linear but switch when a magnetic flux of 30mT is detected.
      They did not work on my very old gas-meter, even if I could measure some magnetic field with an analog compass.
      I tried to measure the field with the magnetometer and I could see a very clear change in the field when gas is flowing.
      I did not write a proper code, but will keep you updated.
      On the pro side ist the high sensitivity of 70nT (about 500000 times better than the hall sensor) and also the low current consumption (100µA in measurement, 2µA in idle mode vs. 25mA on the hall sensor).
      On the con side is the rather high effort for signal processing in code (e.g. low pass filtering for getting rid of the earth magnetic field).

    2. Non-invasive current measurement
      The maximum sampling rate of the HMC5883L is 160Hz, which is in theory enough to signals of up to 80Hz.
      Hence it can be used to measure the magnetic field of 50Hz or 60Hz currents.
      I did a first test with my 60W solder iron. When holding the sensor to the cable I got a very clear Signal with an amplitude of about 20mT.
      It might be hard to calculate an exact current from this reading, as the magnetic field depends on the exact position of the sensor.
      But it can be used as a binary switch sensor which reports the power state of some device. One could e.g. use it to monitor the fridge and send an alarm if the fridge is running for too long.

    Has anyone any experiences with the applications above?

    YveauxY Y 2 Replies Last reply
    1
    • F fleinze

      A few days ago I got a HMC5883L magnetometer from China. I do not post the link as it is the reseller is offline due to Chinese new year.

      Now I can think of two applications for it:

      1. Replacement for hall-sensors
        I have one of these cheap Chinese hall-sensors using a 3144 or 44e hall switch. They are not linear but switch when a magnetic flux of 30mT is detected.
        They did not work on my very old gas-meter, even if I could measure some magnetic field with an analog compass.
        I tried to measure the field with the magnetometer and I could see a very clear change in the field when gas is flowing.
        I did not write a proper code, but will keep you updated.
        On the pro side ist the high sensitivity of 70nT (about 500000 times better than the hall sensor) and also the low current consumption (100µA in measurement, 2µA in idle mode vs. 25mA on the hall sensor).
        On the con side is the rather high effort for signal processing in code (e.g. low pass filtering for getting rid of the earth magnetic field).

      2. Non-invasive current measurement
        The maximum sampling rate of the HMC5883L is 160Hz, which is in theory enough to signals of up to 80Hz.
        Hence it can be used to measure the magnetic field of 50Hz or 60Hz currents.
        I did a first test with my 60W solder iron. When holding the sensor to the cable I got a very clear Signal with an amplitude of about 20mT.
        It might be hard to calculate an exact current from this reading, as the magnetic field depends on the exact position of the sensor.
        But it can be used as a binary switch sensor which reports the power state of some device. One could e.g. use it to monitor the fridge and send an alarm if the fridge is running for too long.

      Has anyone any experiences with the applications above?

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

      @fleinze said:

      I'm struggling with readout of the magnet/piece of iron in my water sensor. I think I'm going to try your suggestion!

      On the con side is the rather high effort for signal processing in code

      This should be rather simple IMHO. Calculate the exponential moving average of the signal(s) and substract them from the actual value(s). A significant change will indicate a pulse.

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • YveauxY Offline
        YveauxY Offline
        Yveaux
        Mod
        wrote on last edited by
        #3

        I can basically find two types of breakout board on Ali:

        • http://www.aliexpress.com/item/HMC5883L-Power-supply-3V-5V-Triple-Axis-Compass-Magnetometer-Sensor-Module/32436383454.html
        • http://www.aliexpress.com/item/New-HMC5883L-Triple-Axis-Compass-Magnetometer-Sensor-Module/32278947012.html

        I guess the first one included level converters fro 5V IO, and the other doesn't. How about your board, @fleinze ?
        Both seem to have an onboard 5V->3V3 regulator.

        http://yveaux.blogspot.nl

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fleinze
          wrote on last edited by
          #4

          I am using the second one, which has a regulator but no level converter. It works with 5v but i will check if i can turn off the internal pull ups on the twi in arduino. (the board seems to have two 10k pull-ups for sda and sck)

          YveauxY 1 Reply Last reply
          0
          • F fleinze

            I am using the second one, which has a regulator but no level converter. It works with 5v but i will check if i can turn off the internal pull ups on the twi in arduino. (the board seems to have two 10k pull-ups for sda and sck)

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

            @fleinze I just received mine. These things are incredibly sensitive!
            When I approach the sensor with a neodimium magnet it 'sees' the magenet from over half a meter distance.
            You can easily use these as a distance sensor too.

            Next up is the water meter experiment ;-)

            http://yveaux.blogspot.nl

            1 Reply Last reply
            1
            • YveauxY Offline
              YveauxY Offline
              Yveaux
              Mod
              wrote on last edited by
              #6

              Attached the HMC5883L to my water meter using some putty (just stuck it on the edge near the metal magnet on the big red arrow):

              0_1458070009000_2016-03-15 20.11.11.jpg

              I let the water run for a while and spilled around 20 litres (0.02m3). You can see the magnet has moved from the 5-digit to the 7-digit:

              0_1458070013698_2016-03-15 20.14.20.jpg

              Next is the chart of the HMC5883L's X/Y/Z readings (Range 8_1GA, average over 8 samples, 1 sample (horizontal pixel) per second):

              0_1458070295145_Naamloos.png

              You can clearly see the sensor readings starting to change when the valve opens and stop changing when it's close again!
              I didn't want to spill 100 litres just for a quick test, but I expect the curves to be sinusodial, and certainly periodic with the turning of the magnet.
              The position of the sensor isn't critical at all (in contrast to all other water meter sensors I've seen), you could even stick it on the closed lid of the water meter!
              Every position will generate a different swing of the X/Y/Z signals, so some clever software is required to translate this into (partial)rotations of the magnet.

              BTW I used this library and modified HMC5883L_simple.ino to output the data for the Arduino plotter.

              http://yveaux.blogspot.nl

              1 Reply Last reply
              5
              • F fleinze

                A few days ago I got a HMC5883L magnetometer from China. I do not post the link as it is the reseller is offline due to Chinese new year.

                Now I can think of two applications for it:

                1. Replacement for hall-sensors
                  I have one of these cheap Chinese hall-sensors using a 3144 or 44e hall switch. They are not linear but switch when a magnetic flux of 30mT is detected.
                  They did not work on my very old gas-meter, even if I could measure some magnetic field with an analog compass.
                  I tried to measure the field with the magnetometer and I could see a very clear change in the field when gas is flowing.
                  I did not write a proper code, but will keep you updated.
                  On the pro side ist the high sensitivity of 70nT (about 500000 times better than the hall sensor) and also the low current consumption (100µA in measurement, 2µA in idle mode vs. 25mA on the hall sensor).
                  On the con side is the rather high effort for signal processing in code (e.g. low pass filtering for getting rid of the earth magnetic field).

                2. Non-invasive current measurement
                  The maximum sampling rate of the HMC5883L is 160Hz, which is in theory enough to signals of up to 80Hz.
                  Hence it can be used to measure the magnetic field of 50Hz or 60Hz currents.
                  I did a first test with my 60W solder iron. When holding the sensor to the cable I got a very clear Signal with an amplitude of about 20mT.
                  It might be hard to calculate an exact current from this reading, as the magnetic field depends on the exact position of the sensor.
                  But it can be used as a binary switch sensor which reports the power state of some device. One could e.g. use it to monitor the fridge and send an alarm if the fridge is running for too long.

                Has anyone any experiences with the applications above?

                Y Offline
                Y Offline
                ybirch
                wrote on last edited by ybirch
                #7

                Non-invasive current measurement with HMC5883L is as good as mosquito killing by the hammer - can be done but an overkill! :-)
                Non-invasive current measurements are greatly done with wire clamp/loops.
                HMC5883L is highly sensitive and low noise digital compass. It can be used in drones, smartphones, VR sets - any applications that needs to know change of physical object orientation in 3D space.
                We use it for vehicle detection sensor. Did a benchmark on RMS on temperature stability with half a dozen of other sensors, ST, NXP, Bosch. HMC is the best! :-)

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


                26

                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