> - The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [Sensor](js-apis-sensor.md) instead.
> - This module requires hardware support and can only be debugged on real devices.
## Modules to Import
```
import sensor from '@system.sensor';
```
## Error Codes
| Error Code| Description|
| -------- | -------- |
| 900 | The current device does not support the corresponding sensor.|
## sensor.subscribeAccelerometer
subscribeAccelerometer(Object): void
Subscribes to data changes of the acceleration sensor. If this API is called multiple times for the same application, the last call takes effect.
**Required permissions**: ohos.permission.ACCELEROMETER (a system permission)
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| interval | string | Yes| Execution frequency of the callback for returning the acceleration sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.|
| success | Function | Yes| Called when the acceleration sensor data changes.|
Subscribes to changes of the wearing state of a wearable device. If this API is called multiple times for the same application, the last call takes effect.
Subscribes to data changes of the device orientation sensor.
If this API is called multiple times for the same application, the last call takes effect. However, this API cannot be called multiple times in one click event.
| interval | string | Yes| Interval at which the callback is invoked to return the device orientation sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.|
| success | Function | Yes| Called when the device orientation sensor data changes.|
| fail | Function | No| Callback upon failure.|
Return values of the success callback
| Name| Type| Description|
| -------- | -------- | -------- |
| alpha | number | Rotation angle around the Z axis when the X/Y axis of the mobile phone coincides with the X/Y axis of the earth.|
| beta | number | Rotation angle around the X axis when the Y/Z axis of the mobile phone coincides with the Y/Z axis of the earth.|
| gamma | number | Rotation angle around the Y axis when the X/Z axis of the mobile phone coincides with the X/Z axis of the earth.|
Subscribes to data changes of the gyroscope sensor.
If this API is called multiple times for the same application, the last call takes effect. However, this API cannot be called multiple times in one click event.
**Required permissions**: ohos.permission.GYROSCOPE (a system permission)
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| interval | string | Yes| Interval at which the callback is invoked to return the gyroscope sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.|
| success | Function | Yes| Called when the gyroscope sensor data changes.|
| fail | Function | No| Callback upon failure.|
Return values of the success callback
| Name| Type| Description|
| -------- | -------- | -------- |
| x | number | Rotation angular velocity of the X axis.|
| y | number | Rotation angular velocity of the Y axis.|
| z | number | Rotation angular velocity of the Z axis.|
> - The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [Vibrator](js-apis-vibrator.md) instead.
> - This module requires hardware support and can only be debugged on real devices.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| mode | string | No| Vibration mode. The value **long** indicates long vibration, and **short** indicates short vibration. The default value is **long**.|