A phone compass estimates direction from magnetic-field sensors. Android describes its geomagnetic sensor as measuring the ambient magnetic field on three axes, and its sensor reference notes that magnetized iron, steel, or permanent magnets can distort magnetic readings. A steel roof, mounting rail, vehicle, magnet, or nearby electrical equipment can therefore pull the reading away from the Earth-field direction. Android sensor overview · Android magnetic-field sensor reference
Declination and interference are different problems
Magnetic declination is the expected angle between true north and magnetic north for a location and date. Nearby metal or electrical currents can instead distort the local field around the phone. Declination can convert a stable magnetic bearing to true azimuth; it cannot repair a bearing that is changing because the sensor is sitting in a disturbed field. Read how to apply declination.
| What you notice | Possible explanation | What to try |
|---|---|---|
| Heading shifts near roof rails, a vehicle, or a tool | Local magnetic interference | Move several steps away from metal and compare again |
| Heading is steady, but differs from a true-north map direction | Magnetic declination or a reference mismatch | Check whether each value is magnetic or true, then apply local declination |
| Heading jumps while the phone rotates or tilts | Sensor calibration, device orientation, or nearby interference | Follow the phone’s calibration prompt and recheck in an open area |
| Different devices disagree only at the installation point | Local field disturbance or device-specific sensor behavior | Compare away from the installation and use an independent reference |
A quick field check
- Take the phone away from the roof, steel rack, car, tools, speakers, magnets, and powered cables. Do not rest it on the panel or mounting frame.
- Hold it flat and still, then note the heading. Follow the device’s own calibration instructions if it reports a calibration problem.
- Turn slowly through a full circle. The reading should change smoothly; sudden jumps or a different result when you return to the same direction suggest the location or sensor needs another check.
- Repeat the measurement at a second nearby open spot. If the two spots disagree, do not assume the larger or more convenient number is correct.
- Use a current declination for the site to convert a reliable magnetic bearing into true azimuth. Keep the result labeled as true or magnetic.
Why moving the phone can help
Magnetic-field sensors respond to the field at the phone, not to a panel’s intended direction. A small change in position can move the sensor closer to or farther from a steel support or current-carrying conductor, changing the measured field. Calibration may compensate for some device-related sensor biases, but it cannot make a disturbed location equivalent to an undisturbed one. Android’s uncalibrated sensor documentation specifically describes hard-iron distortion from magnetized iron, steel, and permanent magnets. Android Sensor API reference
When a phone compass is not enough
For a rough orientation check, repeatable readings away from interference may be useful. For a permanent solar installation, use a survey or layout method appropriate to the site and verify the panel direction against a true-north reference. A phone reading beside the metalwork is not a reliable measurement of true azimuth.
The Sun position calculator reports the Sun’s true azimuth for a selected place and time; it does not read the phone’s compass or measure nearby metal effects. Continue to true north vs magnetic north for the bearing conversion, or use the upcoming Sun-and-shadow guide for a compass-independent orientation check.