MAVLINKHUD

Barometer Physics

Executive Summary

The Barometer is the primary source of relative altitude for most drones. It measures atmospheric pressure. However, pressure changes with Weather, Temperature, and Propeller Wash. ArduPilot includes sophisticated compensation logic to prevent these factors from causing altitude glitches.

Theory & Concepts

1. How a MEMS Barometer Works

Modern drones use MEMS (Micro-Electro-Mechanical Systems) sensors.

  • The Mechanism: Inside the chip, there is a microscopic silicone diaphragm with a vacuum on one side. As air pressure pushes on the diaphragm, it bends.
  • The Measurement: Piezo-resistive strain gauges on the diaphragm change resistance as it bends. This resistance change is converted to a digital Pressure value.
  • The Problem (Temperature): Silicone expands and contracts with heat. This expansion stresses the strain gauges just like pressure does. A hot sensor looks like a "High Pressure" sensor (low altitude).
  • The Solution: Every sample includes a Temperature reading. The driver applies a polynomial curve (calibration coefficients stored in the sensor's ROM) to subtract the thermal expansion effect.

2. Weather vs. Altitude (QNH)

  • Weather: A low-pressure storm front moves in. The barometer drops. The drone thinks it climbed 50 meters.
  • Compensation: ArduPilot does not track weather. It assumes "Pressure Change = Altitude Change".
  • Drift: This is why Baro Altitude drifts over long flights (20+ minutes). GPS Altitude (though noisier) is absolute and does not drift with weather. The EKF fuses both to get the best of both worlds (Baro for short-term precision, GPS for long-term stability).

Architecture (The Engineer's View)

1. The Hypsometric Equation

Converting Pressure to Altitude is not linear.

  • Formula: Altitude = 44330 * (1 - (Pressure / Ground_Pressure)^(1/5.255))
  • Ground Pressure: The EKF captures the "Ground Pressure" at arming. All flight altitudes are relative to this zero point.
  • Temperature: Air density changes with heat. AP_Baro tracks _ground_temperature to scale the altitude calculation accurately.

2. Ground Static Effect (GSE)

This is the most common issue on takeoff.

  • The Physics: When a multicopter takes off, the propellers push a massive column of air downwards. This creates a high-pressure zone under the drone.
  • The Sensor: The barometer sees High Pressure -> Thinks "Below Sea Level".
  • The Result: The drone thinks it is underground. When it climbs out of the ground effect (1-2m), the pressure normalizes. The EKF sees a sudden "Jump" in altitude.
  • Mitigation: The EKF waits for the drone to climb a few meters before fully trusting the Barometer (relying on Accelerometer Z integration during the transition).

3. Light Sensitivity

Many barometers (like the MS5611) are sensitive to UV light.

  • Scenario: Sunlight hits the sensor through the case.
  • Result: The silicon heats up instantly, causing a pressure spike. The drone "jumps" 1-2 meters.
  • Fix: Open-cell foam covers the sensor to block light and wind while letting air pass.

Key Parameters

Parameter Default Description
GND_TEMP 0 (deg C) User override for ground temperature. 0 = Auto-detect.
BARO_PROBE_EXT 0 Probing mask for external barometers.
EK3_GND_EFF_DZ 4.0 (m) EKF Ground Effect Deadzone.

Source Code Reference

Practical Guide: The Foam Fix

If your drone "twitches" vertically when sunlight hits it or when you fly fast, your barometer is exposed.

1. The Symptom

  • Sun: You rotate the drone. As the sun hits the side of the flight controller, the altitude spikes 3-5 meters.
  • Speed: You fly forward fast. The air pressure drops (Bernoulli's principle) inside the frame. The drone thinks it climbed, so it cuts throttle and descends.

2. The Solution

  1. Open the Frame: Expose the Flight Controller (Cube, Pixhawk, etc.).
  2. Locate the Baro: Look for a small metal can with a hole (MS5611) or a tiny black chip with a hole (BMP280).
  3. Apply Foam: Glue a piece of Open Cell Foam (dark gray packing foam) over the sensor.
    • Critical: The foam must be breathable (air passes through) but opaque (blocks light).
    • Test: Shine a flashlight on it. If the altitude changes on the HUD, add more foam.