Calibrating an HMC6352 magnetometer

I’ve started tinkering again with our autonomous vehicle that failed so miserably at Sparkfun AVC 2015. My focus so far has been on the compass, which I suspect was one of the bigger contributors to our poor performance. Some tests confirmed that the compass was very inaccurate so I took the time to learn how to calibrate the compass this weekend and the compass seems to be very accurate now. I didn’t run through this process when we competed in 2014 and we did pretty well then, so maybe we just got lucky.

After studying the datasheet for the HMC6352, I forked the Sparkfun Arduino library and added an example sketch for performing calibration. The library is available here. The calibration process requires the compass to be rotated on a flat surface at a steady pace. I placed the vehicle and my laptop on a lazy susan so I could rotate it with both hands during the calibration process.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *