How to calibrate MMC5983MA magnetometer?

I’ve been told that my Sparkfun Qwiic Micro Magnetometer will not work as a compass without calibration, but I’m having difficulty finding the way to do it. I was given these links (from jremington on Sparkfun Inertial Measurement Units Forum):

Simple tutorial
Advanced Guide

which I followed, and I’m 90% sure I followed them correctly but I’m having no success. The Arduino sketch mentioned in the Simple tutorial doesn’t seem to do anything or create any output in the Arduino IDE serial monitor for my RedBoard Qwiic.

If anyone has a known method for the MMC5983MA, I’d appreciate the info. Alternatively, if you think the info I’ve been given is sufficient, I will go back and try again.

My setup: Sparkfun RedBoard → Qwiic Micro Magnetometer (MMC5983MA)

Any help or other pointers would be appreciated! Thanks :grin:

1 Like

Hi Jacob,

Are any other boards using the same COM port? You might have to reconfigure the sketch for your Redboard to output via the console, taking a few steps back are you able to receive a ‘hello world’ serial output?

From the simple tutorial link it seems to be building a steady-state Kalman filter, which should be more than enough for basic measurements.

If you have other magnetic components around that will interfere with the magnetometer - would it be possible to send through some photos?

PS: the PiicoDev Magnetometer has the compass built in to the micropython libraries: PiicoDev Magnetometer QMC6310 | Core Electronics Australia

Liam

1 Like

Here are some tips about the calibration: ST Community

1 Like

G’day Liam,

Do I understand correctly that the QMC6310 has a calibratable digital compass script included in the libraries?

My SparkFun MMC5983MA also has a digital compass sketch available but it is uncalibrated and off by about 60 degrees.

Following this tutorial I see no output in Magviewer. When I skip this step and go straight to open MagMaster and connect to the ESP32 Thing Plus’s COM port, it gives a “Warning!” message saying “Empty port name.”.

I’m using an ESP32 Thing Plus and an MMC5983MA magnetometer.

Any thoughts or suggestions would be appreciated. Also, if you already have a known method for MMC5983MA calibration, I’d love to hear it. I’m told all calibration methods are the same for all magnetometers, but this has not been my experience. Then again, I am a novice. Thanks!

1 Like

Just realised I kind of asked this question already. Sorry Mods, feel free to delete this topic :sweat_smile:

I’ve been told the PiicoDev QMC6310 magnetometer has a calibration script available. I’ve ordered 2 and will try calibrate them when they arrive.

I think I was told this before but misunderstood it to mean the QMC6310 had a “digital compass” script available. The SparkFun MMC5983MA has a digital compass sketch also, but it’s uncalibrated (and off by about 60 degrees in my case).

1 Like

Hi Jacob,

Thanks for letting us know about the 2 threads, I’ve merged them :slight_smile:

Let us know if those QMCs give you any trouble!

Hi Jacob

I have no experience with this device but to me that is a lot of error. Interesting to see if calibration removes it. Almost enough to suspect a sneaky magnetic field source somewhere close by. If you are somewhere on or near the coast of NSW and the error was about 12º it could be the difference between magnetic and true north.

What are you comparing this with? If a phone that could be in error in the opposite sense which would compound your perceived error.

It is a bit hard to think of a way to check this. You could pick a distant land mark and get a bearing using Google Earth but I think that will be referenced to true north and you would still have to know the magnetic deviation for your location. A trig point marker would indicate North but I think this would be true, not magnetic. Problem is you mostly use a compass because you don’t know where north is so you need to believe something.

I have an App on my phone which provided GPS is activated and it knows where I am will apply the correct deviation and display magnetic or true north, user’s choice. I must admit I have never used this in anger yet.

The most accurate check I think available to us mere mortals is the shadow of a pole at exactly mid day. You will need to know your longitude to calculate at exactly what actual time mid day occurs. The easy way is to know we are east of GMT or UTC by 1 hour per 15º longitude. I think this will be true north so you still need to know the magnetic deviation for your location.
Cheers Bob

Magnetometers are calibrated to remove constant magnetic disturbance. These are things like the components on the circuit board and any ferrous/magnetic objects that move in the same body-fixed reference frame of the magnetometer itself.

you may find this article helpful.

Essentially the hard-iron calibration procedure is to:

  • take continuous measurements on all axes
  • rotate the magnetometer through all orientations
  • keep track of the min and max for each axis
  • find the offset and range for each axis

the range is max - min and the offset is (min+max) / 2

The article does a great job representing this graphically:

You can dig into the QMC6310 MicroPython driver we’ve written and find that this is the method we’ve used. I expect all hard-iron calibration methods use essentially this algorithm - though they may differ in exact implementation.

It does! And after calibration it’s really accurate. You can see me run the compass example and compare the results to a real magnetic compass. The results are pretty pleasing :slight_smile:

2 Likes