4

The"compass" in Android seems to be a projection of the 3D magnetic field measured by a magnetometer:

Android magnetometer sample reading

Having read https://electronics.stackexchange.com/a/22271/282833 I still have three questions:

  1. Assuming the compass has been calibrated while quality testing before shipping, why is it needed to calibrate the compass again? Or in other words: Assuming that the magnetic sensor is placed the same with high precision on each device of the same series, why can't a "golden sample" be calibrated and the data set to all of the similar devices?

  2. Assuming you calibrated the compass and you use it in more or less the same area (meaning: I know that the compass may need re-calibration when moving a significant distance, like a few hundred km), but same area means less than 50km), what are the reasons you must re-calibrate the sensor after some time?

  3. Is the compass calibration global to all apps, or do individual apps require separate compass calibration? It seems some apps suggest re-calibrating the compass frequently, while others don't.

Background for the question is that even after calibrating the compass, it started to "go mad", meaning north was almost 180° off.

1 Answer 1

6

Why is it needed to calibrate the compass again?

Things go out of calibration. If you put a strong magnet next to a camping/orienteering compass for long enough, you will alter the magnetic components of the needle and it will not be able to point to magnetic north correctly. In the same way the magnetometer components in a mobile device are sensitive to magnetic fields.

Why re-calibrate if in the same area?'

The 'same area' needs to specified. Even a smartphone has multiple magnets inside either for the speakers, microphone, or any 'magic' case attachments. A house/home has a variety of magnetic field generators like the electric motors in kitchen appliances, various audio/video equipment, and some lamp fixtures. Vehicles have starter motors and generators in addition to any audio equipment as well as being a large piece of metal. Unless you are in a completely rural community you will be surrounded by power lines, trains, transformers, pipes, buildings all slightly shifting the local magnetic field. In an urban environment it is easy to accidentally get near a strong magnetic field which could require recalibration.

  • If you are having problems with calibration, make sure that you are using a phone case doesn't have magnets. I would suggest trying in an open field far from any electromagnetic interference like the middle/center location of an outdoor school sports field. If afterwards you are still having problems it may be that the compass is damaged, perhaps due to prolonged exposure to a strong electric motor.

Do individual apps need to calibrate the compass?

In a device there is generally only one magnetometer and its calibration is internal to the chip/driver/subsystem. The Android Open Source Project has a section on Sensor HAL (Hardware Abstraction Layer) where corrections would take place. The 'figure 8 pattern' for calibration is in concert with the accelerometer and gyroscope. All apps should receive any corrected/calibrated values. Its possible that the app may need to be restarted after calibration to get correct values.

Reference to an old answer with a nice video: Compass needle deflected when near off smartphone Do note that when designing these products the additional magnets are in a known position relative to the internal magnetometer so their influence is minimized.

So wait is it one chip or multiple chips involved in the compass?

The compass/accelerometer/gyroscope are all MEMS devices which allows these features to fit into tiny spaces. For hobbyists, Arduino has a single chip IMU (inertial measurement unit) board and in consumer phones due to all of the magnets the magnetometer appears to be separated from the gyroscope/accelerometer as seen in the Nexus 5 iFixit teardown and the Samsung S7 iFixit teardown. I would not be surprised if in low end phones one of the pair is missing OR the phone is using a single chip for all three.

Occasionally an app will tell me that the compass needs calibration how is that happening?

Most likely you were using a mapping app in directions mode. By itself there isn't any way for a phone to know which way is north, however when walking/biking/driving along a route the mapping app can identify using GPS / WiFi locations that the person is following a route but the compass isn't making sense and will inform the user that recalibration is required. For example moving east on a east-west road but the phone orientation doesn't change (gyroscope & accelerometers) and the compass points the wrong way may trigger a 'recalibrate compass' message.

2
  • Somehow I doubt that "its calibration is inside the chip": Don't the "three magnetic dimensions" have to be coordinated with the device position (gyros sensor or orientation sensor)? So unless one chip implements all those, I doubt the calibration will be inside the chop. Do you have references? - And I forgot to ask "How does an app detect that compass re-calibration is needed?"
    – U. Windl
    Commented Nov 18 at 9:00
  • @U.Windl Your right 'chip' isn't the right word, probably subsystem is more correct. Commented Nov 19 at 3:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .