Bubble Level

Turn your phone into a spirit level to check whether a surface is flat, using the accelerometer — with the calibration step most people skip.

Tap start on a phone or tablet.

There are two ways to turn gravity into an angle, and one of them fails near vertical

A phone has no idea which way is down. What it has is an accelerometer reading the pull of gravity along each of its three axes. Tilt it by an angle and gravity splits between two of them — g·sin θ along one, g·cos θ across the other — so you can recover the angle from one axis with asin, or from both with atan2. Held flat, the two agree exactly. They stop agreeing as you tip it up.

The reason is that the sensor does not report a continuous number. A common part is 12-bit over ±2g, a step of about 0.0096 m/s². Pushing that quantised reading through both formulas gives the worst error each can make:

TiltFrom one axisFrom two axes
0.028° 0.028°
15° 0.031° 0.034°
30° 0.032° 0.044°
45° 0.046° 0.040°
60° 0.077° 0.044°
75° 0.131° 0.034°
85° 0.373° 0.044°
89° 1.000° 0.036°

The single-axis reading is 43 times worse at the steep end than at the flat end, and at exactly 90° it has no resolution at all. The two-axis reading varies by a factor of 2.5 across the entire range and never exceeds 0.07° — near enough constant that a level built on it is as trustworthy against a door frame as it is on a worktop.

Why: a sine curve is flat at the top

Differentiating θ = asin(a/g) gives dθ/da = 1 / (g·cos θ). That 1/cos is the whole story:

TiltSensitivity penalty
1.00×
30° 1.15×
45° 1.41×
60° 2.00×
80° 5.76×
85° 11.47×
89° 57.30×

Near horizontal, gravity's projection onto the axis changes quickly with angle, so a small change in the reading means a small change in angle. Near vertical it barely changes at all — the sine curve is flat at its peak — and the same quantisation step now covers a much wider band of possible angles.

Two axes escape this because as one goes insensitive the other becomes maximally sensitive. atan2 always has a good axis to work with, which is the same reason it exists separately from atan, and the reason it is the right function for converting any pair of coordinates into an angle. Better sensors do not fix the single-axis version: going from 8-bit to 16-bit shrinks both errors by a factor of 256 and leaves the penalty at 85° exactly where it was.

A real spirit level in a glass vial has the same problem for the same reason, which is why the tool that gave this page its name is precise when laid flat and useless held upright.

How to use

  1. Place the phone on the surface.
  2. Calibrate on a surface you know to be level.
  3. Read the angle in degrees.
  4. Check with the phone rotated 180 degrees to cancel out any error.

Frequently asked questions

How does a phone measure level?

With its accelerometer, which senses the direction of gravity. When the phone is still, the only acceleration acting on it is gravity, so the direction of that force tells the device which way is down and therefore how far from level it is sitting.

How accurate is it?

Usually within a degree or so once calibrated, which is fine for hanging a picture or checking an appliance. It is not a substitute for a proper spirit level on anything structural, and a phone case or a raised camera bump will introduce error before the sensor does.

What is the trick for checking accuracy?

Take a reading, then rotate the phone 180 degrees in place and read again. On a truly level surface both readings match. If they differ, the error is half the difference, and this cancels out both sensor bias and any wobble in the case.

Why does my phone not sit flat?

Because most modern phones have a protruding camera, so they rock on a flat surface. Reading with the phone on its long edge against the surface avoids this, as does removing the case, and both are more reliable than laying it on its back.

Does temperature affect the reading?

Slightly. Accelerometers drift a little with temperature, which is one reason a phone left in the sun or brought in from the cold may need recalibrating. For the precision anyone needs from a phone level, the effect is minor.

Can I use it to measure a slope?

Yes, for rough purposes — a drainage fall, a ramp gradient, a shelf. For anything with a specification to meet, such as an accessibility ramp or a plumbing fall, use a proper level and check against the actual requirement rather than a phone reading.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.