Reading a Phone Compass Without Trusting It Blindly
August 28, 2026 · DevTools
A phone compass isn't a separate app feature — it's the device's magnetometer, read through DeviceOrientationEvent.alpha and turned into a heading in degrees. The Digital Compass tool reads that value directly, no native app or install required, and falls back to a manual simulator the moment the sensor isn't available.
Why compasses lie near electronics
A magnetometer measures the ambient magnetic field, then subtracts Earth's expected field to infer heading. Anything with its own field — a phone case with a magnetic clasp, a laptop speaker, a car dashboard, steel rebar in a floor — distorts that reading. Indoors, near appliances, or inside a metal-frame building, expect drift of tens of degrees. The fix isn't software: move away from the interference source and let the sensor resettle, ideally after the figure-8 recalibration gesture most OSes support.
Why iOS asks permission first
Safari and other iOS browsers gate DeviceOrientationEvent behind an explicit requestPermission() call that must run from a user gesture — a page can't silently read your heading. The tool's "Enable compass" button exists specifically for that prompt; if it's denied, or the API doesn't exist (most desktop browsers), the tool switches to a manual dial you drag by hand.
When to trust it, when not to
Good enough for orienting a map, aligning a satellite dish, or settling a "which way is north" argument. Not accurate enough for surveying, aviation, or anything with legal or safety weight — those need a calibrated magnetic compass or a proper GPS-based heading, which is what the GPS Speedometer falls back to when you're actually moving. For a tilt reading instead of a heading, the Digital Bubble Level uses the same device-orientation API on a different axis.