---
title: Barometer
description: A library that provides access to device's barometer sensor.
sourceCodeUrl: https://github.com/expo/expo/tree/main/packages/expo-sensors
packageName: expo-sensors
iconUrl: /static/images/packages/expo-sensors.png
platforms: ["android", "ios*"]
---
`Barometer` from `expo-sensors` provides access to the device barometer sensor to respond to changes in air pressure, which is measured in hectopascals (`hPa`).
## Installation
## Usage
```jsx
const [{ pressure, relativeAltitude }, setData] = useState({ pressure: 0, relativeAltitude: 0 });
const [subscription, setSubscription] = useState(null);
const toggleListener = () => {
subscription ? unsubscribe() : subscribe();
};
const subscribe = () => {
setSubscription(Barometer.addListener(setData));
};
const unsubscribe = () => {
subscription && subscription.remove();
setSubscription(null);
};
return (
<View style={styles.wrapper}>
<Text>Barometer: Listener {subscription ? 'ACTIVE' : 'INACTIVE'}</Text>
<Text>Pressure: {pressure} hPa</Text>
<Text>
Relative Altitude:{' '}
{Platform.OS === 'ios' ? `${relativeAltitude} m` : `Only available on iOS`}
</Text>
<TouchableOpacity onPress={toggleListener} style={styles.button}>
<Text>Toggle listener</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
button: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#eee',
padding: 10,
marginTop: 15,
},
wrapper: {
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
paddingHorizontal: 20,
},
});
```
## API
```js
```
## Units and providers
| OS | Units | Provider | Description |
| ------- | ---------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| iOS | _`hPa`_ | [`CMAltimeter`](https://developer.apple.com/documentation/coremotion/cmaltimeter) | Altitude events reflect the change in the current altitude, not the absolute altitude. |
| Android | _`hPa`_ | [`Sensor.TYPE_PRESSURE`](https://developer.android.com/reference/android/hardware/Sensor#TYPE_PRESSURE) | Monitoring air pressure changes. |
| Web | | | This sensor is not available on the web and cannot be accessed. An `UnavailabilityError` will be thrown if you attempt to get data. |