IMU Motion and Environment Workbench

Tilt an IMU to read gravity on three axes, run motion presets, watch a gyro trace, and convert barometric pressure to altitude

animation
imu
accelerometer
gyroscope
barometric
tilt
sensors
interactive
Interactive IMU and environment lab: tilt sliders drive live ax/ay/az via gravity decomposition, atan2 tilt readout with the formula shown, motion presets with correct physical signatures including free-fall near 0 g, a gyroscope trace, and a barometric altitude mode using the standard barometric formula.
MPU6050 accel + gyro BMP280 barometric Gravity decomposition

Tilt an IMU, run motion, and read altitude from pressure.

Every number on this page follows from a stated formula. Tilt the board to split gravity across three axes, run motion presets with their real acceleration signatures, and switch to the barometric mode to turn pressure into altitude.

Total acceleration 1.00 g Static tilt keeps the vector at 1 g.
Tilt pitch 30.0° Recovered from ax by atan2.
Tilt roll 0.0° Recovered from ay and az by atan2.
Motion state Still Total is within 0.1 g of 1 g.

Three-axis accelerometer and gyro

A stationary accelerometer measures gravity, so tilt splits 1 g across the axes.

Still

Pitch (side view)

Board tipped nose-up or nose-down.

Roll (front view)

Board tipped left or right.
ax
-0.50 g-8192 LSB
ay
0.00 g0 LSB
az
0.87 g14189 LSB

Total acceleration |a| over time

Static holds at 1 g; free-fall collapses to about 0 g; walking and shake swing around 1 g.

|a| magnitude 1 g reference 0 g (free-fall)

Gyroscope rate trace (representative)

The gyro reads angular velocity in deg/s. It is near zero when still and grows with rotation; integrating it drifts over time.

gz angular rate 0 deg/s
Motion flag Still
Free-fall No
Range check Within +/-2 g

Model readings

The same instant shown as axis values, reconstructed angles, and raw counts.

Gravity vector [-0.50, 0.00, 0.87] g ax, ay, az from the tilt formula.
Total magnitude 1.00 g sqrt(ax^2+ay^2+az^2).
Reconstructed pitch 30.0° atan2(-ax, sqrt(ay^2+az^2)).
Reconstructed roll 0.0° atan2(ay, az).

Formula trace

Live substitution into the equation that produced each reading.

ax = -sin(pitch) Pitch tips gravity onto the x axis.
ay = cos(pitch) * sin(roll) Roll splits the remaining gravity onto y.
az = cos(pitch) * cos(roll) What is left of gravity stays on z.
|a| = sqrt(ax^2 + ay^2 + az^2) Static tilt always totals 1 g; motion or free-fall changes it.
pitch = atan2(-ax, sqrt(ay^2+az^2)); roll = atan2(ay, az) The same gravity split, inverted back to angles.

Learning support

These notes keep the simplified workbench honest about what a real MPU6050 and BMP280 do and do not measure.

Reading the model
Gravity, not motionA still accelerometer reports gravity. On a level board that is [0, 0, 1] g, so total is 1 g even at rest.
Tilt from gravityPitch and roll come from where gravity lands on the axes, using atan2 so the quadrant is correct.
Motion flagMotion is flagged when total leaves the 0.9 g to 1.1 g band, the same 0.1 g rule as the lab code.
Free-fall is 0 gIn free-fall the case and proof mass fall together, so there is no contact force and every axis reads about 0 g.
Raw LSB countsRaw = value in g times the LSB/g for the chosen range, matching the I2C registers you would read.
Altitude from pressureThe barometric formula maps a pressure ratio to height; it depends strongly on the sea-level reference P0.
Guided checks
Level the boardSet pitch and roll to 0 and confirm the axes read about [0, 0, 1] g with total 1 g.
Tip to 90 degreesPitch to 90 and watch gravity move fully onto ax while az drops to 0.
Run free-fallSwitch to Free-fall and confirm the total trace collapses to about 0 g, the fall-detection trigger.
Overrange the shakeRun Shake on the +/-2 g range and watch the range-check warn, then raise the range to fit the peaks.
Move the referenceHold P fixed and change P0 to see the same pressure imply a different altitude.
Detect a floorUse One floor up and confirm 0.36 hPa maps to about a 3 m step.
Technical accuracy notes
Static assumptionThe tilt formula assumes the only acceleration is gravity. Under real motion, linear acceleration corrupts the angle estimate.
Gyro driftIntegrating gyro rate accumulates error; even 0.01 deg/s of offset drifts about 0.6 deg per minute, so fusion is needed.
Representative gyroThe gyro trace here shows characteristic rate magnitudes per motion class, not a reading derived from the accelerometer.
Constants44330 m and the 0.1903 exponent come from the standard atmosphere; accuracy falls where real conditions differ.
Relative vs absoluteFloor detection uses relative pressure change; absolute altitude needs a trusted P0 that weather keeps moving.
Gimbal at 90 degreesAt pitch near +/-90 the roll estimate becomes ill-conditioned, a known limit of gravity-only orientation.