Miniature magnetometers are used inside of cell phones in addition to gyroscopes to determine location and movement of the phone. The earth has a magnetic field that extends away from its surface, and the field is made of lines of magnetic force that are three dimensional. A vector magnetometer breaks down the magnetic force into components of direction and amount, whereas a scalar magnetometer simply gives you the net force. Unfortunately, the lines of magnetic force do not necessarily point north, so interpreting the readings is a tricky task for your smart phone.
Inside your phone is an accelerometer, which can detect the direction of earth’s gravity. Having established the direction of your phone, the compass app can determine which vectors point in what direction relative to Earth. Because of the unique pattern of the magnetic field, magnetic north can be established from these facts alone. Once your phone has your GPS coordinates, the compass app can continue to translate magnetic north in to true north. That is quite a bit of calculation for a simple compass, compared to its analog version where a magnetized needle is allowed to spin freely.
Under ideal conditions, your compass app can perform its calculations more or less without error. However, there are many large, magnetic structures that can interfere with the magnetometer’s readings. In effect, a magnetometer can be used as a metal detector the finds magnetic objects only, so it is highly sensitive to any ferrous metals.
In addition to magnetic objects, the sensor itself is an instrument with its own limitations. For example, the higher the sample rate, the better the final reading. Sample rate is the reported readings per second. Bandwidth is a related measurement because it’s a limitation to how well the magnetometer responds to quick movements. Try turning on the compass app and spinning around quickly. You will notice that the compass may struggle to keep up with your direction.
Heading error is what happens when you rapidly change directions. Try turning your phone over and over, and you’ll notice that your compass app may even report a direction that is far from your actual direction.
The magnetometer itself will contain magnetic materials, producing what scientists call noise. This noise has nothing to do with the earth’s magnetic field, but the magnetometer may struggle to tell the difference. Calculations must be performed to filter out the noise in order to get accurate readings.
As with any instrument, the magnetometer has a set of ideal conditions where it will function properly. Temperature is one such requirement, and with thermal instability, the readings produced by the magnetometer may be inconsistent.
Because of the complexity of the operations, running the magnetometer and accelerometer creates heavy demand on your phone’s energy supply. Whenever possible, avoid using your compass to preserve your phone’s battery life.
Michael C Nelson blogger and an automobile freak with strong passion for new technology. He’s written about the industry since 2009. Apart from his profession, he is a keen automobile enthusiast with a passion for vintage cars. Follow him at Twitter or Google +