Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.

Two CLUEs, two very different magnetometer readings

I've got two CLUEs and they give very different magnetometer readings in CircuitPython. These are the values from clue.magnetic on REPL with the board placed in the same position and orientation.

Code: Select all | TOGGLE FULL SIZE
`CLUE 1(-10.5086, -7.46857, 39.8129)(-11.1371, -7.04472, 40.2952)(-11.1371, -7.04472, 40.2952)`

Code: Select all | TOGGLE FULL SIZE
`CLUE 2(-46.0976, 20.3449, 21.5288)(-46.5653, 20.8272, 21.2803)(-46.2146, 20.8857, 21.5873)`

These do not look at all similar. I had a quick look at the component on the CLUEs and they both appear to have the same orientation on the board based on the text and pattern on the tiny chip.

I tested with a slightly less precise position/orientation and a magnet about 8cm from them and got:

Code: Select all | TOGGLE FULL SIZE
`CLUE 1(-92.9845, -36.1736, -171.353)(-92.6045, -36.2905, -171.485)(-94.5922, -36.9921, -172.683)`

Code: Select all | TOGGLE FULL SIZE
`CLUE 2(-128.047, -2.30927, -204.238)(-127.916, -2.51388, -203.727)(-129.465, -1.95849, -205.013)`

Perhaps I've answered my own question here, do these things have an unpredictable offset (bias) on them? The values look comparable if an offset is applied. Is the sort of subsantial variation seen here typical for the same sensor on the same board?

Magnetometers can be used to detect orientation with respect to the Earths magnetic field. Basically, like a compass! We can tell which way is North, and thus correct for motion calculation errors and 'absolute orientation'

Good stuff! But, magnetometers have to measure a very small magnetic field of 35-65 uTesla, in a world full of magnets. And there's some offset when they are manufactured and pick and placed.

Of all the sensors that need calibration, magnetometers are the most essential to calibrate! Unless you're detecting strong magnets, there's no way for a magnetometer to work unless you perform a hard iron offset calculation. Once this is done, you will get rid of any strong magnetic offset values and be able to find magnetic North!

I'm now pondering whether the libraries should have a facility to apply an offset to the returned values?

kevinjwalters

Posts: 982
Joined: Sun Oct 01, 2017 3:15 pm

Re: Two CLUEs, two very different magnetometer readings

Magnetometers do tend to have some zero-offset error. They are also subject to hard and soft iron errors. One thing we have seen that can cause extreme hard-iron errors is testing your magnetometer with strong magnets in close proximity. With some devices it is possible to actually magnetize parts of the magnetometer itself (with predictably awful results). The Clue has other components on-board which can potentially become magnetized as well and can skew the readings.

Posts: 82472
Joined: Sat Feb 07, 2009 10:11 am

Re: Two CLUEs, two very different magnetometer readings

Thanks, I'm going to eventually have a look at the calibration stuff, it looks like the sensor has non-voltatile memory for storing the calibration data. In the meantime I've visualised the difference using the data from my previous post.

Magnetometer Readings for Two CLUE boards (uncalibrated)
clue-magnetometer-comparison-faster-smaller.gif (1009.74 KiB) Viewed 206 times

kevinjwalters

Posts: 982
Joined: Sun Oct 01, 2017 3:15 pm

Re: Two CLUEs, two very different magnetometer readings

Hard to see precisely. But the offset between the two seems consistent between the two readings. And consistency is the most important property of a sensor: