×

Please see all COVID-19 updates here as some shipments may be delayed due to CDC safety and staffing guidelines. If you have an order or shipping question please refer to our Customer Support page. For technical questions please check out our Forums. Thank you for your continued support.

Adventures in Science: Using a Magnetometer as a Compass

We can use digital magnetic field detectors as a compass to give our robot an absolute heading.

Favorited Favorite 0

Time for another Adventures in Science! While finding north has never been particularly tricky for the navigators of yesteryear (see: compass), teaching robots how to navigate is a tad more difficult. While GPS can give you a position, it won't immediately provide heading data without gathering several position points first. To remedy this, we have digital magnetometers, which we can configure to act as a compass.

Detecting magnetic fields can be accomplished through a variety of methods, including measuring the buildup of charge carriers on the edges of semiconductor material, or measuring the deflection of a beam with an attached permanent magnet. As technology progresses, these measuring devices continue to shrink in size, which is how we're able to fit magnetometers in smartphones, along with dozens of other sensors.

To get a heading, we need to calibrate the magnetometer, which involves taking samples several times per second and finding which direction yields the strongest magnetic "north" (or "south"). Every time we reset the sensor, we'll need to perform this calibration, as the ambient magnetic fields change depending on your location and surroundings (e.g. electronics, other magnets). The tutorial below will show you how to use the SparkFun MAG3110 magnetometer breakout with Arduino.

MAG3110 Magnetometer Hookup Guide

October 24, 2016

Get started with the MAG3110 3-Axis Magnetometer and learn how to make your own digital compass that senses the Earth's magnetic fields.

For information on the digital compass shown in the video, see these links:

Any tips for getting better accuracy out of a magnetometer when it comes to finding a heading? Feel free to share in the comments!


Comments 5 comments

  • Awesome!! Shawn... you nailed it like always by bringing up new techniques or by reminding old techniques.

  • From a navigation standpoint, east is 90 degrees, south is 180, and west is 270. Great video :)

    • Yeah, I remember reading that in my research. For whatever reason, the Arduino library for the MAG3110 gives West as -90. Oh well.

Related Posts

Recent Posts

Apple of My FTDI

Tags


All Tags