Electronics Design AU
Sensors

How Do You Interface a MEMS Barometric Pressure Sensor?

Last updated 7 July 2026 · 6 min read

Direct Answer

A MEMS barometric pressure sensor measures absolute atmospheric pressure using a piezoresistive or capacitive membrane that deflects under pressure, with signal conditioning and an ADC integrated into the sensor package. Modern sensors (Bosch BMP388/BMP390, TE MS5611, ST LPS22HB) communicate over I2C or SPI and output raw pressure and temperature ADC codes that must be corrected using factory-programmed calibration coefficients stored in the sensor's own memory — the sensor is not usable without applying this compensation, which the manufacturer's datasheet specifies as a fixed polynomial or lookup formula. Altitude is then derived from the compensated pressure reading using the barometric formula, referenced against a known sea-level pressure (which varies day to day with weather, so absolute altitude accuracy depends on how current that reference value is) — relative altitude change (e.g. floor detection, climb rate) is far more reliable than absolute altitude from pressure alone.

Detailed Explanation

Pressure sensors are named in passing across this site as an example of a ratiometric or bridge-output sensor — but the modern, dominant approach (a digital MEMS sensor with I2C/SPI output and on-board compensation) has no dedicated coverage. This page covers that approach directly: how the sensor works, why factory calibration coefficients are mandatory rather than optional, and how altitude is derived from a pressure reading.

How a MEMS Pressure Sensor Works

A MEMS barometric pressure sensor uses a thin silicon membrane suspended over a sealed reference cavity. Ambient pressure deflects the membrane; the deflection is measured either piezoresistively (strain-sensitive resistors change value as the membrane bends) or capacitively (the membrane forms one plate of a capacitor whose spacing to a fixed plate changes). Unlike the raw resistive or capacitive sensors covered in sensor signal conditioning basics, modern pressure sensor ICs integrate the excitation, amplification, ADC, and a microcontroller-readable digital interface (I2C or SPI) into a single small package — the designer reads a digital pressure and temperature value directly, with no external analog signal conditioning required.

Factory Calibration Coefficients Are Mandatory

Every individual sensor die has small manufacturing variations. To correct for this, the manufacturer characterises each unit at the factory across a range of pressures and temperatures and stores a set of unique calibration coefficients in the sensor's own non-volatile memory. At startup, the host reads these coefficients (typically over the same I2C or SPI bus — see what is I2C? for the bus protocol these sensors commonly use) once, then applies the datasheet's specified compensation formula to every subsequent raw pressure and temperature ADC reading.

This is not an optional refinement — the raw ADC output from a MEMS pressure sensor is not directly interpretable as a pressure value at all without the per-unit compensation formula applied, unlike, say, a linear analog output sensor where a rough reading is still meaningful before calibration.

Temperature Compensation Is Built Into the Pressure Formula

The pressure-sensing element's response has its own temperature dependence, so the sensor also includes an internal temperature sensor purely to correct the pressure reading — this is a different purpose from reporting ambient temperature as a separate measurement, although the compensated temperature value is usually exposed as a useful secondary output. See the FAQ above for why this is a single combined compensation step, not two separate corrections.

Deriving Altitude from Pressure

Altitude is calculated from compensated pressure using the barometric formula, which relates pressure to altitude assuming the International Standard Atmosphere's standard temperature lapse rate and a reference sea-level pressure (standard reference: 101,325 Pa). A commonly used approximate form:

altitude (m) ≈ 44330 × (1 − (P / P0)^0.1903)

where P is the measured pressure and P0 is the sea-level reference pressure. Because P0 varies with weather (see the FAQ above), absolute altitude accuracy depends entirely on how current and locally accurate the P0 value used is — for applications needing genuine absolute altitude (aviation, precise elevation logging), the sensor must be periodically referenced against a known local pressure. For relative measurements — detecting a floor change in a building, measuring climb rate, or triggering an event on a pressure change — the P0 reference cancels out and the sensor performs reliably without any external reference.

I2C vs SPI, and Common Parts

Most MEMS pressure sensors support both I2C and SPI, selected by a pin strap or by which bus the host actually drives:

  • Bosch BMP388/BMP390 — I2C or SPI, integrated pressure and temperature, widely used in drones and wearables for altitude/climb-rate sensing.
  • TE Connectivity MS5611 — SPI or I2C, higher pressure resolution (commonly used in GPS/altitude-fusion applications and weather stations).
  • ST LPS22HB — I2C or SPI, compact package, common in wearable and IoT designs alongside an accelerometer/IMU on the same board.

