HomeGuidesReferenceLearn

Expo Sensors iconExpo Sensors

GitHub

npm


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

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

Was this doc helpful?