Ready
—

Relative to screen-up horizontal

Left / right
—
Front / back
—
Total tilt
—

Sensor access has not started.

RAW Tools Measurement

Online Spirit Level and Inclinometer

Robert Eisele

Use your phone as a free online spirit level and inclinometer to check surface tilt in degrees. The digital bubble level shows two-axis inclination; the inclination view displays a signed left/right angle. On a supported smartphone, the tool uses the built-in motion sensors without an account, external sensor, or app installation. Sensor readings are processed locally in your browser.

How to Use the Online Spirit Level

Open the tool over HTTPS, press Start sensors, and allow motion access if your browser asks. Place the phone screen-up on a stable surface and wait for the reading to settle. The total angle is zero when the screen normal points upward, 90 degrees when it is horizontal, and 180 degrees when the screen faces down. Left/right is a signed angle in the current screen axes; front/back ranges from -90 to 90 degrees.

Set reference saves the current filtered direction as a reference plane. Subsequent values show the deviation from that plane, not necessarily from the horizontal. Clear reference restores the screen-up horizontal reference. Rotating the screen between portrait and landscape clears the reference because the displayed axes have changed. Calibration is kept only for the current page session.

The bubble view is useful for checking a tabletop or shelf in two directions at once. Switch to inclination to read the left/right tilt as a signed angle, or save a reference to compare two surface orientations. Place the phone consistently for each comparison; the measurement describes the phone's orientation, not the surface itself.

A phone case, camera bump, uneven edge, sensor bias, or vibration can affect a measurement. Check the reading on a known level surface and compare reversed placements. This is a convenient visual aid, not a calibrated surveying instrument. Do not rely on it for safety-critical work.

Angles from a Gravity Vector

The preferred input is DeviceMotionEvent.accelerationIncludingGravity. When the phone is stationary, it provides a gravity-related acceleration vector in device coordinates. We rotate its in-plane components into screen coordinates, then normalize it to a unit vector \(\hat{\mathbf g}\). The uncalibrated reference is \(\hat{\mathbf n}=(0,0,1)\). The total tilt follows from the dot product:

\[\theta = \arccos\!\left(\operatorname{clamp}(\hat{\mathbf g}\cdot\hat{\mathbf n},-1,1)\right).\]

This measures an actual angle between directions, including inverted positions. Subtracting independent roll and pitch angles would not provide the same result. For a saved reference, we project a device axis onto the reference plane and normalize it to obtain a right direction \(\hat{\mathbf r}\). A cross product supplies the perpendicular in-plane direction \(\hat{\mathbf u}=\hat{\mathbf n}\times\hat{\mathbf r}\).

\[\begin{aligned} x &= \hat{\mathbf g}\cdot\hat{\mathbf r},\\ y &= \hat{\mathbf g}\cdot\hat{\mathbf u},\\ z &= \hat{\mathbf g}\cdot\hat{\mathbf n}. \end{aligned}\] \[\begin{aligned} \text{left/right} &= \operatorname{atan2}(x,z),\\ \text{front/back} &= \operatorname{atan2}\!\left(-y,\sqrt{x^2+z^2}\right). \end{aligned}\]

These are gravity-based tilt components, not a complete three-dimensional orientation. Gravity cannot determine heading or rotation about the vertical axis. The bubble reaches its display boundary at 30 degrees; the numeric total continues up to 180 degrees. At an exactly inverted position, the bubble's lateral direction is undefined; the total-angle readout distinguishes it from a level, screen-up position.

Smoothing the Tilt Readings

Sensor samples arrive at varying intervals. Instead of blending angles by a fixed fraction per sample, the tool applies an exponential low-pass filter to the normalized input vector. With elapsed time \(\Delta t\) and smoothing time constant \(\tau\):

\[\alpha=1-e^{-\frac{\Delta t}{\tau}}.\] \[\mathbf g_f\leftarrow\mathbf g_f+\alpha(\hat{\mathbf g}-\mathbf g_f).\]

A larger time constant gives a quieter but slower response. After one time constant, about 63 percent of a fixed component change has reached the filter output. The filtered vector is normalized again before calculating angles. Accelerometer samples outside 3 to 17 metres per second squared are rejected as gross disturbances, but this is not motion compensation: ordinary linear acceleration can still look like tilt. Keep the phone still.

Phone Sensor Support and Privacy

Motion sensors require a secure context and may need a user-triggered permission request, particularly on iOS. Some desktop browsers expose the event APIs without delivering any readings. If acceleration data is absent, beta and gamma from DeviceOrientationEvent are converted into a direction vector and passed through the same filter. An available recent accelerometer sample takes priority over that fallback.

Browser and operating-system sensor conventions can differ. The tool uses a positive screen-normal component for screen-up rest; if your device reports the opposite sign, a known flat reference can remove that fixed offset for relative measurements. After loss of data, the last displayed number is not a new measurement: the status changes and reference capture is disabled. Neither sensor data nor calibration is stored or submitted by this tool. No gyroscope integration or compass permission is used to calculate the tilt.

Frequently Asked Questions

Does the spirit level work on iPhone and Android?

It can work on either platform when the device and browser provide motion sensor data. On iPhone, press Start sensors and grant motion access when prompted. Android browser support and permissions vary. Use HTTPS and keep the page visible. A desktop browser usually has no suitable motion sensor, even if it exposes the browser APIs.

How accurate is a phone bubble level?

Accuracy depends on the phone's sensors, its contact with the surface, motion, and calibration. The displayed tenth of a degree is a readout resolution, not a guaranteed measurement accuracy. Check a known horizontal surface first and use a dedicated, calibrated level when accuracy or safety is important.

What is the difference between a spirit level and an inclinometer?

A spirit level helps identify whether a surface is horizontal. An inclinometer measures the angle of inclination. This tool offers both views of the same sensor input: a two-axis bubble indicator and a numeric tilt angle. A saved reference changes the measurement from horizontal tilt to deviation from that reference plane.

Why does the tool show no sensor data?

Check that the page uses HTTPS, motion access is allowed, and the device has supported sensors. Press Start sensors again after changing browser permissions. If the browser still supplies no readings, the tool cannot measure an angle. An old value shown after data stops is not a current measurement.