A map can show your position correctly while the direction arrow points the wrong way. You turn the phone, but the arrow hesitates, swings around, or seems several degrees off. Then a compass app asks you to move the device through the air to improve its accuracy.

These behaviours make more sense once you separate two questions: Where is the phone? and Which way is it facing? Location systems can help answer the first question, but a phone usually needs additional sensors to estimate the second when it is standing still.

The key sensor is a magnetometer, which measures magnetic fields around the phone. Combined with information about the phone’s orientation, it can act as an electronic compass. That also explains its main weakness: nearby magnetic fields can distort the reading.

Location and direction are different measurements

Suppose you are standing at a street corner with a navigation app open. The app may know your approximate location from satellite navigation, Wi-Fi, mobile networks, or a combination of sources. That tells it where the device is on the map.

It does not automatically tell the app which edge of the phone is pointing north.

When you are moving, a navigation system can often estimate your direction of travel by comparing positions over time. If successive location estimates move east along a road, for example, the software has evidence that you are travelling east.

But direction of travel is not the same as device orientation. You can sit still and rotate a phone in your hand. You can also travel forward while holding the phone sideways. A location trail alone cannot reliably describe those changes.

For an immediate estimate of which way the device is pointing, phones can use motion and magnetic sensors.

The magnetometer measures the magnetic field around the phone

Earth has a magnetic field. A traditional magnetic compass responds to that field mechanically: its magnetised needle aligns approximately with the local magnetic field.

A phone’s magnetometer does not contain a compass needle. It electronically measures magnetic-field strength along multiple axes of the device. Software can use those measurements to estimate the direction of the surrounding magnetic field.

The raw measurement is not yet a useful compass heading. The phone might be lying flat, tilted toward you, or held nearly upright. The same environmental field therefore appears differently relative to the phone’s own axes as you move it.

To interpret the magnetic measurement correctly, software also needs to know how the phone is oriented in space.

Motion sensors help turn magnetic measurements into a heading

Phones commonly contain an accelerometer, which measures acceleration and can also provide information related to the direction of gravity when the device is relatively steady. Many devices also have a gyroscope, which measures rotational motion.

Software can combine information from these sensors with magnetometer readings. This process is often called sensor fusion: instead of trusting one sensor to answer every question, the system combines measurements that have different strengths and weaknesses.

The motion sensors help the system understand how the phone is tilted and rotating. The magnetic measurement provides a reference related to Earth’s magnetic field. Together, they can produce a more useful estimate of the phone’s orientation and compass heading.

The exact implementation varies between devices and operating systems. Applications may receive already-processed orientation information rather than calculating every part from raw sensor readings themselves.

Why a compass can be wrong even when your map location is right

A magnetometer measures the magnetic field that actually reaches the sensor. It cannot inherently distinguish Earth’s field from every magnetic influence nearby.

That matters because everyday environments contain materials and devices that can alter the local magnetic field. Magnets, magnetised objects, electrical equipment, speakers, some accessories, and large metal structures can all affect compass behaviour depending on their strength and distance from the phone.

Imagine standing beside a large metal structure while your map correctly places you on the pavement. The location estimate and compass estimate come from different evidence. Local magnetic distortion can make the direction arrow inaccurate without moving your location marker at all.

The same principle explains why a compass reading may change when you move the phone away from a magnetic accessory or another object. The phone has not changed its geographic position in a meaningful way; the magnetic environment around its sensor has changed.

This is also why a phone compass should not be treated as an infallible reference simply because it displays a precise number of degrees. A precise-looking display can still be based on a disturbed sensor reading.

What compass calibration is trying to correct

A phone’s own components and its surroundings can introduce magnetic effects that bias measurements. Sensor systems can estimate and compensate for some of these errors, but they need useful measurements from different device orientations to do so.

That is why a device or app may ask you to move the phone through several orientations, sometimes with a figure-eight-like motion. The important idea is not the exact shape drawn in the air. Moving the device through varied orientations gives the sensor system additional observations that can help it estimate magnetic bias and improve its calibration.

Android’s sensor documentation, for example, notes that moving a device in a figure-eight pattern can improve magnetometer accuracy during testing. The details of calibration are implementation-dependent, so not every phone or app uses the same prompt or procedure.

Calibration also cannot remove every external magnetic disturbance. If you calibrate a phone while it remains beside a strong source of interference, the environment can still produce unreliable headings. Moving away from the interfering object may matter more than repeatedly performing a calibration gesture.

Magnetic north and true north are not identical

There is another reason two direction readings can differ even when both are behaving correctly.

A magnetometer naturally provides information related to magnetic north, the direction associated with Earth’s local magnetic field. True north is the geographic direction toward the North Pole along Earth’s surface.

The angle between magnetic north and true north is called magnetic declination, and it varies by location and changes over time. Navigation software can apply a declination correction when it has the information needed to do so.

As a result, a compass application may offer magnetic-north and true-north modes, or it may handle the correction automatically. The labels and behaviour vary by platform and application.

This distinction does not usually matter when you only need a rough sense of which street is ahead. It matters more when comparing headings from different tools or when a task requires a more exact directional reference.

Why the direction arrow can jump when you start walking

Navigation apps do not have to rely on one source of heading information at all times.

While you are stationary, sensor-based orientation can be useful because there may be no movement trail from which to infer travel direction. Once you begin moving, changes in location provide another source of information about your course.

Software can combine or switch between these signals depending on speed, sensor quality, location accuracy, and the application’s design. That can make the displayed arrow behave differently when you start or stop moving.

A small amount of smoothing may also be applied so the arrow does not react to every tiny sensor fluctuation. The trade-off is that smoothing can make a direction indicator feel slightly delayed during a quick turn.

These choices are application-dependent. A map, compass app, augmented-reality tool, and game may process orientation data differently even on the same phone.

What to do when the compass direction looks wrong

Start by checking whether the problem is direction or location. If the map marker is in the correct place but its orientation is wrong, the compass or orientation estimate deserves more attention than the location system.

Move the phone away from obvious magnetic or metal objects and see whether the heading becomes more stable. If you use a case, mount, wallet, ring, or other accessory containing magnets or magnetic material, temporarily removing it is a useful diagnostic test. Magnetic accessories do not necessarily cause a problem in every design or position, but magnets can affect compass sensors.

If the phone or application provides a calibration prompt, follow it in an open area away from likely interference. The exact procedure can vary, so use the instructions shown by the device rather than assuming one gesture applies universally.

Also compare behaviour in more than one place. A compass that is unreliable beside a particular desk, vehicle mount, speaker, or large structure but works normally elsewhere is giving you an important clue: the environment may be influencing the sensor.

If the reading remains consistently wrong in different locations and without accessories, restarting the relevant app or device can rule out a temporary software problem. Persistent errors may require device-specific troubleshooting because sensor hardware, calibration systems, and diagnostic options vary.

A phone compass is an estimate built from several clues

A phone does not determine direction simply by asking GPS which way it points. Location and orientation are separate problems.

The magnetometer measures the magnetic field around the device, while motion sensors help software interpret that measurement as the phone tilts and rotates. Navigation software may then combine that sensor-based heading with movement and location information.

That mental model explains the everyday behaviour: a map can know exactly where you are while pointing the arrow the wrong way, calibration can improve a biased sensor estimate, and nearby magnets can disturb direction without affecting your geographic location. When the compass behaves strangely, checking the magnetic environment is often more useful than assuming the entire navigation system has failed.