GitHub
npm
expo-sensors
provides various APIs for accessing device sensors to measure motion, orientation, pressure, magnetic fields, and step count.
Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
-
npx expo install expo-sensors
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
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.
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: