41 IMU and Barometric Calibration
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
41.1 Start With the Measurement Story
This section: Start With the Measurement Story — Picture a delivery cart that must detect a turn and a change of floor.
Calibrate Against a Known Still Point
Picture a delivery cart that must detect a turn and a change of floor. Its motion sensor reports gravity as well as movement. Its pressure sensor also reacts to weather and warm air. A changing number is not yet proof of a real move.
Begin with a known state. Hold the device still, record its pose and local pressure, and save the bias seen on each axis. Rotate it through checked directions. Move it by a known height and compare the result with a tape or fixed mark.
Test vibration, slow heat change, a new mounting angle, and a restart. Keep the raw readings, correction values, sample time, and final claim together. If the reference is old or the sensors disagree, lower confidence instead of forcing an answer.
One indoor check cannot promise accuracy on every vehicle or day. The deeper sections explain gravity, drift, alignment, pressure, and combined sensing so each correction has a reference, a limit, and a new-test trigger.
IMU and barometric readings are useful only after bias, drift, alignment, and altitude assumptions are visible. The first story is the reference condition, then the correction, then evidence that motion or pressure changes are real.
The mathematical gist. Hydrostatic balance and the ideal gas law give . With the chapter’s sea-level constants, the scale height is 8.43 km and one pascal is worth 8.32 cm near 101,325 Pa. A hypothetical 0.12 Pa pressure-noise assumption therefore becomes about 1.00 cm, rising to roughly 1.09 cm near the chapter’s 93,255 Pa example. The BMP280 data sheet instead lists 0.2 Pa RMS for its lowest-bandwidth filtered mode and 1.3 Pa RMS at full bandwidth; neither noise number is an absolute altitude-accuracy guarantee.
41.2 Learning Objectives
This section: Learning Objectives
After this page, you should be able to:
- Explain how a MEMS capacitive accelerometer turns proof-mass deflection into acceleration readings.
- Convert analog and digital IMU readings into physical units while preserving full-scale and offset evidence.
- Diagnose why accelerometers confuse gravity, tilt, vibration, and horizontal acceleration without fusion.
- Use BMP280 pressure changes as relative altitude evidence while accounting for weather drift and baseline freshness.
41.3 After Motion and Environment Labs
This section: After Motion and Environment Labs — Motion and Environmental Sensor Labs introduces MPU6050 and BMP280 wiring, expected readings, calibration steps, and exercises.
Motion and Environmental Sensor Labs introduces MPU6050 and BMP280 wiring, expected readings, calibration steps, and exercises. This page isolates the deeper measurement boundaries behind those labs: what moves inside the IMU, how raw counts become evidence, why fusion is needed, and when barometric altitude is a relative signal rather than absolute truth.
Use it when motion or floor-change logic works on a bench but becomes noisy after mounting, orientation changes, sampling changes, vibration, or slow pressure drift.
41.4 Overview: A Tiny Mass on Silicon Springs
This section: Overview: A Tiny Mass on Silicon Springs — The accelerometer in a phone, a drone, or an IoT motion tag is a MEMS device — a micro-electro-mechanical system etched from silicon.
The accelerometer in a phone, a drone, or an IoT motion tag is a MEMS device — a micro-electro-mechanical system etched from silicon. Inside is a microscopic proof mass suspended on flexible silicon beams that act as springs. When the device accelerates, inertia makes the mass lag behind, deflecting on its springs. The sensor measures that tiny deflection and reports it as acceleration.
The clever part is how the deflection is read out. The proof mass carries movable plates interleaved with fixed plates, forming capacitors. As the mass shifts, the gaps change, and so does the capacitance. This is capacitive transduction shrunk to the micrometre scale: mechanical motion becomes a capacitance change becomes a voltage.
That means the first lab check is physical, not just digital. With the board flat and still, one accelerometer axis should report about +1 g or -1 g depending on mounting, while the other two axes sit near 0 g. If all axes hover near 0 g, the code may be reading the wrong register or scale. If the total magnitude is far from 1 g while stationary, the offset calibration, range setting, or board orientation needs attention before motion detection can be trusted.
The BMP280 side of the lab uses a different physical proxy. Pressure falls as altitude rises, so a barometric sensor can estimate relative height changes even though weather systems shift the absolute pressure over time. The shared lesson is that motion and environmental labs both need a known reference: gravity for the IMU, a stable desk-height baseline for pressure, and repeated samples to separate real movement from startup noise.
Intuition: picture a weight hanging between two charged plates. Push the whole assembly sideways and the weight swings, moving closer to one plate and further from the other. The changing gaps change the capacitances, and that difference is the acceleration signal.
41.4.1 Overview Knowledge Check
41.5 Deflection to Volts
This section: Deflection to Volts — The mechanics are a mass on a spring.
The mechanics are a mass on a spring. An inertial force F = m·a deflects the mass until the spring pushes back equally, so the static deflection is:
m·a = k·x -> x = m·a / k = a / ω0^2 k = spring stiffness, ω0 = sqrt(k/m) = resonant frequency Parallel-plate capacitance: C = ε · A / d as the mass moves, one gap d shrinks and the other grows, giving a differential capacitance change proportional to x
That same equation is also the whole story of why MEMS accelerometers can be shrunk onto a chip in the first place. Writing the resonant frequency as f0 = ω0 / 2π = (1/2π)·sqrt(k/m) turns the deflection equation into x = a / (2πf0)^2: for a fixed target f0, only the ratio k/m matters, not k and m individually. Shrinking the proof mass alone would push f0 up and shrink the deflection per g; to keep the same sensitivity at the same resonant frequency, the spring has to be softened by the same factor the mass was reduced. A miniaturized accelerometer therefore needs a small mass and a proportionally weak spring — it is the ratio, not the size, that is being designed. At a fixed target f0, scaling m and k by the same factor leaves deflection per acceleration unchanged; readout geometry and noise still need separate evaluation as the die gets smaller.
Before acting on deflection to volts, inspect Figure 41.2 because it condenses the evidence path: an ADXL335 breakout turns the tiny proof-mass deflections described above into three analog voltages. The central MEMS package contains all three axes; the labeled X, Y, and Z outputs are the signals a calibration rig must map from volts back to acceleration. Photo: oomlout, CC BY-SA 2.0.
A blue ADXL335 three-axis analog accelerometer breakout board shows its central sensor chip, printed X, Y and Z markings, and labeled connection pads. A separate strip of six metal header pins lies to the right on a white background.
Read Figure 41.2 from the central MEMS package outward to the labelled X, Y, and Z connections. The package converts proof-mass deflection into three analogue outputs; the breakout only makes those supply and signal pins accessible. Follow each axis into the calibration record rather than treating the board as a ready-made orientation estimate: offset, scale, mounting direction, ADC reference, and cross-axis behaviour still determine what the voltages mean.
41.5.0.1 Dynamic response is still the same mechanical model
When the input changes quickly, the proof mass is better treated as a mass-spring-damper rather than a static spring alone. The force balance is:
F(t) = m*x'' + b*x' + k*x X(s) / F(s) = (1/m) / (s^2 + (b/m)*s + k/m)
The step response depends on damping. An underdamped sensor overshoots and rings, a critically damped sensor reaches the final value quickly without overshoot, and an overdamped sensor is stable but slow. Other real channels can add simple delay, decay, or a combination of both. That is why bandwidth, settling time, and filtering belong in the sensor evidence record: raise bandwidth only when the physical event is fast enough to justify the extra noise.
41.5.0.2 Worked example: reading an ADXL335 analog accelerometer
The ADXL335 outputs a ratiometric analog voltage,
typically 300 mV per g, centered at half the supply
(0 g sits at Vs/2, about 1.5 V on a 3 V rail):
At rest, flat on a bench, the Z axis feels gravity:
Vz = 1.5 V + (1 g × 0.300 V/g) = 1.80 V
X and Y axes feel 0 g:
Vx = Vy = 1.5 V
Tilt the board 30° and Z feels cos(30°) = 0.87 g:
Vz = 1.5 V + 0.87 × 0.300 = 1.76 V
Because the output is ratiometric, referencing the ADC to the same supply cancels supply drift — the same trick that helps resistive dividers, applied to a MEMS part.
A digital IMU such as the MPU6050 hides the analog voltage, but the same calibration thinking still applies. In the +/-2 g accelerometer range, one g is 16,384 counts, so a stationary Z reading of 15,900 counts is about 0.97 g. A useful calibration record stores the raw X/Y/Z counts, converted g values, total magnitude, board orientation, and whether the device was still. That record catches swapped axes and wrong full-scale constants before they become false motion events.
For motion detection, avoid testing a single axis in isolation. A tilt can move gravity from Z into X or Y without the device translating. The magnitude test sqrt(ax^2 + ay^2 + az^2) should stay near 1 g while stationary at any orientation; walking, taps, and vibration appear as deviations around that baseline. The threshold then becomes a design choice tied to the activity you want to detect.
41.5.1 Practitioner Knowledge Check
41.6 Gravity, Brownian Noise, Bandwidth
This section: Gravity, Brownian Noise, Bandwidth — Three physical realities shape what a MEMS accelerometer can and cannot tell you.
Three physical realities shape what a MEMS accelerometer can and cannot tell you. The sensor reports specific force, not a labelled distinction between gravity, vibration, and intentional movement. Software has to infer that distinction from time, context, and companion sensors.
It always feels gravity
A capacitive accelerometer is DC-capable, so at rest it reads 1 g along the vertical. That makes it a fine tilt sensor — but it cannot, by itself, separate a tilt from a real horizontal acceleration, since both are just specific force.
Brownian noise floor
The proof mass is so tiny that random thermal-mechanical (Brownian) buffeting jostles it, setting a noise floor quoted in micro-g per sqrt(Hz). A smaller mass means more Brownian noise, so there is a size-versus-noise trade-off.
Quantitatively, that buffeting is a force noise with spectral density Sn_force(f) = 4·kB·T·k / (ω0·Q), where Q is the resonator's quality factor. For a MEMS cantilever in air, squeeze-film air damping typically limits Q to only about 30–50 — far below what a vacuum-packaged resonator can reach. A softer spring k lowers this noise floor for a given Q, which is one more reason the miniaturization trade-off above pairs a small mass with a weak spring rather than shrinking either alone.
Bandwidth and resonance
The spring-mass system has a resonant frequency; useful measurement stays well below it. On parts like the ADXL335 you set the bandwidth with output capacitors, trading response speed for less noise.
Why fusion exists
Because the accelerometer confuses gravity with motion and is noisy under vibration, real systems fuse it with a gyroscope, which is clean short-term but drifts. Each covers the other's weakness.
Before choosing the filter constant, use Figure 41.1 to distinguish the raw sources, their calibration boundary, and the orientation quantities each complementary path can support.
Gyroscope, accelerometer and magnetometer inputs feed calibration, roll/pitch fusion and tilt-compensated yaw calculation. Sensor roles distinguish fast angular rate, gravity reference and magnetic heading.
Read Figure 41.1 from the gyroscope and accelerometer inputs. The gyro follows fast turns but drifts with time. The accelerometer gives a gravity guide but is noisy in motion. Their joint path can estimate roll and pitch. The magnetic input needs tilt correction before it can help with yaw. Each source passes through a calibration block first. Bias or scale error at that point harms every later angle. This split also explains why pressure needs its own check. It should not be mixed into pose without evidence about height and weather.
These limits explain the whole design pattern of inertial sensing: the accelerometer gives an absolute, gravity-referenced tilt that never drifts but is noisy and ambiguous under motion; the gyroscope gives smooth short-term rotation that slowly drifts. Fusing them is not a luxury — it is how you get a stable orientation from imperfect parts.
The simplest fusion logic is a complementary filter. At each sample it trusts the gyroscope for the fast change, then slowly pulls the estimate back toward the accelerometer angle: angle = alpha * (angle + gyro_rate * dt) + (1 - alpha) * accel_angle. A larger alpha follows fast rotations more smoothly but corrects drift slowly; a smaller alpha rejects drift faster but lets vibration shake the angle estimate.
Environmental pressure adds another kind of ambiguity. A BMP280 can see a floor change because pressure changes with height, but it cannot tell whether pressure changed because the device moved upward or because weather drifted over minutes. The robust lab pattern is therefore the same as IMU fusion: keep a short-term baseline, log raw and converted values, and compare the inferred event against another clue before making a decision.
41.6.1 Under-the-Hood Knowledge Check
41.7 Release Checklist
This section: Release Checklist — Start by the IMU full-scale range, LSB-per-unit constants, raw offsets, and mounting orientation are recorded with the calibration data.
Before relying on motion or pressure-derived events, confirm these points:
Start by the IMU full-scale range, LSB-per-unit constants, raw offsets, and mounting orientation are recorded with the calibration data. Then stationary accelerometer readings have total magnitude near 1 g, not merely near zero on each axis. Next motion thresholds are tested across orientation changes, taps, vibration, and expected activity patterns. After that gyroscope integrations include sample interval evidence and a drift-correction plan, such as a complementary or Kalman filter. Continue by pressure-based floor or altitude logic uses a short-term baseline and relative changes rather than unqualified absolute pressure. Finally each event record stores raw values, converted units, baseline timestamp, threshold, and any companion evidence used for confirmation.
41.8 See Also
This section: See Also — Start by Motion and Environmental Sensor Labs for MPU6050 and BMP280 setup, code, and exercises.
Start by Motion and Environmental Sensor Labs for MPU6050 and BMP280 setup, code, and exercises. Then Sensor Data Processing for filtering and confidence checks after acquisition. Next Sensor Calibration Techniques for reference records, offsets, and drift management. Finally Sensor Power Management for duty-cycling IMUs and pressure sensors in battery nodes.
41.9 Next
This section: Next — Return to Motion and Environmental Sensor Labs once the calibration boundaries are clear, then continue to Light and Proximity Sensors for optical, PIR, ultrasonic, and capacitive readout practice.
Return to Motion and Environmental Sensor Labs once the calibration boundaries are clear, then continue to Light and Proximity Sensors for optical, PIR, ultrasonic, and capacitive readout practice.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