Bring-up follows the same pattern as any other digital sensor (see how to interface a digital temperature sensor for the equivalent I2C bring-up sequence): confirm the device ID/WHO_AM_I register, read the calibration coefficients once at startup, then poll or use a data-ready interrupt to read raw pressure and temperature, applying the compensation formula in firmware (most manufacturers publish reference C code implementing the exact polynomial).

Design Considerations

  • Seal the sensor's pressure port appropriately for the enclosure. A pressure sensor needs an air path to the ambient environment through the enclosure — a sealed enclosure with no vent will read the trapped internal air pressure, which drifts with internal temperature rather than tracking true ambient pressure. Use a vented enclosure design or a dedicated gasketed port matched to the sensor manufacturer's mechanical guidance.
  • Isolate the sensor from self-heating sources on the PCB. A pressure sensor placed next to a voltage regulator or other heat-generating component will read a locally elevated temperature, degrading the accuracy of its own temperature-compensation step even though the pressure reading itself is less directly affected.
  • Budget conversion time against your required update rate. Higher oversampling settings (used to reduce noise) increase each conversion's completion time; check the datasheet's conversion time table against your target sample rate before selecting an oversampling mode.

Zeus Design's electronics engineering team integrates barometric pressure and other environmental sensors into embedded products as part of complete product electronics design.

Common Mistakes

  • Using the raw ADC output without applying the calibration coefficients. Covered in detail above — the raw reading is specific to that individual die and is not a valid pressure value on its own.
  • Assuming absolute altitude accuracy without a current local pressure reference. See the FAQ above — day-to-day weather-driven pressure changes alone can shift the calculated absolute altitude by more than a hundred metres if the sea-level reference isn't kept current.
  • Sealing the sensor inside an unvented enclosure. Trapped air pressure inside a sealed housing responds to internal temperature changes rather than tracking true ambient pressure, producing readings that look like real-world pressure changes but are actually enclosure thermal effects.
  • Placing the sensor next to a heat-generating component on the PCB. Localised self-heating from a nearby regulator or high-current trace skews the sensor's own temperature-compensation input, reducing measurement accuracy even though the sensor's electrical interface still functions correctly.

Frequently Asked Questions

Why can't I use a barometric pressure sensor for accurate absolute altitude?
Absolute altitude from pressure depends on knowing the current sea-level pressure at your location, which changes continuously with weather (typically by 1–2 kPa over a few days, corresponding to 100+ metres of apparent altitude error if the reference isn't updated). Aviation altimeters solve this by having pilots dial in the current local sea-level pressure (QNH) before flight. Without a live local reference, absolute altitude from a barometric sensor alone can be off by tens to over a hundred metres. Relative altitude change over a short period — climb rate, floor-change detection in a building, or fusing barometric data with GPS altitude for correction — is a far more reliable use of the sensor than absolute altitude in isolation.
Why does a pressure sensor's datasheet include so many calibration coefficients?
Each individual sensor die has small manufacturing variations in its piezoresistive or capacitive elements, so the manufacturer measures every unit at the factory across a range of pressures and temperatures and stores unique compensation coefficients in the sensor's own non-volatile memory (typically read once at startup). The host MCU reads these coefficients and applies the datasheet's specified compensation formula (a second- or third-order polynomial in most Bosch and TE parts) to the raw ADC output to get a calibrated pressure and temperature reading. Skipping this step and using the raw ADC code directly produces a reading that is wrong by an amount specific to that individual sensor unit, not a fixed offset you could hard-code.
Do I need to compensate for temperature separately from pressure?
No — in a MEMS pressure sensor, temperature compensation is built into the same calibration formula as the pressure compensation, not a separate correction step. The sensor measures its own die temperature (via an integrated temperature sensor) specifically to correct for the pressure-sensing element's temperature dependence; the compensated temperature reading is a useful byproduct but the primary reason it's measured is to correct the pressure value itself. Applying the manufacturer's compensation formula with the sensor's own temperature reading, as specified in the datasheet, handles this automatically.

References

Related Questions

Related Forum Discussions