> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.stereolabs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.stereolabs.com/_mcp/server.

# Barometer Overview

The barometer measures the ambient air pressure around the camera in hectopascals (hPa). As the ambient air pressure decreases with the altitude, the barometer can be used to measure the altitude variations of the camera.

> **Note**
>
> Only the **ZED 2** (out of production) and the **ZED 2i** cameras are equipped with a barometer.

However, ambient air pressure is also affected by weather conditions. During sunny days the ambient pressure is higher than during rainy ones. This means that the barometer is affected by outdoor conditions and cannot be used to estimate the absolute altitude of the camera above sea level. Therefore, this sensor only provides relative altitude variations.

## Output Data

The following information is accessible from the camera sensor stack:

| Output Data           | Description                                                              | Units  |
| --------------------- | ------------------------------------------------------------------------ | ------ |
| **Barometer (25 Hz)** |                                                                          |        |
| pressure              | Ambient air pressure.                                                    | hPa    |
| relative\_altitude    | Relative altitude (altitude variation) from the initial camera position. | meters |

## Using the API

You can access the barometer data with:

**`C++`**

```cpp C++
SensorsData sensors_data;
SensorsData::BarometerData barometer_data;

// Grab new frames and retrieve sensors data
while (zed.grab() == ERROR_CODE::SUCCESS) {
  zed.getSensorsData(sensors_data, TIME_REFERENCE::IMAGE); // Retrieve only frame synchronized data

  // Extract barometer data
  barometer_data = sensors_data.barometer;

  // Retrieve pressure and relative altitude
  float pressure = barometer_data.pressure;
  float relative_altitude = barometer_data.relative_altitude;
}
```

**`Python`**

```python Python
sensors_data = sl.SensorsData()
barometer_data = sl.SensorsData.BarometerData()

# Grab new frames and retrieve sensors data
while zed.grab() == sl.ERROR_CODE.SUCCESS :
  zed.get_sensors_data(sensors_data, sl.TIME_REFERENCE.IMAGE) # Retrieve only frame synchronized data

  # Extract barometer data
  barometer_data = sensors_data.get_barometer_data()

  # Retrieve pressure and relative altitude
  pressure = barometer_data.pressure
  relative_altitude = barometer_data.relative_altitude
```

**`C#`**

```csharp C#
SensorsData sensors_data = new SensorsData();
BarometerData barometer_data = new BarometerData();

RuntimeParameters runtimeParameters  = new RuntimeParameters();
// Grab new frames and retrieve sensors data
while (zed.Grab(ref runtimeParameters) == ERROR_CODE.SUCCESS) {
  zed.GetSensorsData(ref sensors_data, TIME_REFERENCE.IMAGE); // Retrieve only frame synchronized data

  // Extract barometer data
  barometer_data = sensors_data.barometer;

  // Retrieve pressure and relative altitude
  float pressure = barometer_data.pressure;
  float relative_altitude = barometer_data.relativeAltitude;
}
```

## Code Example

For a code example, check out the [Getting Sensor Data](/docs/tutorials/sensor-data/) tutorial.