---
title: Exploring the Capacitor Barometer API
description: Discover how to integrate atmospheric pressure measurements into your Ionic and Capacitor applications using the Capacitor Barometer plugin from Capawesome.
date: 
  created: 2025-07-28
  updated: 2026-07-17
authors:
  - robingenz
categories:
  - Capacitor
  - Guides
  - SDKs
links:
  - Capacitor Barometer: sdks/capacitor/barometer.md
faq: true
---

# Exploring the Capacitor Barometer API

Environmental sensors have become increasingly important in modern mobile applications, enabling developers to create context-aware experiences that respond to real-world conditions. With the [Capacitor Barometer plugin](../../sdks/capacitor/barometer.md) from Capawesome, developers can integrate precise atmospheric pressure measurements into their Ionic and Capacitor applications, unlocking possibilities for weather monitoring, altitude tracking, and environmental data collection through a streamlined API that delivers accurate barometric readings across Android and iOS platforms.

<!-- more -->

## Installation

To install the Capacitor Barometer plugin, please refer to the [Installation](../../sdks/capacitor/barometer.md/#installation) section in the plugin documentation.

## Usage

Let's explore the core functionality of the Capacitor Barometer API and learn how to implement atmospheric pressure monitoring in your applications.

### Checking Sensor Availability

Before implementing barometric pressure features, it's essential to verify that the barometer sensor is available on the device. The Capacitor Barometer API provides the [`isAvailable(...)`](../../sdks/capacitor/barometer.md#isavailable) method for this purpose:

```ts
import { Barometer } from '@capawesome-team/capacitor-barometer';

const checkSensorAvailability = async () => {
  const result = await Barometer.isAvailable();
  
  if (!result.isAvailable) {
    alert('Barometer sensor is not available on this device.');
    return;
  }
  
  console.log('Barometer sensor is ready for use');
};
```

Always call this method before attempting any barometric operations. If the sensor is not available, you can inform the user or disable barometer-related features in your application.

### Getting Single Measurements

To retrieve a single atmospheric pressure reading, use the [`getMeasurement(...)`](../../sdks/capacitor/barometer.md#getmeasurement) method:

```ts
import { Barometer } from '@capawesome-team/capacitor-barometer';

const getCurrentPressure = async () => {
  try {
    const result = await Barometer.getMeasurement();
    const pressure = result.measurement.pressure;
    
    console.log(`Current atmospheric pressure: ${pressure} hPa`);
    
    // Display pressure with appropriate formatting
    document.getElementById('pressure-display').textContent = 
      `${pressure.toFixed(2)} hPa`;
  } catch (error) {
    console.error('Failed to get barometer measurement:', error);
  }
};
```

This method returns the atmospheric pressure in hectopascals (hPa), which is the standard unit for barometric pressure measurements. You can use this data for weather monitoring, altitude estimation, or environmental analysis.

### Continuous Measurement Updates

For applications that require real-time pressure monitoring, you can start continuous measurement updates using the [`startMeasurementUpdates(...)`](../../sdks/capacitor/barometer.md#startmeasurementupdates) method and listen for changes using the [`measurement`](../../sdks/capacitor/barometer.md#addlistenermeasurement) event:

```ts
import { Barometer } from '@capawesome-team/capacitor-barometer';

const startPressureMonitoring = async () => {
  // Add listener for measurement updates
  Barometer.addListener('measurement', (event) => {
    const pressure = event.measurement.pressure;
    console.log(`New pressure reading: ${pressure} hPa`);
  });
  
  // Start receiving continuous updates
  await Barometer.startMeasurementUpdates();
  console.log('Started continuous pressure monitoring');
};
```

Remember to stop measurement updates when they're no longer needed to conserve battery life:

```ts
const stopPressureMonitoring = async () => {
  await Barometer.stopMeasurementUpdates();
  
  // Remove all listeners to prevent memory leaks
  Barometer.removeAllListeners();
  
  console.log('Stopped pressure monitoring');
};
```

### Handling Permissions

Before accessing the barometer sensor, ensure your application has the necessary permissions using the [`checkPermissions(...)`](../../sdks/capacitor/barometer.md#checkpermissions) and [`requestPermissions(...)`](../../sdks/capacitor/barometer.md#requestpermissions) methods:

```ts
const handleBarometerPermissions = async () => {
  // Check current permission status
  const permissionStatus = await Barometer.checkPermissions();
  
  if (permissionStatus.sensors !== 'granted') {
    // Request permission if not already granted
    const requestResult = await Barometer.requestPermissions();
    
    if (requestResult.sensors !== 'granted') {
      alert('Sensor permissions are required for barometer functionality.');
      return false;
    }
  }
  
  return true;
};
```

Always verify permissions before performing barometer operations to ensure a smooth user experience and prevent runtime errors.

## Best Practices

When implementing atmospheric pressure monitoring with the Capacitor Barometer API, consider these best practices:


1. **Check sensor availability**: Always check if the barometer sensor is available on the device using the [`isAvailable(...)`](../../sdks/capacitor/barometer.md#isavailable) method before attempting to access barometric data. This prevents unnecessary errors and enhances user experience by gracefully handling unsupported devices.

2. **Check and request permissions**: Before accessing the barometer sensor, ensure your application has the necessary permissions using the [`checkPermissions(...)`](../../sdks/capacitor/barometer.md#checkpermissions) and [`requestPermissions(...)`](../../sdks/capacitor/barometer.md#requestpermissions) methods. This guarantees a smooth user experience and prevents runtime errors related to missing permissions.

3. **Implement proper resource management**: Always stop measurement updates when your application goes into the background or when continuous monitoring is no longer needed. Use the [`stopMeasurementUpdates(...)`](../../sdks/capacitor/barometer.md#stopmeasurementupdates) method and remove event listeners to prevent battery drain and memory leaks.

## FAQ

### Does the barometer report altitude directly, or only air pressure?

Only air pressure in hectopascals is guaranteed across platforms. Relative altitude is also available, but only on iOS — on Android, you'd need to derive elevation change yourself from pressure trends, since the plugin doesn't expose a computed altitude value there.

### Is the barometer available on every Android and iOS device?

No — not every device has a barometric pressure sensor, particularly among older or budget Android phones. That's exactly why `isAvailable()` exists: call it before enabling any barometer-dependent feature, and fall back gracefully (hide the feature, or explain it's unsupported) rather than assuming the sensor is present.

### Why would I use continuous updates instead of just polling `getMeasurement()` repeatedly?

Continuous updates (`startMeasurementUpdates()` plus the `measurement` listener) let the native sensor push readings to you as they change, rather than your code repeatedly asking for a fresh value. For something like a live weather trend graph or an [elevation tracker during a hike](./capacitor-device-sensors-guide.md), this is both more efficient and more responsive than polling on a timer.

### What happens to battery life if I forget to stop measurement updates?

Continuous sensor polling keeps draining battery as long as it's active, even if your UI isn't visible — this is why the best practice is to call `stopMeasurementUpdates()` and remove listeners when the feature isn't in active use, such as when the app backgrounds or the user navigates away from the relevant screen.

### Can I use barometer readings to detect weather changes in real time?

You can track pressure trends over time as a signal — a sustained pressure drop often precedes worsening weather, and a rise often precedes clearing conditions — but the plugin itself only reports raw pressure readings with timestamps. Turning that into an actual weather forecast or trend classification is application logic you build on top of the raw data, not something the plugin provides out of the box.

## Conclusion

The Capacitor Barometer Plugin from Capawesome provides developers with a powerful tool for integrating atmospheric pressure measurements into mobile applications. By offering precise barometric readings through a simple API, it enables the creation of weather monitoring apps, altitude trackers, and environmental sensing applications with minimal complexity.

To stay updated with the latest updates, features, and news about the Capawesome, Capacitor, and Ionic ecosystem, subscribe to the [Capawesome newsletter](/newsletter/){:target="_blank"} and follow us on [X (formerly Twitter)](https://x.com/capawesomeio){:target="_blank"}.

If you have any questions or need assistance with the Capacitor Barometer Plugin, feel free to reach out to the Capawesome team. We're here to help you harness the power of environmental sensors in your Ionic applications.
