Guides
Plan-enterprise-icon
Expo Application Services
API Reference

Sensors

expo-sensors provides various APIs for accessing device sensors to measure motion, orientation, pressure, magnetic fields, and step count.

Platform Compatibility

Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorWeb
Status-success-iconStatus-success-iconStatus-success-iconStatus-success-iconStatus-success-icon

Installation

Terminal
→ npx expo install expo-sensors

If you're installing this in a bare React Native app, you should also follow these additional installation instructions.

Configuration

Starting in Android 12 (API level 31), the system has a 200ms limit for each sensor updates. If you need a update interval less than 200ms, you should add <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/> to AndroidManifest.xml.

API

import * as Sensors from 'expo-sensors';
// OR
import {
  Accelerometer,
  Barometer,
  Gyroscope,
  LightSensor,
  Magnetometer,
  MagnetometerUncalibrated,
  Pedometer,
} from 'expo-sensors';
For more information, please see the documentation for the sensor you are interested in:
  • Accelerometer
  • Barometer
  • Gyroscope
  • Magnetometer
  • LightSensor
  • Pedometer
  • Message-iconAsk a question on the forums about Sensors
  • Github-iconView open bug reports for Sensors
  • Code-iconView source code for Sensors
  • Build-iconView package in npm Registry
  • Edit-iconEdit this page

Was this doc helpful?