Paul Stoffregen of PJRC wrote a really awesome cross-platform calibration helper that is great for doing both soft and hard iron magnetometer calibration. What's nice about it is you get a 3D visualization of the magnetometer output and it also tosses outliers and tells you how much spherical coverage you got!
Step 1 - Download MotionCal Software
MotionCal is available for Mac, Windows and Linux, you can download it from clicking here.
Look for this section in the website:
And click the one that matches your computer the best.
Step 2 - Upload the SensorLab imucal
Example
Next we have to tell the microcontroller board to send the magnetometer (and, if there is one, accelerometer and gyroscope) data out over serial in the right format.
Open up the Adafruit_SensorLab->calibration->imucal
Open up the serial console, you'll see SensorLab initialization and detection of whatever magnetometer is available. In this case is a LIS3MDL, but any magnetometer can be calibrated!
You'll then see a stream of data that looks like:Raw:-58,-815,8362,76,-121,-95,-375,-159,-24
Uni:-0.07,-0.98,10.00,0.0832,-0.1327,-0.1046,-37.50,-15.93,-2.50
The first three numbers are accelerometer data - if you don't have an accelerometer, they will be 0
The middle three numbers are gyroscope data - if you don't have an gyroscope, they will be 0
The last three numbers are magnetometer, they should definitely not be zeros!
Twist the board/sensor around. Make sure its not near any strong magnets (unless that's part of the installation)
Page last edited March 08, 2024
Text editor powered by tinymce.