# Sensor hacking 101 > Accelerometers measure specific force, not “zero when still.” A gentle primer on what each phone sensor really reports. 2025-10-08 · 20 min read · phyzix, physics · by ntan (ntan) for uranashel Canonical HTML: https://uranashel.com/blog/phyzix-sensor-hacking.html --- Every smartphone sold in the last decade carries a cluster of MEMS sensors — tiny silicon structures that move when you move, bend when air pressure changes, and deflect in magnetic fields. Most owners never see the numbers. They feel a smooth glass rectangle, while underneath it a bundle of transducers samples the physical world at 50–200 Hz. Phyzix exists to put those numbers on screen, in SI units, with no smoothing you did not ask for. Before you build anything serious on sensor data (a parking walk in Wheria, a classroom lab, a vibration baseline for a failing pump) you need to know what each chip actually measures, because the spec sheet is consistently more optimistic than the silicon. ## Accelerometers measure specific force, not motion The most common misconception in introductory sensor work is that an accelerometer reports how fast you are moving. It does not. A MEMS accelerometer measures **specific force**: the net contact force per unit mass acting on a microscopic proof mass suspended inside the chip, expressed in m/s². Lay a phone flat on a table and the vertical axis reads about −9.81 m/s², with the sign depending on axis convention. The phone is going nowhere. The table is pushing up against gravity, and the sensor reports that reaction force. Drop the same phone in a vacuum chamber and all three axes head toward zero, because free fall involves no contact force at all. In symbols the output is `f = a − g`: proper acceleration minus the gravitational field, resolved in the sensor frame. That one distinction separates working sensor fusion from code that integrates garbage into position. Double integration amplifies a constant bias as `Δx = ½·b·t²`. A respectable 1 mg bias (0.0098 m/s²) becomes 4.4 m of position error after 30 s, and consumer chips are rarely that polite for long. This is why Wheria never double-integrates accelerometer data for position, and why the blue dot in naive IMU demos drifts across the parking lot inside 30 s. Phyzix shows the raw trace on a live graph so you can watch the physics directly. Shake the phone and oscillations ride on top of the gravity vector. Rotate it slowly and the 9.81 migrates from one axis to the next as the sensor frame turns. Students who expected zero at rest tend to go quiet for a moment. One warning about convenience APIs. Both platforms offer a derived linear-acceleration stream with gravity already subtracted, and it is tempting to treat that as ground truth. It is the output of the OS's own fusion filter, complete with that filter's lag and assumptions. Phyzix deliberately graphs the raw stream first, so you learn what the estimate is built from before you decide to trust it. ## Watching a gyroscope drift A gyroscope outputs angular velocity in rad/s around each axis, and it needs no gravity reference. Inside the package a proof mass vibrates along one axis; rotating the chip adds a Coriolis acceleration `a_c = 2·Ω×v` at right angles to that vibration, and capacitive electrodes read the deflection. Direct rotation sensing makes gyros excellent at tracking fast orientation changes between steps in a parking garage. The catch is bias. Consumer MEMS gyros drift 1–3° per minute while sitting perfectly still, and the integral `θ(t) = ∫ω·dt` faithfully accumulates every bit of it. Phyzix ships a small experiment for exactly this: spin the phone on a table against a printed protractor, then compare the integrated angle with what the paper says. The gap is visible after 10 s. Because of that gap, every practical orientation system fuses the gyro with something absolute: the accelerometer for tilt whenever linear acceleration is small, the magnetometer for yaw whenever the field is clean. It is also why Wheria corrects heading with magnetometer updates while the field is trustworthy, then falls back to gyro-only dead reckoning the moment steel pillars make the compass lie. The classic entry point is a complementary filter, which Phyzix exposes as a toggle on the orientation screen: ``` // per sample, dt in seconds gyro_pitch = pitch + w_x * dt // fast, drifts acc_pitch = atan2(a_y, a_z) // absolute, noisy pitch = 0.98 * gyro_pitch + 0.02 * acc_pitch ``` Two lines of fusion and one tuning constant. The 0.98 says: trust the gyro over fractions of a second, and let the accelerometer pull the estimate back over a few seconds. A Kalman filter is the grown-up version of the same bargain, with weights derived from noise statistics rather than tuned by eye — that derivation lives in our [Kalman filter post](https://uranashel.com/blog/kalman-filter-parking.html). ## The magnetometer draws an ellipsoid The magnetometer returns a three-component vector of the local magnetic field in microtesla. Earth's field runs 25–65 µT depending on latitude and local geological anomalies; around Ho Chi Minh City it sits near 43 µT. In open air the vector points toward magnetic north with a predictable inclination angle. Inside a parking garage everything changes. Steel reinforcement and your own car distort the field until the apparent north rotates 40–90° while the phone lies motionless. Plot uncalibrated samples in 3D as you rotate the phone and they trace an off-center ellipsoid instead of a sphere centered at the origin. The constant offset is hard-iron bias from nearby ferromagnetic parts, typically tens of µT on the handsets we test. The stretching is soft-iron distortion from the surrounding steel. Phyzix draws raw and calibrated vectors side by side, so you can watch the ellipsoid recenter and round out as you walk from the street down into Landmark 81's basement. The correction itself is a figure-8 motion, or slow online fitting during straight walks; either way it is the same pipeline Wheria runs in production, documented in our [compass calibration post](https://uranashel.com/blog/compass-calibration-story.html). ## Barometers, light, and the environment The barometer reports absolute atmospheric pressure in hPa. Hydrostatics gives `ΔP = ρ·g·Δh`, roughly 12 Pa per meter of height near sea level, so one garage floor of 3.2 m is a 38 Pa step. Weather fronts move the absolute reading by hundreds of pascals over a few hours. Only the differential since you tapped "parked" carries floor information, high-pass filtered to reject that slow drift. Phyzix shows absolute pressure alongside the delta from a user-set baseline; the full floor-counting math, including why 0.3–1 Pa RMS of sensor noise still resolves a 38 Pa step cleanly, is in the [barometer parking post](https://uranashel.com/blog/barometer-parking-math.html). The ambient light sensor rounds out the environmental set. It reports illuminance in lux and makes a decent inverse-square demo: measure a desk lamp at 0.5 m and again at 1 m, then check the ratio against `E ∝ 1/r²`. Expect a factor near 4, minus whatever the wall reflections contribute. Many models saturate in direct sunlight and quantize coarsely at the dim end, which is itself a useful lesson about instrument range. ## Bench notes: six phones on a granite slab Numbers in posts like this should come from somewhere. Last spring we clamped 6 phones (3 iPhone, 3 Android) to a granite surface plate for 48 h and logged every sensor at its maximum advertised rate. Granite does not fidget. Every wiggle in those logs is the sensor's own opinion. - **Accelerometer:** 1.5–4 mg RMS of noise at 100 Hz depending on the handset, and the bias moved by up to 8 mg between cold start and thermal equilibrium some 20 min later. Thermal drift dwarfs the white noise on a timescale of minutes. - **Gyroscope:** 0.05–0.12 °/s RMS at rest, with integrated heading wandering 1–3° per minute — matching the folklore for once. - **Magnetometer:** 0.3–1.2 µT RMS, plus a 6 µT step on one device the instant a charging cable was plugged in. Current makes fields, and the chip cannot know the field is your charger. - **Barometer:** 0.3–1 Pa RMS once warm, but the first 10 min of each log showed a 4–6 Pa slope from self-heating. That is about 0.4 m of phantom altitude, which matters when a floor is worth 38 Pa. One Android also promised 200 Hz and delivered 197 Hz with visible timestamp jitter. Integrate against per-sample timestamps, always. The nominal rate is a marketing number. ## From classroom to production pipeline The gap between reading sensor values and navigating a user back to their car is signal processing plus honest uncertainty. Phyzix is deliberately the first half of that journey: raw SI units, live graphs, exportable CSV, bilingual labels so Vietnamese students do not have to parse English error strings. Wheria is the second half: step detection from accelerometer peaks, heading fusion from gyro and magnetometer, floor hints from barometer deltas, all combined in a Kalman filter that outputs a confidence badge instead of a fake precise dot. To follow the full chain, start with step detection in our [IMU odometry post](https://uranashel.com/blog/step-detection-imu.html), then read how the pieces fuse in the [indoor navigation pipeline](https://uranashel.com/blog/building-wheria-indoor.html); the classroom side of the same instrument set is covered in the [pocket lab post](https://uranashel.com/blog/phyzix-pocket-lab.html). The physics is the same in both apps. Phyzix just shows you the wires. --- uranashel · [Home](https://uranashel.com/) · [Apps](https://uranashel.com/apps.html) · [Lab](https://uranashel.com/lab.html) · [About](https://uranashel.com/about.html) · [Blog](https://uranashel.com/blog/) · [Developers](https://uranashel.com/developers/) · [API docs](https://uranashel.com/docs/) · [Privacy](https://uranashel.com/privacy.html) Machine-readable: [llms.txt](https://uranashel.com/llms.txt) · [sitemap.xml](https://uranashel.com/sitemap.xml) · [openapi.json](https://uranashel.com/openapi.json) · [API](https://uranashel.com/api/v1/)