We will be closed on November 25, 2021 and November 26, 2021 in observance of the Thanksgiving holiday. We will resume normal operations on November 29, 2021. Wishing you a safe and happy holiday from all your friends at SparkFun!
We can use digital magnetic field detectors as a compass to give our robot an absolute heading.
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.
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!