If you are building a drone flight controller, a hiking altimeter, or a high-altitude balloon payload, you need to know exactly how a modern altitude sensor translates atmospheric weight into usable data. The direct answer: a current-generation sensor like the Bosch BMP390 outputs a 24-bit digital pressure reading via I2C or SPI. You must convert this raw ADC count into Pascals using factory-stored calibration coefficients, and then into meters using the international barometric formula. Unlike legacy analog pressure transducers, there is no analog voltage to measure with a multimeter; the signal is entirely digital.
The Physics: How a Piezoresistive Altitude Sensor Works
At the heart of a solid-state altitude sensor is a micromachined piezoresistive silicon membrane suspended over a vacuum cavity. As atmospheric pressure pushes down on this membrane, it physically deforms. This deformation alters the electrical resistance of piezoresistors embedded in the silicon, which are wired into a Wheatstone bridge circuit. When a reference voltage is applied, the bridge becomes unbalanced, generating a microvolt-level signal proportional to the applied pressure.
However, silicon is highly sensitive to temperature, meaning the membrane's stiffness and the piezoresistors' baseline resistance will drift as ambient heat changes. To solve this, the sensor integrates a secondary thermistor directly on the silicon die. The internal ASIC reads both the pressure bridge and the thermistor simultaneously, allowing the sensor's internal logic (or your microcontroller) to apply real-time thermal compensation to the pressure reading before it ever reaches your code.
Hardware Interfacing: Wiring and Power Requirements
A common mistake on the bench is conflating digital barometric sensors with analog pressure transducers. The BMP390 and similar MEMS sensors do not output a 0-3.3V analog signal. They output digital I2C or SPI data packets. Supplying them with 5V logic without a level shifter will destroy the internal ASIC, as the absolute maximum supply voltage is 3.6V.
| Sensor Pin | ESP32 / 3.3V Arduino Pin | Function & Notes |
|---|---|---|
| VCC / VIN | 3.3V | Supply range: 1.65V to 3.6V. Do not exceed 3.6V. |
| GND | GND | Common ground. Keep star-grounded to avoid noise. |
| SCL / SCK | GPIO 22 (I2C) or GPIO 18 (SPI) | Clock line. Use 4.7kΩ pull-ups for I2C. |
| SDA / SDI | GPIO 21 (I2C) or GPIO 23 (SPI) | Data line. Use 4.7kΩ pull-ups for I2C. |
| CSB | 3.3V (I2C) or GPIO 5 (SPI) | Chip select. Tie to VCC for I2C mode. |
| SDO | GND or 3.3V | I2C address select. GND = 0x76, VCC = 0x77. |
From Raw ADC to Meters: The Compensation Math
When you read the pressure registers on the BMP390, you do not get Pascals. You get a 24-bit unsigned integer representing the raw ADC count. To get a physical unit, you must apply the sensor's unique factory calibration parameters (stored in its NVM) to compensate for silicon manufacturing variances. Libraries like Adafruit's BMP3XX handle this heavy lifting, but understanding the math is critical for debugging drift.
Step 1: Raw to Compensated Pressure (Pa)
The sensor provides calibration coefficients (e.g., T1, T2, T3 for temperature; P1 through P11 for pressure). The raw temperature ADC is compensated first, because the pressure compensation algorithm requires the compensated temperature value as an input variable. The result is a highly accurate pressure value in Pascals (Pa).
Step 2: Pressure to Altitude (Meters)
Once you have the compensated pressure ($P$) in Pascals, you convert it to altitude using the international barometric formula. The standard approximation used in most embedded libraries is:
Altitude (m) = 44330.0 * (1.0 - pow((P / P0), (1.0 / 5.255)))
Calibration and Scaling: The $P_0$ variable is the sea-level reference pressure. If you use the standard 101325 Pa, you get pressure altitude (what airplanes use). If you want absolute altitude above sea level for your specific GPS coordinate, you must fetch the current local barometric pressure from a nearby METAR weather station or a local airport ATIS feed and plug that value into $P_0$. For relative altitude (e.g., measuring a drone's climb from its takeoff point), simply record the sensor's pressure output at power-on and use that as your $P_0$.
Real-World Interference and Mounting Tactics
Silicon MEMS pressure sensors are incredibly sensitive, which makes them vulnerable to environmental interference that has nothing to do with atmospheric weight. If your altitude readings are jittering or drifting, check these three culprits:
- Light Interference: Silicon is photosensitive. If direct sunlight or a high-intensity LED hits the sensor's gel cavity, it generates a photocurrent that the ASIC reads as a pressure spike. Fix: Ensure the sensor is mounted in an opaque enclosure, or cover the gel with a dab of black silicone conformal coating (leaving the microscopic vent hole clear).
- Acoustic Noise and Wind: Fast-moving air over the sensor port creates a low-pressure zone via the Bernoulli effect, and acoustic vibrations (like propeller wash on a drone) can physically vibrate the membrane. Fix: Wrap the sensor in open-cell acoustic foam or route the pressure port through a labyrinthine baffle to dampen high-frequency noise without blocking static air pressure.
- Thermal Shock: If you mount the sensor near a voltage regulator, an ESC, or an HVAC vent, rapid temperature changes will outpace the internal thermistor's compensation algorithm. Fix: Thermally isolate the sensor board using double-sided foam tape and keep it away from heat-generating components.
For deeper integration into flight stacks, reviewing the ArduPilot barometer documentation provides excellent insights on how open-source autopilots filter out these exact environmental noise sources using EKF (Extended Kalman Filter) sensor fusion.
Altitude Sensor FAQ
How accurate is an altitude sensor for drone flight controllers?
Modern sensors like the Bosch BMP390 offer a relative altitude accuracy of ±0.1 meters under ideal, static conditions. However, in a real-world drone environment with propeller wash and wind, practical accuracy drops to ±0.5 meters. This is why flight controllers never rely on the barometer alone; they fuse the barometric altitude with accelerometer data and GPS (if available) to maintain a stable hover.
Why does my altitude sensor drift when the weather changes?
Barometric sensors do not measure height directly; they measure the weight of the air column above them. When a low-pressure weather front moves into your area, the atmospheric pressure drops. If your code is using a hardcoded sea-level reference ($P_0$), the sensor will interpret this weather-related pressure drop as a gain in elevation, causing your calculated altitude to slowly drift upward over the course of the day. You must periodically update $P_0$ with live local weather data for long-term absolute accuracy.
Can I use an altitude sensor underwater or in a vacuum chamber?
No. Standard MEMS altitude sensors are designed for atmospheric gases. Submerging the sensor in water will short the internal ASIC and potentially rupture the delicate silicon membrane, as water is incompressible and exerts vastly higher hydrostatic pressure than air. In a vacuum chamber, the sensor will simply bottom out at its minimum readable pressure (usually around 30,000 Pa for the BMP390) and cannot measure the hard vacuum below that threshold. For underwater depth, you need a dedicated, potted hydrostatic pressure transducer.






