← Glossary
How does a smartphone know its orientation and how to measure it?

Orientation

The orientation of an object is its angular position in space with respect to a reference frame, described by three angles: heading (or azimuth, rotation around the vertical), pitch (front-back tilt) and roll (side tilt). No single smartphone sensor measures orientation directly: it is computed by combining several sensors. This is the information that rotates the screen, stabilises photos and orients maps.

Discover FizziQ

How to measure it in class

FizziQ groups the orientation instruments in a single theme: the compass gives the heading with respect to magnetic north, the inclinometer measures pitch and roll from -90° to +90°, and the theodolite combines both to read the azimuth and elevation of a sighted target.

Steps:

  • Open FizziQ and display the compass: turn slowly on the spot and check that the heading covers 0 to 360°.
  • Display the inclinometer: tilt the phone forwards then sideways and identify which angle corresponds to pitch and which to roll.
  • With the theodolite, aim at a high object (tree, building) and read its elevation, then its azimuth.
  • Bring a magnet close: the heading goes wrong, but not the tilt. Deduce which sensor provides each angle.
  • Lay the phone still and observe the stability of the angles: these are orientation measurements, not motion measurements, unlike the gyroscope which reads zero at rest.

Scientific activities on this topic

Possible extensions with FizziQ: orientation of a façade or a solar panel, surveying a room plan by successive sightings, or studying the Sun’s path over a day.

Learn more

Three sensors for three angles

Orientation results from sensor fusion. The accelerometer senses the direction of gravity: it provides the vertical, hence pitch and roll. The magnetometer senses the direction of the Earth’s magnetic field: it provides north, hence the heading. The gyroscope gives no absolute direction, but measures fast rotations very finely: it provides the responsiveness of the whole. An algorithm combines the three continuously: the first two correct the gyroscope’s drift, which in return smooths their noisy measurements.

Why the measurement goes wrong near metal

The heading depends on the measured magnetic field. A metal table, a speaker or the magnet of a phone case distort this field and rotate the apparent north, while pitch and roll, computed from gravity, remain correct. It is a good classroom test to attribute each angle to its sensor.

Orders of magnitude: realistic heading accuracy on a smartphone: a few degrees, away from metal structures; pitch and roll accuracy at rest: about 0.5 to 1°. The horizontal component of the Earth’s field, which drives the heading, is only about 20 µT in mid-latitudes: it is easily dominated by a nearby magnet.

Formula

Pitch and roll follow from how gravity is distributed over the device’s axes, for example for a tilt around a single axis:

θ = arctan(a∥ / a⊥)

where a∥ and a⊥ are the components of gravity measured in the tilt plane (m/s²), the relation being valid only at rest.

The heading follows from the horizontal components of the magnetic field, phone held flat:

azimuth = arctan(Bx / By)

where Bx and By are expressed in µT; the exact convention depends on the orientation of the device’s axes.

Application examples

  • Automatic screen rotation, triggered by the tilt detected through gravity.
  • Augmented reality, which overlays information on the image by tracking the phone’s orientation in real time.
  • Photo and video stabilisation, which compensates for small hand rotations.
  • Astronomy apps, which identify the star being pointed at from the phone’s heading and elevation.
  • Navigation of a robot or a drone, which holds its course through sensor fusion.

FAQ

Q: What is the difference between orientation and what the gyroscope measures? A: The gyroscope measures a rotation rate, zero as soon as the device is still. Orientation is an angular position, defined even at rest. One can go from one to the other by integration, but at the cost of a growing drift if only the gyroscope is used.

Q: Why is the heading sometimes wrong while the tilt stays correct? A: Because they do not come from the same sensor. The heading relies on the magnetometer, sensitive to metal masses and magnets; the tilt relies on the accelerometer, which only depends on gravity.

Q: Is the displayed heading true north? A: No, magnetic north. To obtain true north, you must add the local magnetic declination, small in western Europe but significant in other regions of the globe.

Compass - Inclinometer - Theodolite - Accelerometer - Magnetometer - Gyroscope - Magnetic declination - Earth’s magnetic field

Explore FizziQ

Discover all the science experiments you can do with your smartphone.