Tech Behind ThingsHow the ordinary machinery actually works

Devices

Why Your Phone Knows Which Way Up It Is

Screen rotation depends on three separate sensors that each measure something different, and the reason it occasionally gets stuck is that none of them can see orientation directly.

A classroom setting featuring laptops and desks, capturing a modern educational environment.
Photograph by Adam Sondel via Pexels
Editorial note. Independent reporting and analysis. Nothing here is sponsored or paid for. How we work.

A phone rotates its screen within a fraction of a second of being turned, which suggests it has a sensor for orientation. It does not have one, and what it does have measures something else entirely.

The accelerometer measures force, not direction

Inside the device is a tiny suspended mass that shifts when the phone accelerates. Circuitry measures how far it has shifted and reports that as acceleration along three axes.

Sitting still on a table, the phone is not accelerating in any obvious sense, yet the sensor still reports a steady pull. That pull is gravity, and it is the only reference the device has for down.

Orientation is therefore inferred rather than measured. The phone works out which of its own edges gravity is pointing towards and assumes that edge is the bottom of the world.

Gravity disappears when the phone is moving

The weakness of that inference shows up as soon as the device is in motion. Acceleration from a car, a hand or a jog adds to gravity and the sensor cannot separate the two.

This is why a phone lying flat rotates unpredictably. With gravity pointing straight through the screen rather than towards any edge, the remaining signal is mostly noise from your own movement.

Software compensates by smoothing readings over time, which is also why rotation feels slightly delayed. The lag is a filter deciding whether the change it saw was real.

The gyroscope covers the gap

A second sensor measures rotation rate directly, using a vibrating structure that deflects predictably when twisted. It responds instantly and does not care about gravity at all.

Its problem is the opposite one. A gyroscope reports change rather than position, so small errors accumulate and its idea of orientation drifts steadily away from reality.

Used alone it would be accurate for seconds and useless after minutes. Used alongside the accelerometer, its fast response covers exactly the moments when gravity readings are least trustworthy.

The magnetometer supplies an absolute heading

Neither sensor can tell you which way the phone faces horizontally, because rotating around the vertical axis changes neither gravity nor, eventually, anything the gyroscope remembers correctly.

A magnetometer reads the Earth's magnetic field and provides a fixed external reference. It is slow, easily disturbed by speakers and steel furniture, and wrong near anything magnetic.

Maps applications lean on it heavily, which is why they occasionally insist you are facing the wrong way until you wave the handset in a figure of eight to recalibrate.

Fusion reconciles three imperfect answers

The device runs an algorithm that weighs all three streams continuously, trusting the gyroscope over short intervals and correcting its drift with the slower, steadier sensors.

The result is a single orientation estimate that is better than any input on its own. It is a statistical best guess, refreshed hundreds of times a second.

Understanding that explains the failures. A phone that will not rotate is usually being held at an angle where every sensor is contributing ambiguity rather than evidence.

Questions readers ask

Why does brightness jump when I unlock the phone?

The sensor is often only sampled while the screen is on, so the first reading after unlocking replaces a stale value from earlier.

Does automatic brightness save battery?

Usually yes, because most people set a fixed level high enough for the worst case and then leave it there in dim rooms.

Devicesdisplayssensorsperceptionpower
Grigor Petrov
Hardware writer, Tech Behind Things

Grigor writes about silicon, thermals and the physical limits designers keep bumping into.

Also by Grigor Petrov