Tuesday, 11 November 2014

Troubleshooting the Android Compass

Symptoms: Compass (orientation sensor) on Android device seems to be 'stuck' on one or two headings. This heading may change with a switch from landscape to portrait screen mode, but will still be incorrect.

Incorrectly described as fix: moving. Movement in some apps like Google Maps will calculate your heading from your change in GPS position. Clever Google Maps! The moment you stop, an incorrect heading from the orientation sensor will again be displayed.

Incomplete fix: waving device in large figure-8s or circles. This seems a popular forum suggestion. But it doesn't seem to work for everyone, and I myself have intermittent success. As to why this only works sometimes, let's look at the probable cause: magnetic interference.



The magnetic sensors in the phone are sensitive enough to respond not only to magnets, but also to metal objects. To see this for yourself, run the Sensor Tester app, choose the magnetic sensor if available and move a paper clip or other metal object near your phone. The readings will change with even the slightest movement.

It is foreseeable then that even a weak magnet nearby will overwhelm the sensors' ability to read the Earth's geomagnetic field. This does not happen at all places because geomagnetic field strength varies between location. In fact, a database of field strengths and flux direction is used by NATO (and Android) for positioning. My own experience is of the compass 'recovering' more often in South Australia than in Tokyo, which seems in turn better than Singapore.

By weak magnet, I also mean the oft-overlooked magnetic clasp on many device wallets or cases.

To test this, the two of five times the figure-8 fix worked in my home was when I removed my phone from its cover (with magnetic clasp) before waving the phone about. In one case I simply twirled the phone on the floor. The other three times, while the case remained on, neither waving the phone nor rebooting it made a difference.

It seems, though, that once the orientation sensor starts returning correct readings, it is 'calibrated' and you can safely put the device back in its case without the symptoms recurring until the next reboot.

I hope this helps before you execute the next popular forum suggestion: a factory reset or re-flashing to a stock OS.

Did it work? Did it not? Please share or comment.

No comments:

Post a Comment