Magnetometers, accelerometers, and the calibration procedure for your Android device
Posted on May 22, 2013
What is an accelerometer or a magnetometer? Many Android apps rely on the accuracy of sensors within your device to work properly. Below I have set out what these sensors are, with a focus on how they are used to produce an accurate compass bearing. I have also included some advice on how to calibrate your device to ensure that you get the best readings from these sensors.
The sensors in your Android device
Most Android powered devices have built-in sensors that measure motion, orientation, and various environmental conditions. Android app developers make use of these sensors to monitor three-dimensional device movement or positioning. Within our Survey Compass, Accurate Compass, and Sun Position apps, we use the magnetometer and accelerometer within your device to calculate a compass bearing.
What are a magnetometer and accelerometer?
The magnetometer sensor in your device measures the direction of the magnetic field acting on your device. (i.e. it monitors which way is north).
The accelerometer sensor measures the acceleration force that is applied to your device. When your phone is stationary, it will determine which way gravity is pulling. Within our compass apps, we use this sensor to determine the angle at which your device is rotated from horizontal. This allows us to know how to draw the direction to magnetic north on your screen (as it will look different if your phone is held vertical than if it is horizontal).
Unfortunately the magnetometer sensor within your device will be very sensitive to interference from local magnetic fields, even if these are very small (such as a metal button on your phone case). Once they have been exposed to this interference over a prolonged period, the sensor will no longer be accurate and will need re-calibrating.
Calibrating your device
To calibrate your device move it a far away as you can from any magnetic interference (cars, computers etc).
You should then wave your device in a figure of 8 pattern rotating it in different directions as you do this. If your device is very hot you may need to wait for it to cool down. You can also try switching it off and on again.
If you are unsure of the accuracy of your sensors, you can check this within the “sensor status” or “calibrate” menu option of our Survey Compass, Accurate Compass, or Sun Position apps. This will show an information screen setting out the accuracy of your magnetometer and accelerometer and whether any calibration is required.
It’s also worth noting that not all Android devices contain a magnetometer sensor. If they don’t have one you won’t be able to use many compass apps, so if this is important to you, you might want to check before you buy a new phone!