• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.sensor (Sensor)
2
3The **Sensor** module provides APIs for obtaining the sensor list and subscribing to sensor data. It also provides some common sensor algorithms.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9
10## Modules to Import
11
12```js
13import sensor from '@ohos.sensor';
14```
15
16## sensor.on<sup>9+</sup>
17
18### ACCELEROMETER<sup>9+</sup>
19
20on(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;,options?: Options): void
21
22Subscribes to data of the acceleration sensor.
23
24**Required permissions**: ohos.permission.ACCELEROMETER
25
26**System capability**: SystemCapability.Sensors.Sensor
27
28**Parameters**
29
30| Name  | Type                                                        | Mandatory| Description                                                       |
31| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
32| type     | [SensorId](#sensorid9).ACCELEROMETER                         | Yes  | Sensor type. The value is fixed at **SensorId.ACCELEROMETER**.             |
33| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is an **AccelerometerResponse** object.|
34| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                        |
35
36**Error code**
37
38For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
39
40| Error Code ID| Error Message          |
41| -------- | ------------------ |
42| 14500101 | Service exception. |
43
44**Example**
45
46```js
47try {
48    sensor.on(sensor.SensorId.ACCELEROMETER, function (data) {
49        console.info('X-coordinate component: ' + data.x);
50        console.info('Y-coordinate component: ' + data.y);
51        console.info('Z-coordinate component: ' + data.z);
52    }, { interval: 10000000 });
53} catch (err) {
54    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
55}
56```
57
58### ACCELEROMETER_UNCALIBRATED<sup>9+</sup>
59
60on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback&lt;AccelerometerUncalibratedResponse&gt;,options?: Options): void
61
62Subscribes to data of the uncalibrated acceleration sensor.
63
64**Required permissions**: ohos.permission.ACCELEROMETER
65
66**System capability**: SystemCapability.Sensors.Sensor
67
68**Parameters**
69
70| Name  | Type                                                        | Mandatory| Description                                                        |
71| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
72| type     | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED            | Yes  | Sensor type. The value is fixed at **SensorId.ACCELEROMETER_UNCALIBRATED**. |
73| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes  | Callback used to report the sensor data, which is an **AccelerometerUncalibratedResponse** object.|
74| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
75
76**Error code**
77
78For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
79
80| Error Code ID| Error Message          |
81| -------- | ------------------ |
82| 14500101 | Service exception. |
83
84**Example**
85
86```js
87try {
88    sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
89        console.info('X-coordinate component: ' + data.x);
90        console.info('Y-coordinate component: ' + data.y);
91        console.info('Z-coordinate component: ' + data.z);
92        console.info('X-coordinate bias: ' + data.biasX);
93        console.info('Y-coordinate bias: ' + data.biasY);
94        console.info('Z-coordinate bias: ' + data.biasZ);
95    }, { interval: 10000000 });
96} catch (err) {
97    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
98}
99```
100
101### AMBIENT_LIGHT<sup>9+</sup>
102
103on(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void
104
105Subscribes to data of the ambient light sensor.
106
107**System capability**: SystemCapability.Sensors.Sensor
108
109**Parameters**
110
111| Name  | Type                                           | Mandatory| Description                                               |
112| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- |
113| type     | [SensorId](#sensorid9).AMBIENT_LIGHT            | Yes  | Sensor type. The value is fixed at **SensorId.AMBIENT_LIGHT**.     |
114| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **LightResponse** object.|
115| options  | [Options](#options)                             | No  | Data reporting frequency. The default value is 200,000,000 ns.                |
116
117**Error code**
118
119For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
120
121| Error Code ID| Error Message          |
122| -------- | ------------------ |
123| 14500101 | Service exception. |
124
125**Example**
126
127```js
128try {
129    sensor.on(sensor.SensorId.AMBIENT_LIGHT, function (data) {
130        console.info('The ambient light intensity: ' + data.intensity);
131    }, { interval: 10000000 });
132} catch (err) {
133    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
134}
135```
136
137###  AMBIENT_TEMPERATURE<sup>9+</sup>
138
139on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatureResponse&gt;,options?: Options): void
140
141Subscribes to data of the ambient temperature sensor.
142
143**System capability**: SystemCapability.Sensors.Sensor
144
145**Parameters**
146
147| Name  | Type                                                        | Mandatory| Description                                                        |
148| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
149| type     | [SensorId](#sensorid9).AMBIENT_TEMPERATURE                   | Yes  | Sensor type. The value is fixed at **SensorId.AMBIENT_TEMPERATURE**.        |
150| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes  | Callback used to report the sensor data, which is an **AmbientTemperatureResponse** object.|
151| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
152
153**Error code**
154
155For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
156
157| Error Code ID| Error Message          |
158| -------- | ------------------ |
159| 14500101 | Service exception. |
160
161**Example**
162
163```js
164try {
165    sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
166        console.info('Temperature: ' + data.temperature);
167    }, { interval: 10000000 });
168} catch (err) {
169    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
170}
171```
172
173### BAROMETER<sup>9+</sup>
174
175on(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;, options?: Options): void
176
177Subscribes to data of the barometer sensor.
178
179**System capability**: SystemCapability.Sensors.Sensor
180
181**Parameters**
182
183| Name  | Type                                                   | Mandatory| Description                                                   |
184| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
185| type     | [SensorId](#sensorid9).BAROMETER                        | Yes  | Sensor type. The value is fixed at **SensorId.BAROMETER**.             |
186| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **BarometerResponse** object.|
187| options  | [Options](#options)                                     | No  | Data reporting frequency. The default value is 200,000,000 ns.                    |
188
189**Error code**
190
191For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
192
193| Error Code ID| Error Message          |
194| -------- | ------------------ |
195| 14500101 | Service exception. |
196
197**Example**
198
199```js
200try {
201    sensor.on(sensor.SensorId.BAROMETER, function (data) {
202        console.info('Atmospheric pressure: ' + data.pressure);
203    }, { interval: 10000000 });
204} catch (err) {
205    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
206}
207```
208
209###  GRAVITY<sup>9+</sup>
210
211on(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void
212
213Subscribes to data of the gravity sensor.
214
215**System capability**: SystemCapability.Sensors.Sensor
216
217**Parameters**
218
219| Name  | Type                                               | Mandatory| Description                                                 |
220| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------- |
221| type     | [SensorId](#sensorid9).GRAVITY                      | Yes  | Sensor type. The value is fixed at **SensorId.GRAVITY**.             |
222| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **GravityResponse** object.|
223| options  | [Options](#options)                                 | No  | Data reporting frequency. The default value is 200,000,000 ns.                  |
224
225**Error code**
226
227For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
228
229| Error Code ID| Error Message          |
230| -------- | ------------------ |
231| 14500101 | Service exception. |
232
233**Example**
234
235```js
236try {
237    sensor.on(sensor.SensorId.GRAVITY, function (data) {
238        console.info('X-coordinate component: ' + data.x);
239        console.info('Y-coordinate component: ' + data.y);
240        console.info('Z-coordinate component: ' + data.z);
241    }, { interval: 10000000 });
242} catch (err) {
243    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
244}
245```
246
247###  GYROSCOPE<sup>9+</sup>
248
249on(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;,options?: Options): void
250
251Subscribes to data of the gyroscope sensor.
252
253**Required permissions**: ohos.permission.GYROSCOPE
254
255**System capability**: SystemCapability.Sensors.Sensor
256
257**Parameters**
258
259| Name  | Type                                                   | Mandatory| Description                                                   |
260| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
261| type     | [SensorId](#sensorid9).GYROSCOPE                        | Yes  | Sensor type. The value is fixed at **SensorId.GYROSCOPE**.             |
262| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes  | Callback used to report the sensor data, which is a **GyroscopeResponse** object.|
263| options  | [Options](#options)                                     | No  | Data reporting frequency. The default value is 200,000,000 ns.                    |
264
265**Error code**
266
267For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
268
269| Error Code ID| Error Message          |
270| -------- | ------------------ |
271| 14500101 | Service exception. |
272
273**Example**
274
275```js
276try {
277    sensor.on(sensor.SensorId.GYROSCOPE, function (data) {
278        console.info('X-coordinate component: ' + data.x);
279        console.info('Y-coordinate component: ' + data.y);
280        console.info('Z-coordinate component: ' + data.z);
281    }, { interval: 10000000 });
282} catch (err) {
283    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
284}
285```
286
287###  GYROSCOPE_UNCALIBRATED<sup>9+</sup>
288
289on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncalibratedResponse&gt;,
290      options?: Options): void
291
292Subscribes to data of the uncalibrated gyroscope sensor.
293
294**Required permissions**: ohos.permission.GYROSCOPE
295
296**System capability**: SystemCapability.Sensors.Sensor
297
298**Parameters**
299
300| Name  | Type                                                        | Mandatory| Description                                                        |
301| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
302| type     | [SensorId](#sensorid9).GYROSCOPE_UNCALIBRATED                | Yes  | Sensor type. The value is fixed at **SensorId.GYROSCOPE_UNCALIBRATED**.     |
303| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **GyroscopeUncalibratedResponse** object.|
304| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
305
306**Error code**
307
308For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
309
310| Error Code ID| Error Message          |
311| -------- | ------------------ |
312| 14500101 | Service exception. |
313
314**Example**
315
316```js
317try {
318    sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
319        console.info('X-coordinate component: ' + data.x);
320        console.info('Y-coordinate component: ' + data.y);
321        console.info('Z-coordinate component: ' + data.z);
322        console.info('X-coordinate bias: ' + data.biasX);
323        console.info('Y-coordinate bias: ' + data.biasY);
324        console.info('Z-coordinate bias: ' + data.biasZ);
325    }, { interval: 10000000 });
326} catch (err) {
327    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
328}
329```
330
331###  HALL<sup>9+</sup>
332
333on(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void
334
335Subscribes to data of the Hall effect sensor.
336
337**System capability**: SystemCapability.Sensors.Sensor
338
339**Parameters**
340
341| Name  | Type                                         | Mandatory| Description                                              |
342| -------- | --------------------------------------------- | ---- | -------------------------------------------------- |
343| type     | [SensorId](#sensorid9).HALL                   | Yes  | Sensor type. The value is fixed at **SensorId.HALL**.             |
344| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **HallResponse** object.|
345| options  | [Options](#options)                           | No  | Data reporting frequency. The default value is 200,000,000 ns.               |
346
347**Error code**
348
349For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
350
351| Error Code ID| Error Message          |
352| -------- | ------------------ |
353| 14500101 | Service exception. |
354
355**Example**
356
357```js
358try {
359    sensor.on(sensor.SensorId.HALL, function (data) {
360        console.info('Hall status: ' + data.status);
361    }, { interval: 10000000 });
362} catch (err) {
363    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
364}
365```
366
367###   HEART_RATE<sup>9+</sup>
368
369on(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;,options?: Options): void
370
371Subscribes to data of the heart rate sensor.
372
373**Required permissions**: ohos.permission.READ_HEALTH_DATA
374
375**System capability**: SystemCapability.Sensors.Sensor
376
377**Parameters**
378
379| Name  | Type                                                   | Mandatory| Description                                                   |
380| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
381| type     | [SensorId](#sensorid9).HEART_RATE                       | Yes  | Sensor type. The value is fixed at **SensorId.HEART_RATE**.            |
382| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **HeartRateResponse** object.|
383| options  | [Options](#options)                                     | No  | Data reporting frequency. The default value is 200,000,000 ns.                    |
384
385**Error code**
386
387For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
388
389| Error Code ID| Error Message          |
390| -------- | ------------------ |
391| 14500101 | Service exception. |
392
393**Example**
394
395```js
396try {
397    sensor.on(sensor.SensorId.HEART_RATE, function (data) {
398        console.info('Heart rate: ' + data.heartRate);
399    }, { interval: 10000000 });
400} catch (err) {
401    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
402}
403```
404
405###  HUMIDITY<sup>9+</sup>
406
407on(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void
408
409Subscribes to data of the humidity sensor.
410
411**System capability**: SystemCapability.Sensors.Sensor
412
413**Parameters**
414
415| Name  | Type                                                 | Mandatory| Description                                                  |
416| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------ |
417| type     | [SensorId](#sensorid9).HUMIDITY                       | Yes  | Sensor type. The value is fixed at **SensorId.HUMIDITY**.             |
418| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **HumidityResponse** object.|
419| options  | [Options](#options)                                   | No  | Data reporting frequency. The default value is 200,000,000 ns.                   |
420
421**Error code**
422
423For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
424
425| Error Code ID| Error Message          |
426| -------- | ------------------ |
427| 14500101 | Service exception. |
428
429**Example**
430
431```js
432try {
433    sensor.on(sensor.SensorId.HUMIDITY, function (data) {
434        console.info('Humidity: ' + data.humidity);
435    }, { interval: 10000000 });
436} catch (err) {
437    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
438}
439```
440
441###   LINEAR_ACCELEROMETER<sup>9+</sup>
442
443on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAccelerometerResponse&gt;,
444        options?: Options): void
445
446Subscribes to data of the linear acceleration sensor.
447
448**Required permissions**: ohos.permission.ACCELEROMETER
449
450**System capability**: SystemCapability.Sensors.Sensor
451
452**Parameters**
453
454| Name  | Type                                                        | Mandatory| Description                                                        |
455| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
456| type     | [SensorId](#sensorid9).LINEAR_ACCELEROMETER                  | Yes  | Sensor type. The value is fixed at **SensorId.LINEAR_ACCELEROMETER**.       |
457| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **LinearAccelerometerResponse** object.|
458| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
459
460**Error code**
461
462For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
463
464| Error Code ID| Error Message          |
465| -------- | ------------------ |
466| 14500101 | Service exception. |
467
468**Example**
469
470```js
471try {
472    sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
473        console.info('X-coordinate component: ' + data.x);
474        console.info('Y-coordinate component: ' + data.y);
475        console.info('Z-coordinate component: ' + data.z);
476    }, { interval: 10000000 });
477} catch (err) {
478    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
479}
480```
481
482###  MAGNETIC_FIELD<sup>9+</sup>
483
484on(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void
485
486Subscribes to data of the magnetic field sensor.
487
488**System capability**: SystemCapability.Sensors.Sensor
489
490**Parameters**
491
492| Name  | Type                                                        | Mandatory| Description                                                       |
493| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
494| type     | [SensorId](#sensorid9).MAGNETIC_FIELD                        | Yes  | Sensor type. The value is fixed at **SensorId.MAGNETIC_FIELD**.            |
495| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **MagneticFieldResponse** object.|
496| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                        |
497
498**Error code**
499
500For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
501
502| Error Code ID| Error Message          |
503| -------- | ------------------ |
504| 14500101 | Service exception. |
505
506**Example**
507
508```js
509try {
510    sensor.on(sensor.SensorId.MAGNETIC_FIELD, function (data) {
511        console.info('X-coordinate component: ' + data.x);
512        console.info('Y-coordinate component: ' + data.y);
513        console.info('Z-coordinate component: ' + data.z);
514    }, { interval: 10000000 });
515} catch (err) {
516    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
517}
518```
519
520### MAGNETIC_FIELD_UNCALIBRATED<sup>9+</sup>
521
522on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void
523
524Subscribes to data of the uncalibrated magnetic field sensor.
525
526**System capability**: SystemCapability.Sensors.Sensor
527
528**Parameters**
529
530| Name  | Type                                                        | Mandatory| Description                                                        |
531| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
532| type     | [SensorId](#sensorid9).MAGNETIC_FIELD_UNCALIBRATED           | Yes  | Sensor type. The value is fixed at **SensorId.MAGNETIC_FIELD_UNCALIBRATED**.|
533| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **MagneticFieldUncalibratedResponse** object.|
534| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
535
536**Error code**
537
538For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
539
540| Error Code ID| Error Message          |
541| -------- | ------------------ |
542| 14500101 | Service exception. |
543
544**Example**
545
546```js
547try {
548    sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
549        console.info('X-coordinate component: ' + data.x);
550        console.info('Y-coordinate component: ' + data.y);
551        console.info('Z-coordinate component: ' + data.z);
552        console.info('X-coordinate bias: ' + data.biasX);
553        console.info('Y-coordinate bias: ' + data.biasY);
554        console.info('Z-coordinate bias: ' + data.biasZ);
555    }, { interval: 10000000 });
556} catch (err) {
557    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
558}
559```
560
561### ORIENTATION<sup>9+</sup>
562
563on(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;,options?: Options): void
564
565Subscribes to data of the orientation sensor.
566
567**System capability**: SystemCapability.Sensors.Sensor
568
569**Error code**
570
571For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
572
573| Error Code ID| Error Message          |
574| -------- | ------------------ |
575| 14500101 | Service exception. |
576
577**Parameters**
578
579| Name  | Type                                                       | Mandatory| Description                                                     |
580| -------- | ----------------------------------------------------------- | ---- | --------------------------------------------------------- |
581| type     | [SensorId](#sensorid9).ORIENTATION                          | Yes  | Sensor type. The value is fixed at **SensorId.ORIENTATION**.             |
582| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **OrientationResponse** object.|
583| options  | [Options](#options)                                         | No  | Data reporting frequency. The default value is 200,000,000 ns.                      |
584
585**Example**
586
587```js
588try {
589    sensor.on(sensor.SensorId.ORIENTATION, function (data) {
590        console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
591        console.info('The device rotates at an angle around the X axis: ' + data.beta);
592        console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
593    }, { interval: 10000000 });
594} catch (err) {
595    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
596}
597```
598
599### PEDOMETER<sup>9+</sup>
600
601on(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void
602
603Subscribes to data of the pedometer sensor.
604
605**Required permissions**: ohos.permission.ACTIVITY_MOTION
606
607**System capability**: SystemCapability.Sensors.Sensor
608
609**Error code**
610
611For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
612
613| Error Code ID| Error Message          |
614| -------- | ------------------ |
615| 14500101 | Service exception. |
616
617**Parameters**
618
619| Name  | Type                                                   | Mandatory| Description                                                   |
620| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
621| type     | [SensorId](#sensorid9).PEDOMETER                        | Yes  | Sensor type. The value is fixed at **SensorId.PEDOMETER**.             |
622| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **PedometerResponse** object.|
623| options  | [Options](#options)                                     | No  | Data reporting frequency. The default value is 200,000,000 ns.                    |
624
625**Example**
626
627```js
628try {
629    sensor.on(sensor.SensorId.PEDOMETER, function (data) {
630        console.info('Step count: ' + data.steps);
631    }, { interval: 10000000 });
632} catch (err) {
633    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
634}
635```
636
637### PEDOMETER_DETECTION<sup>9+</sup>
638
639on(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;,
640        options?: Options): void
641
642Subscribes to data of the pedometer detection sensor.
643
644**Required permissions**: ohos.permission.ACTIVITY_MOTION
645
646**System capability**: SystemCapability.Sensors.Sensor
647
648**Parameters**
649
650| Name  | Type                                                        | Mandatory| Description                                                        |
651| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
652| type     | [SensorId](#sensorid9).PEDOMETER_DETECTION                   | Yes  | Sensor type. The value is fixed at **SensorId.PEDOMETER_DETECTION**.        |
653| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **PedometerDetectionResponse** object.|
654| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
655
656**Error code**
657
658For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
659
660| Error Code ID| Error Message          |
661| -------- | ------------------ |
662| 14500101 | Service exception. |
663
664**Example**
665
666```js
667try {
668    sensor.on(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
669        console.info('Pedometer scalar: ' + data.scalar);
670    }, { interval: 10000000 });
671} catch (err) {
672    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
673}
674```
675
676### PROXIMITY<sup>9+</sup>
677
678on(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;, options?: Options): void
679
680Subscribes to data of the proximity sensor.
681
682**System capability**: SystemCapability.Sensors.Sensor
683
684**Parameters**
685
686| Name  | Type                                                   | Mandatory| Description                                                   |
687| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
688| type     | [SensorId](#sensorid9).PROXIMITY                        | Yes  | Sensor type. The value is fixed at **SensorId.PROXIMITY**.             |
689| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **ProximityResponse** object.|
690| options  | [Options](#options)                                     | No  | Data reporting frequency. The default value is 200,000,000 ns.                    |
691
692**Error code**
693
694For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
695
696| Error Code ID| Error Message          |
697| -------- | ------------------ |
698| 14500101 | Service exception. |
699
700**Example**
701
702```js
703try {
704    sensor.on(sensor.SensorId.PROXIMITY, function (data) {
705        console.info('Distance: ' + data.distance);
706    }, { interval: 10000000 });
707} catch (err) {
708    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
709}
710```
711
712### ROTATION_VECTOR<sup>9+</sup>
713
714on(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;,
715        options?: Options): void
716
717Subscribes to data of the rotation vector sensor.
718
719**System capability**: SystemCapability.Sensors.Sensor
720
721**Parameters**
722
723| Name  | Type                                                        | Mandatory| Description                                                        |
724| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
725| type     | [SensorId](#sensorid9).ROTATION_VECTOR                       | Yes  | Sensor type. The value is fixed at **SensorId.ROTATION_VECTOR**.            |
726| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **RotationVectorResponse** object.|
727| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
728
729**Error code**
730
731For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
732
733| Error Code ID| Error Message          |
734| -------- | ------------------ |
735| 14500101 | Service exception. |
736
737**Example**
738
739```js
740try {
741    sensor.on(sensor.SensorId.ROTATION_VECTOR, function (data) {
742        console.info('X-coordinate component: ' + data.x);
743        console.info('Y-coordinate component: ' + data.y);
744        console.info('Z-coordinate component: ' + data.z);
745        console.info('Scalar quantity: ' + data.w);
746    }, { interval: 10000000 });
747} catch (err) {
748    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
749}
750```
751
752### SIGNIFICANT_MOTION<sup>9+</sup>
753
754on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;,
755        options?: Options): void
756
757Subscribes to data of the significant motion sensor.
758
759**System capability**: SystemCapability.Sensors.Sensor
760
761**Parameters**
762
763| Name  | Type                                                        | Mandatory| Description                                                        |
764| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
765| type     | [SensorId](#sensorid9).SIGNIFICANT_MOTION                    | Yes  | Sensor type. The value is fixed at **SensorId.SIGNIFICANT_MOTION**.         |
766| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **SignificantMotionResponse** object.|
767| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                         |
768
769**Error code**
770
771For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
772
773| Error Code ID| Error Message          |
774| -------- | ------------------ |
775| 14500101 | Service exception. |
776
777**Example**
778
779```js
780try {
781    sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
782        console.info('Scalar data: ' + data.scalar);
783    }, { interval: 10000000 });
784} catch (err) {
785    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
786}
787```
788
789###  WEAR_DETECTION<sup>9+</sup>
790
791on(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,
792        options?: Options): void
793
794Subscribes to data of the wear detection sensor.
795
796**System capability**: SystemCapability.Sensors.Sensor
797
798**Parameters**
799
800| Name  | Type                                                        | Mandatory| Description                                                       |
801| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
802| type     | [SensorId](#sensorid9).WEAR_DETECTION                        | Yes  | Sensor type. The value is fixed at **SensorId.WEAR_DETECTION**.            |
803| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **WearDetectionResponse** object.|
804| options  | [Options](#options)                                          | No  | Data reporting frequency. The default value is 200,000,000 ns.                        |
805
806**Error code**
807
808For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
809
810| Error Code ID| Error Message          |
811| -------- | ------------------ |
812| 14500101 | Service exception. |
813
814**Example**
815
816```js
817try {
818    sensor.on(sensor.SensorId.WEAR_DETECTION, function (data) {
819        console.info('Wear status: ' + data.value);
820    }, { interval: 10000000 });
821} catch (err) {
822    console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
823}
824```
825
826## sensor.once<sup>9+</sup>
827
828### ACCELEROMETER<sup>9+</sup>
829
830once(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void
831
832Obtains data of the acceleration sensor once.
833
834**Required permissions**: ohos.permission.ACCELEROMETER
835
836**System capability**: SystemCapability.Sensors.Sensor
837
838**Parameters**
839
840| Name  | Type                                                        | Mandatory| Description                                                       |
841| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
842| type     | [SensorId](#sensorid9).ACCELEROMETER                         | Yes  | Sensor type. The value is fixed at **SensorId.ACCELEROMETER**.             |
843| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is an **AccelerometerResponse** object.|
844
845**Error code**
846
847For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
848
849| Error Code ID| Error Message          |
850| -------- | ------------------ |
851| 14500101 | Service exception. |
852
853**Example**
854
855```js
856try {
857    sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
858        console.info('X-coordinate component: ' + data.x);
859        console.info('Y-coordinate component: ' + data.y);
860        console.info('Z-coordinate component: ' + data.z);
861    });
862} catch (err) {
863    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
864}
865```
866
867### ACCELEROMETER_UNCALIBRATED<sup>9+</sup>
868
869once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
870
871Obtains data of the uncalibrated acceleration sensor once.
872
873**Required permissions**: ohos.permission.ACCELEROMETER
874
875**System capability**: SystemCapability.Sensors.Sensor
876
877**Parameters**
878
879| Name  | Type                                                        | Mandatory| Description                                                        |
880| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
881| type     | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED            | Yes  | Sensor type. The value is fixed at **SensorId.ACCELEROMETER_UNCALIBRATED**. |
882| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes  | Callback used to report the sensor data, which is an **AccelerometerUncalibratedResponse** object.|
883
884**Error code**
885
886For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
887
888| Error Code ID| Error Message          |
889| -------- | ------------------ |
890| 14500101 | Service exception. |
891
892**Example**
893
894```js
895try {
896    sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
897        console.info('X-coordinate component: ' + data.x);
898        console.info('Y-coordinate component: ' + data.y);
899        console.info('Z-coordinate component: ' + data.z);
900        console.info('X-coordinate bias: ' + data.biasX);
901        console.info('Y-coordinate bias: ' + data.biasY);
902        console.info('Z-coordinate bias: ' + data.biasZ);
903    });
904} catch (err) {
905    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
906}
907```
908
909### AMBIENT_LIGHT<sup>9+</sup>
910
911once(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void
912
913Obtains data of the ambient light sensor once.
914
915**System capability**: SystemCapability.Sensors.Sensor
916
917**Parameters**
918
919| Name  | Type                                           | Mandatory| Description                                               |
920| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- |
921| type     | [SensorId](#sensorid9).AMBIENT_LIGHT            | Yes  | Sensor type. The value is fixed at **SensorId.AMBIENT_LIGHT**.     |
922| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **LightResponse** object.|
923
924**Error code**
925
926For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
927
928| Error Code ID| Error Message          |
929| -------- | ------------------ |
930| 14500101 | Service exception. |
931
932**Example**
933
934```js
935try {
936    sensor.once(sensor.SensorId.AMBIENT_LIGHT, function (data) {
937        console.info('The ambient light intensity: ' + data.intensity);
938    });
939} catch (err) {
940    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
941}
942```
943
944### AMBIENT_TEMPERATURE<sup>9+</sup>
945
946once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatureResponse&gt;): void
947
948Obtains data of the temperature sensor once.
949
950**System capability**: SystemCapability.Sensors.Sensor
951
952**Parameters**
953
954| Name  | Type                                                        | Mandatory| Description                                                        |
955| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
956| type     | [SensorId](#sensorid9).AMBIENT_TEMPERATURE                   | Yes  | Sensor type. The value is fixed at **SensorId.AMBIENT_TEMPERATURE**.        |
957| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes  | Callback used to report the sensor data, which is an **AmbientTemperatureResponse** object.|
958
959**Error code**
960
961For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
962
963| Error Code ID| Error Message          |
964| -------- | ------------------ |
965| 14500101 | Service exception. |
966
967**Example**
968
969```js
970try {
971    sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
972        console.info('Temperature: ' + data.temperature);
973    });
974} catch (err) {
975    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
976}
977```
978
979### BAROMETER<sup>9+</sup>
980
981once(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void
982
983Obtains data of the barometer sensor once.
984
985**System capability**: SystemCapability.Sensors.Sensor
986
987**Parameters**
988
989| Name  | Type                                                   | Mandatory| Description                                                   |
990| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
991| type     | [SensorId](#sensorid9).BAROMETER                        | Yes  | Sensor type. The value is fixed at **SensorId.BAROMETER**.             |
992| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **BarometerResponse** object.|
993
994**Error code**
995
996For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
997
998| Error Code ID| Error Message          |
999| -------- | ------------------ |
1000| 14500101 | Service exception. |
1001
1002**Example**
1003
1004```js
1005try {
1006    sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (data) {
1007        console.info('Atmospheric pressure: ' + data.pressure);
1008    });
1009} catch (err) {
1010    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1011}
1012```
1013
1014### GRAVITY<sup>9+</sup>
1015
1016once(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;): void
1017
1018Obtains data of the gravity sensor once.
1019
1020**System capability**: SystemCapability.Sensors.Sensor
1021
1022**Parameters**
1023
1024| Name  | Type                                               | Mandatory| Description                                                 |
1025| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------- |
1026| type     | [SensorId](#sensorid9).GRAVITY                      | Yes  | Sensor type. The value is fixed at **SensorId.GRAVITY**.             |
1027| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **GravityResponse** object.|
1028
1029**Error code**
1030
1031For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1032
1033| Error Code ID| Error Message          |
1034| -------- | ------------------ |
1035| 14500101 | Service exception. |
1036
1037**Example**
1038
1039```js
1040try {
1041    sensor.once(sensor.SensorId.GRAVITY, function (data) {
1042        console.info('X-coordinate component: ' + data.x);
1043        console.info('Y-coordinate component: ' + data.y);
1044        console.info('Z-coordinate component: ' + data.z);
1045    });
1046} catch (err) {
1047    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1048}
1049```
1050
1051### GYROSCOPE<sup>9+</sup>
1052
1053once(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void
1054
1055Obtains to data of the gyroscope sensor once.
1056
1057**Required permissions**: ohos.permission.GYROSCOPE
1058
1059**System capability**: SystemCapability.Sensors.Sensor
1060
1061**Parameters**
1062
1063| Name  | Type                                                   | Mandatory| Description                                                   |
1064| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
1065| type     | [SensorId](#sensorid9).GYROSCOPE                        | Yes  | Sensor type. The value is fixed at **SensorId.GYROSCOPE**.             |
1066| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes  | Callback used to report the sensor data, which is a **GyroscopeResponse** object.|
1067
1068**Error code**
1069
1070For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1071
1072| Error Code ID| Error Message          |
1073| -------- | ------------------ |
1074| 14500101 | Service exception. |
1075
1076**Example**
1077
1078```js
1079try {
1080    sensor.once(sensor.SensorId.GYROSCOPE, function (data) {
1081        console.info('X-coordinate component: ' + data.x);
1082        console.info('Y-coordinate component: ' + data.y);
1083        console.info('Z-coordinate component: ' + data.z);
1084    });
1085} catch (err) {
1086    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1087}
1088```
1089
1090### GYROSCOPE_UNCALIBRATED<sup>9+</sup>
1091
1092once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
1093
1094Obtains data of the uncalibrated gyroscope sensor once.
1095
1096**Required permissions**: ohos.permission.GYROSCOPE
1097
1098**System capability**: SystemCapability.Sensors.Sensor
1099
1100**Parameters**
1101
1102| Name  | Type                                                        | Mandatory| Description                                                        |
1103| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1104| type     | [SensorId](#sensorid9).GYROSCOPE_UNCALIBRATED                | Yes  | Sensor type. The value is fixed at **SensorId.GYROSCOPE_UNCALIBRATED**.     |
1105| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **GyroscopeUncalibratedResponse** object.|
1106
1107**Error code**
1108
1109For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1110
1111| Error Code ID| Error Message          |
1112| -------- | ------------------ |
1113| 14500101 | Service exception. |
1114
1115**Example**
1116
1117```js
1118try {
1119    sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
1120        console.info('X-coordinate component: ' + data.x);
1121        console.info('Y-coordinate component: ' + data.y);
1122        console.info('Z-coordinate component: ' + data.z);
1123        console.info('X-coordinate bias: ' + data.biasX);
1124        console.info('Y-coordinate bias: ' + data.biasY);
1125        console.info('Z-coordinate bias: ' + data.biasZ);
1126    });
1127} catch (err) {
1128    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1129}
1130```
1131
1132### HALL<sup>9+</sup>
1133
1134once(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;): void
1135
1136Obtains data of the Hall effect sensor once.
1137
1138**System capability**: SystemCapability.Sensors.Sensor
1139
1140**Parameters**
1141
1142| Name  | Type                                         | Mandatory| Description                                              |
1143| -------- | --------------------------------------------- | ---- | -------------------------------------------------- |
1144| type     | [SensorId](#sensorid9).HALL                   | Yes  | Sensor type. The value is fixed at **SensorId.HALL**.             |
1145| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **HallResponse** object.|
1146
1147**Error code**
1148
1149For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1150
1151| Error Code ID| Error Message          |
1152| -------- | ------------------ |
1153| 14500101 | Service exception. |
1154
1155**Example**
1156
1157```js
1158try {
1159    sensor.once(sensor.SensorId.HALL, function (data) {
1160        console.info('Status: ' + data.status);
1161    });
1162} catch (err) {
1163    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1164}
1165```
1166
1167### HEART_RATE<sup>9+</sup>
1168
1169once(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void
1170
1171Obtains data of the heart rate sensor once.
1172
1173**Required permissions**: ohos.permission.READ_HEALTH_DATA
1174
1175**System capability**: SystemCapability.Sensors.Sensor
1176
1177**Parameters**
1178
1179| Name  | Type                                                   | Mandatory| Description                                                   |
1180| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
1181| type     | [SensorId](#sensorid9).HEART_RATE                       | Yes  | Sensor type. The value is fixed at **SensorId.HEART_RATE**.            |
1182| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **HeartRateResponse** object.|
1183
1184**Error code**
1185
1186For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1187
1188| Error Code ID| Error Message          |
1189| -------- | ------------------ |
1190| 14500101 | Service exception. |
1191
1192**Example**
1193
1194```js
1195try {
1196    sensor.once(sensor.SensorId.HEART_RATE, function (data) {
1197        console.info('Heart rate: ' + data.heartRate);
1198    });
1199} catch (err) {
1200    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1201}
1202```
1203
1204### HUMIDITY<sup>9+</sup>
1205
1206once(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void
1207
1208Obtains data of the humidity sensor once.
1209
1210**System capability**: SystemCapability.Sensors.Sensor
1211
1212**Parameters**
1213
1214| Name  | Type                                                 | Mandatory| Description                                                  |
1215| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------ |
1216| type     | [SensorId](#sensorid9).HUMIDITY                       | Yes  | Sensor type. The value is fixed at **SensorId.HUMIDITY**.             |
1217| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **HumidityResponse** object.|
1218
1219**Error code**
1220
1221For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1222
1223| Error Code ID| Error Message          |
1224| -------- | ------------------ |
1225| 14500101 | Service exception. |
1226
1227**Example**
1228
1229```js
1230try {
1231    sensor.once(sensor.SensorId.HUMIDITY, function (data) {
1232        console.info('Humidity: ' + data.humidity);
1233    });
1234} catch (err) {
1235    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1236}
1237```
1238
1239### LINEAR_ACCELEROMETER<sup>9+</sup>
1240
1241once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAccelerometerResponse&gt;): void
1242
1243Obtains data of the linear acceleration sensor once.
1244
1245**Required permissions**: ohos.permission.ACCELEROMETER
1246
1247**System capability**: SystemCapability.Sensors.Sensor
1248
1249**Parameters**
1250
1251| Name  | Type                                                        | Mandatory| Description                                                        |
1252| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1253| type     | [SensorId](#sensorid9).LINEAR_ACCELEROMETER                  | Yes  | Sensor type. The value is fixed at **SensorId.LINEAR_ACCELEROMETER**.       |
1254| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **LinearAccelerometerResponse** object.|
1255
1256**Error code**
1257
1258For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1259
1260| Error Code ID| Error Message          |
1261| -------- | ------------------ |
1262| 14500101 | Service exception. |
1263
1264**Example**
1265
1266```js
1267try {
1268    sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
1269        console.info('X-coordinate component: ' + data.x);
1270        console.info('Y-coordinate component: ' + data.y);
1271        console.info('Z-coordinate component: ' + data.z);
1272    });
1273} catch (err) {
1274    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1275}
1276```
1277
1278### MAGNETIC_FIELD<sup>9+</sup>
1279
1280once(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void
1281
1282Obtains data of the magnetic field sensor once.
1283
1284**System capability**: SystemCapability.Sensors.Sensor
1285
1286**Parameters**
1287
1288| Name  | Type                                                        | Mandatory| Description                                                       |
1289| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
1290| type     | [SensorId](#sensorid9).MAGNETIC_FIELD                        | Yes  | Sensor type. The value is fixed at **SensorId.MAGNETIC_FIELD**.            |
1291| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **MagneticFieldResponse** object.|
1292
1293**Error code**
1294
1295For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1296
1297| Error Code ID| Error Message          |
1298| -------- | ------------------ |
1299| 14500101 | Service exception. |
1300
1301**Example**
1302
1303```js
1304try {
1305    sensor.once(sensor.SensorId.MAGNETIC_FIELD, function (data) {
1306        console.info('X-coordinate component: ' + data.x);
1307        console.info('Y-coordinate component: ' + data.y);
1308        console.info('Z-coordinate component: ' + data.z);
1309    });
1310} catch (err) {
1311    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1312}
1313```
1314
1315### MAGNETIC_FIELD_UNCALIBRATED<sup>9+</sup>
1316
1317once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
1318
1319Obtains data of the uncalibrated magnetic field sensor once.
1320
1321**System capability**: SystemCapability.Sensors.Sensor
1322
1323**Parameters**
1324
1325| Name  | Type                                                        | Mandatory| Description                                                        |
1326| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1327| type     | [SensorId](#sensorid9).MAGNETIC_FIELD_UNCALIBRATED           | Yes  | Sensor type. The value is fixed at **SensorId.MAGNETIC_FIELD_UNCALIBRATED**.|
1328| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **MagneticFieldUncalibratedResponse** object.|
1329
1330**Error code**
1331
1332For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1333
1334| Error Code ID| Error Message          |
1335| -------- | ------------------ |
1336| 14500101 | Service exception. |
1337
1338**Example**
1339
1340```js
1341try {
1342    sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
1343        console.info('X-coordinate component: ' + data.x);
1344        console.info('Y-coordinate component: ' + data.y);
1345        console.info('Z-coordinate component: ' + data.z);
1346        console.info('X-coordinate bias: ' + data.biasX);
1347        console.info('Y-coordinate bias: ' + data.biasY);
1348        console.info('Z-coordinate bias: ' + data.biasZ);
1349    });
1350} catch (err) {
1351    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1352}
1353```
1354
1355### ORIENTATION<sup>9+</sup>
1356
1357once(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void
1358
1359Obtains data of the orientation sensor once.
1360
1361**System capability**: SystemCapability.Sensors.Sensor
1362
1363**Parameters**
1364
1365| Name  | Type                                                       | Mandatory| Description                                                     |
1366| -------- | ----------------------------------------------------------- | ---- | --------------------------------------------------------- |
1367| type     | [SensorId](#sensorid9).ORIENTATION                          | Yes  | Sensor type. The value is fixed at **SensorId.ORIENTATION**.             |
1368| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **OrientationResponse** object.|
1369
1370**Error code**
1371
1372For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1373
1374| Error Code ID| Error Message          |
1375| -------- | ------------------ |
1376| 14500101 | Service exception. |
1377
1378**Example**
1379
1380```js
1381try {
1382    sensor.once(sensor.SensorId.ORIENTATION, function (data) {
1383        console.info('The device rotates at an angle around the X axis: ' + data.beta);
1384        console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
1385        console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
1386    });
1387} catch (err) {
1388    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1389}
1390```
1391
1392### PEDOMETER<sup>9+</sup>
1393
1394once(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void
1395
1396Obtains data of the pedometer sensor once.
1397
1398**Required permissions**: ohos.permission.ACTIVITY_MOTION
1399
1400**System capability**: SystemCapability.Sensors.Sensor
1401
1402**Parameters**
1403
1404| Name  | Type                                                   | Mandatory| Description                                                   |
1405| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
1406| type     | [SensorId](#sensorid9).PEDOMETER                        | Yes  | Sensor type. The value is fixed at **SensorId.PEDOMETER**.             |
1407| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **PedometerResponse** object.|
1408
1409**Error code**
1410
1411For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1412
1413| Error Code ID| Error Message          |
1414| -------- | ------------------ |
1415| 14500101 | Service exception. |
1416
1417**Example**
1418
1419```js
1420try {
1421    sensor.once(sensor.SensorId.PEDOMETER, function (data) {
1422        console.info('Step count: ' + data.steps);
1423    });
1424} catch (err) {
1425    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1426}
1427```
1428
1429### PEDOMETER_DETECTION<sup>9+</sup>
1430
1431once(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;): void
1432
1433Obtains data of the pedometer sensor once.
1434
1435**Required permissions**: ohos.permission.ACTIVITY_MOTION
1436
1437**System capability**: SystemCapability.Sensors.Sensor
1438
1439**Parameters**
1440
1441| Name  | Type                                                        | Mandatory| Description                                                        |
1442| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1443| type     | [SensorId](#sensorid9).PEDOMETER_DETECTION                   | Yes  | Sensor type. The value is fixed at **SensorId.PEDOMETER_DETECTION**.        |
1444| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **PedometerDetectionResponse** object.|
1445
1446**Error code**
1447
1448For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1449
1450| Error Code ID| Error Message          |
1451| -------- | ------------------ |
1452| 14500101 | Service exception. |
1453
1454**Example**
1455
1456```js
1457try {
1458    sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
1459        console.info('Scalar data: ' + data.scalar);
1460    });
1461} catch (err) {
1462    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1463}
1464```
1465
1466### PROXIMITY<sup>9+</sup>
1467
1468once(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void
1469
1470Obtains data of the proximity sensor once.
1471
1472**System capability**: SystemCapability.Sensors.Sensor
1473
1474**Parameters**
1475
1476| Name  | Type                                                   | Mandatory| Description                                                   |
1477| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- |
1478| type     | [SensorId](#sensorid9).PROXIMITY                        | Yes  | Sensor type. The value is fixed at **SensorId.PROXIMITY**.             |
1479| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **ProximityResponse** object.|
1480
1481**Error code**
1482
1483For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1484
1485| Error Code ID| Error Message          |
1486| -------- | ------------------ |
1487| 14500101 | Service exception. |
1488
1489**Example**
1490
1491```js
1492try {
1493    sensor.once(sensor.SensorId.PROXIMITY, function (data) {
1494        console.info('Distance: ' + data.distance);
1495    });
1496} catch (err) {
1497    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1498}
1499```
1500
1501### ROTATION_VECTOR<sup>9+</sup>
1502
1503once(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void
1504
1505Obtains data of the rotation vector sensor once.
1506
1507**System capability**: SystemCapability.Sensors.Sensor
1508
1509**Parameters**
1510
1511| Name  | Type                                                        | Mandatory| Description                                                        |
1512| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1513| type     | [SensorId](#sensorid9).ROTATION_VECTOR                       | Yes  | Sensor type. The value is fixed at **SensorId.ROTATION_VECTOR**.            |
1514| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **RotationVectorResponse** object.|
1515
1516**Error code**
1517
1518For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1519
1520| Error Code ID| Error Message          |
1521| -------- | ------------------ |
1522| 14500101 | Service exception. |
1523
1524**Example**
1525
1526```js
1527try {
1528    sensor.once(sensor.SensorId.ROTATION_VECTOR, function (data) {
1529        console.info('X-coordinate component: ' + data.x);
1530        console.info('Y-coordinate component: ' + data.y);
1531        console.info('Z-coordinate component: ' + data.z);
1532        console.info('Scalar quantity: ' + data.w);
1533    });
1534} catch (err) {
1535    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1536}
1537```
1538
1539### SIGNIFICANT_MOTION<sup>9+</sup>
1540
1541once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;): void
1542
1543Obtains data of the significant motion sensor once.
1544
1545**System capability**: SystemCapability.Sensors.Sensor
1546
1547**Parameters**
1548
1549| Name  | Type                                                        | Mandatory| Description                                                        |
1550| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1551| type     | [SensorId](#sensorid9).SIGNIFICANT_MOTION                    | Yes  | Sensor type. The value is fixed at **SensorId.SIGNIFICANT_MOTION**.         |
1552| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **SignificantMotionResponse** object.|
1553
1554**Error code**
1555
1556For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1557
1558| Error Code ID| Error Message          |
1559| -------- | ------------------ |
1560| 14500101 | Service exception. |
1561
1562**Example**
1563
1564```js
1565try {
1566    sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
1567        console.info('Scalar data: ' + data.scalar);
1568    });
1569} catch (err) {
1570    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1571}
1572```
1573
1574### WEAR_DETECTION<sup>9+</sup>
1575
1576once(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void
1577
1578Obtains data of the wear detection sensor once.
1579
1580**System capability**: SystemCapability.Sensors.Sensor
1581
1582**Parameters**
1583
1584| Name  | Type                                                        | Mandatory| Description                                                       |
1585| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
1586| type     | [SensorId](#sensorid9).WEAR_DETECTION                        | Yes  | Sensor type. The value is fixed at **SensorId.WEAR_DETECTION**.            |
1587| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes  | Callback used to report the sensor data, which is a **WearDetectionResponse** object.|
1588
1589**Error code**
1590
1591For details about the following error codes, see [Sensor Error Codes](../errorcodes/errorcode-sensor.md).
1592
1593| Error Code ID| Error Message          |
1594| -------- | ------------------ |
1595| 14500101 | Service exception. |
1596
1597**Example**
1598
1599```js
1600try {
1601    sensor.once(sensor.SensorId.WEAR_DETECTION, function (data) {
1602        console.info("Wear status: " + data.value);
1603    });
1604} catch (err) {
1605    console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1606}
1607```
1608
1609## sensor.off<sup>9+</sup>
1610
1611### ACCELEROMETER<sup>9+</sup>
1612
1613off(type: SensorId.ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void
1614
1615Unsubscribes from data of the acceleration sensor.
1616
1617**Required permissions**: ohos.permission.ACCELEROMETER
1618
1619**System capability**: SystemCapability.Sensors.Sensor
1620
1621**Parameters**
1622
1623| Name  | Type                                                        | Mandatory| Description                                                        |
1624| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1625| type     | [SensorId](#sensorid9).ACCELEROMETER                         | Yes  | Sensor type. The value is fixed at **SensorId.ACCELEROMETER**.              |
1626| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1627
1628**Example**
1629
1630```js
1631function callback1(data) {
1632    console.info('Callback1 data: ' + JSON.stringify(data));
1633}
1634function callback2(data) {
1635    console.info('Callback2 data: ' + JSON.stringify(data));
1636}
1637try {
1638    sensor.on(sensor.SensorId.ACCELEROMETER, callback1);
1639    sensor.on(sensor.SensorId.ACCELEROMETER, callback2);
1640    // Unsubscribe from callback1.
1641    sensor.off(sensor.SensorId.ACCELEROMETER, callback1);
1642    // Unsubscribe from all callbacks of the SensorId.ACCELEROMETER type.
1643    sensor.off(sensor.SensorId.ACCELEROMETER);
1644} catch (err) {
1645    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1646}
1647```
1648
1649### ACCELEROMETER_UNCALIBRATED<sup>9+</sup>
1650
1651off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
1652
1653Unsubscribes from data of the uncalibrated acceleration sensor.
1654
1655**Required permissions**: ohos.permission.ACCELEROMETER
1656
1657**System capability**: SystemCapability.Sensors.Sensor
1658
1659**Parameters**
1660
1661| Name  | Type                                                        | Mandatory| Description                                                        |
1662| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1663| type     | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED            | Yes  | Sensor type. The value is fixed at **SensorId.ACCELEROMETER_UNCALIBRATED**. |
1664| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1665
1666**Example**
1667
1668```js
1669function callback1(data) {
1670    console.info('Callback1 data: ' + JSON.stringify(data));
1671}
1672function callback2(data) {
1673    console.info('Callback2 data: ' + JSON.stringify(data));
1674}
1675try {
1676    sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
1677    sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback2);
1678    // Unsubscribe from callback1.
1679    sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
1680    // Unsubscribe from all callbacks of the SensorId.ACCELEROMETER_UNCALIBRATED type.
1681    sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED);
1682} catch (err) {
1683    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1684}
1685```
1686
1687### AMBIENT_LIGHT<sup>9+</sup>
1688
1689off(type: SensorId.AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void
1690
1691Unsubscribes from data of the ambient light sensor.
1692
1693**System capability**: SystemCapability.Sensors.Sensor
1694
1695**Parameters**
1696
1697| Name  | Type                                           | Mandatory| Description                                                        |
1698| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
1699| type     | [SensorId](#sensorid9).AMBIENT_LIGHT            | Yes  | Sensor type. The value is fixed at **SensorId.AMBIENT_LIGHT**.              |
1700| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1701
1702**Example**
1703
1704```js
1705function callback1(data) {
1706    console.info('Callback1 data: ' + JSON.stringify(data));
1707}
1708function callback2(data) {
1709    console.info('Callback2 data: ' + JSON.stringify(data));
1710}
1711try {
1712    sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback1);
1713    sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2);
1714    // Unsubscribe from callback1.
1715    sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback1);
1716    // Unsubscribe from all callbacks of the SensorId.AMBIENT_LIGHT type.
1717    sensor.off(sensor.SensorId.AMBIENT_LIGHT);
1718} catch (err) {
1719    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1720}
1721```
1722
1723### AMBIENT_TEMPERATURE<sup>9+</sup>
1724
1725off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void
1726
1727Unsubscribes from data of the ambient temperature sensor.
1728
1729**System capability**: SystemCapability.Sensors.Sensor
1730
1731**Parameters**
1732
1733| Name  | Type                                                        | Mandatory| Description                                                        |
1734| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1735| type     | [SensorId](#sensorid9).AMBIENT_TEMPERATURE                   | Yes  | Sensor type. The value is fixed at **SensorId.AMBIENT_TEMPERATURE**.        |
1736| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1737
1738**Example**
1739
1740```js
1741function callback1(data) {
1742    console.info('Callback1 data: ' + JSON.stringify(data));
1743}
1744function callback2(data) {
1745    console.info('Callback2 data: ' + JSON.stringify(data));
1746}
1747try {
1748    sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
1749    sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback2);
1750    // Unsubscribe from callback1.
1751    sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
1752    // Unsubscribe from all callbacks of the SensorId.AMBIENT_TEMPERATURE type.
1753    sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE);
1754} catch (err) {
1755    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1756}
1757```
1758
1759### BAROMETER<sup>9+</sup>
1760
1761off(type: SensorId.BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void
1762
1763Unsubscribes from data of the barometer sensor.
1764
1765**System capability**: SystemCapability.Sensors.Sensor
1766
1767**Parameters**
1768
1769| Name  | Type                                                   | Mandatory| Description                                                        |
1770| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
1771| type     | [SensorId](#sensorid9).BAROMETER                        | Yes  | Sensor type. The value is fixed at **SensorId.BAROMETER**.                  |
1772| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1773
1774**Example**
1775
1776```js
1777function callback1(data) {
1778    console.info('Callback1 data: ' + JSON.stringify(data));
1779}
1780function callback2(data) {
1781    console.info('Callback2 data: ' + JSON.stringify(data));
1782}
1783try {
1784    sensor.on(sensor.SensorId.BAROMETER, callback1);
1785    sensor.on(sensor.SensorId.BAROMETER, callback2);
1786    // Unsubscribe from callback1.
1787    sensor.off(sensor.SensorId.BAROMETER, callback1);
1788    // Unsubscribe from all callbacks of the SensorId.BAROMETER type.
1789    sensor.off(sensor.SensorId.BAROMETER);
1790} catch (err) {
1791    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1792}
1793```
1794
1795### GRAVITY<sup>9+</sup>
1796
1797off(type: SensorId.GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
1798
1799Unsubscribes from data of the gravity sensor.
1800
1801**System capability**: SystemCapability.Sensors.Sensor
1802
1803**Parameters**
1804
1805| Name  | Type                                               | Mandatory| Description                                                        |
1806| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
1807| type     | [SensorId](#sensorid9).GRAVITY                      | Yes  | Sensor type. The value is fixed at **SensorId.GRAVITY**.                    |
1808| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1809
1810**Example**
1811
1812```js
1813function callback1(data) {
1814    console.info('Callback1 data: ' + JSON.stringify(data));
1815}
1816function callback2(data) {
1817    console.info('Callback2 data: ' + JSON.stringify(data));
1818}
1819try {
1820    sensor.on(sensor.SensorId.GRAVITY, callback1);
1821    sensor.on(sensor.SensorId.GRAVITY, callback2);
1822    // Unsubscribe from callback1.
1823    sensor.off(sensor.SensorId.GRAVITY, callback1);
1824    // Unsubscribe from all callbacks of the SensorId.GRAVITY type.
1825    sensor.off(sensor.SensorId.GRAVITY);
1826} catch (err) {
1827    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1828}
1829```
1830
1831### GYROSCOPE<sup>9+</sup>
1832
1833off(type: SensorId.GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void
1834
1835Unsubscribes from data of the gyroscope sensor.
1836
1837**Required permissions**: ohos.permission.GYROSCOPE
1838
1839**System capability**: SystemCapability.Sensors.Sensor
1840
1841**Parameters**
1842
1843| Name  | Type                                                   | Mandatory| Description                                                        |
1844| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
1845| type     | [SensorId](#sensorid9).GYROSCOPE                        | Yes  | Sensor type. The value is fixed at **SensorId.GYROSCOPE**.                  |
1846| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1847
1848**Example**
1849
1850```js
1851function callback1(data) {
1852    console.info('Callback1 data: ' + JSON.stringify(data));
1853}
1854function callback2(data) {
1855    console.info('Callback2 data: ' + JSON.stringify(data));
1856}
1857try {
1858    sensor.on(sensor.SensorId.GYROSCOPE, callback1);
1859    sensor.on(sensor.SensorId.GYROSCOPE, callback2);
1860    // Unsubscribe from callback1.
1861    sensor.off(sensor.SensorId.GYROSCOPE, callback1);
1862    // Unsubscribe from all callbacks of the SensorId.GYROSCOPE type.
1863    sensor.off(sensor.SensorId.GYROSCOPE);
1864} catch (err) {
1865    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1866}
1867```
1868
1869### GYROSCOPE_UNCALIBRATED<sup>9+</sup>
1870
1871off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
1872
1873 Unsubscribes from data of the uncalibrated gyroscope sensor.
1874
1875**Required permissions**: ohos.permission.GYROSCOPE
1876
1877**System capability**: SystemCapability.Sensors.Sensor
1878
1879**Parameters**
1880
1881| Name  | Type                                                        | Mandatory| Description                                                        |
1882| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1883| type     | [SensorId](#sensorid9).GYROSCOPE_UNCALIBRATED                | Yes  | Sensor type. The value is fixed at **SensorId.GYROSCOPE_UNCALIBRATED**.     |
1884| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1885
1886**Example**
1887
1888```js
1889function callback1(data) {
1890    console.info('Callback1 data: ' + JSON.stringify(data));
1891}
1892function callback2(data) {
1893    console.info('Callback2 data: ' + JSON.stringify(data));
1894}
1895try {
1896    sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
1897    sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback2);
1898    // Unsubscribe from callback1.
1899    sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
1900    // Unsubscribe from all callbacks of the SensorId.GYROSCOPE_UNCALIBRATED type.
1901    sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED);
1902} catch (err) {
1903    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1904}
1905```
1906
1907### HALL<sup>9+</sup>
1908
1909off(type: SensorId.HALL, callback?: Callback&lt;HallResponse&gt;): void
1910
1911Unsubscribes from data of the Hall effect sensor.
1912
1913**System capability**: SystemCapability.Sensors.Sensor
1914
1915**Parameters**
1916
1917| Name  | Type                                         | Mandatory| Description                                                        |
1918| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
1919| type     | [SensorId](#sensorid9).HALL                   | Yes  | Sensor type. The value is fixed at **SensorId.HALL**.                       |
1920| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1921
1922**Example**
1923
1924```js
1925function callback1(data) {
1926    console.info('Callback1 data: ' + JSON.stringify(data));
1927}
1928function callback2(data) {
1929    console.info('Callback2 data: ' + JSON.stringify(data));
1930}
1931try {
1932    sensor.on(sensor.SensorId.HALL, callback1);
1933    sensor.on(sensor.SensorId.HALL, callback2);
1934    // Unsubscribe from callback1.
1935    sensor.off(sensor.SensorId.HALL, callback1);
1936    // Unsubscribe from all callbacks of the SensorId.HALL type.
1937    sensor.off(sensor.SensorId.HALL);
1938} catch (err) {
1939    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1940}
1941```
1942
1943### HEART_RATE<sup>9+</sup>
1944
1945off(type: SensorId.HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void
1946
1947Unsubscribes from data of the heart rate sensor.
1948
1949**Required permissions**: ohos.permission.READ_HEALTH_DATA
1950
1951**System capability**: SystemCapability.Sensors.Sensor
1952
1953**Parameters**
1954
1955| Name  | Type                                                   | Mandatory| Description                                                        |
1956| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
1957| type     | [SensorId](#sensorid9).HEART_RATE                       | Yes  | Sensor type. The value is fixed at **SensorId.HEART_RATE**.                 |
1958| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1959
1960**Example**
1961
1962```js
1963function callback1(data) {
1964    console.info('Callback1 data: ' + JSON.stringify(data));
1965}
1966function callback2(data) {
1967    console.info('Callback2 data: ' + JSON.stringify(data));
1968}
1969try {
1970    sensor.on(sensor.SensorId.HEART_RATE, callback1);
1971    sensor.on(sensor.SensorId.HEART_RATE, callback2);
1972    // Unsubscribe from callback1.
1973    sensor.off(sensor.SensorId.HEART_RATE, callback1);
1974    // Unsubscribe from all callbacks of the SensorId.HEART_RATE type.
1975    sensor.off(sensor.SensorId.HEART_RATE);
1976} catch (err) {
1977    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
1978}
1979```
1980
1981### HUMIDITY<sup>9+</sup>
1982
1983off(type: SensorId.HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
1984
1985Unsubscribes from data of the humidity sensor.
1986
1987**System capability**: SystemCapability.Sensors.Sensor
1988
1989**Parameters**
1990
1991| Name  | Type                                                 | Mandatory| Description                                                        |
1992| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
1993| type     | [SensorId](#sensorid9).HUMIDITY                       | Yes  | Sensor type. The value is fixed at **SensorId.HUMIDITY**.                   |
1994| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
1995
1996**Example**
1997
1998```js
1999function callback1(data) {
2000    console.info('Callback1 data: ' + JSON.stringify(data));
2001}
2002function callback2(data) {
2003    console.info('Callback2 data: ' + JSON.stringify(data));
2004}
2005try {
2006    sensor.on(sensor.SensorId.HUMIDITY, callback1);
2007    sensor.on(sensor.SensorId.HUMIDITY, callback2);
2008    // Unsubscribe from callback1.
2009    sensor.off(sensor.SensorId.HUMIDITY, callback1);
2010    // Unsubscribe from all callbacks of the SensorId.HUMIDITY type.
2011    sensor.off(sensor.SensorId.HUMIDITY);
2012} catch (err) {
2013    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2014}
2015```
2016
2017### LINEAR_ACCELEROMETER<sup>9+</sup>
2018
2019off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void
2020
2021Unsubscribes from data of the linear acceleration sensor.
2022
2023**Required permissions**: ohos.permission.ACCELEROMETER
2024
2025**System capability**: SystemCapability.Sensors.Sensor
2026
2027**Parameters**
2028
2029| Name  | Type                                                        | Mandatory| Description                                                        |
2030| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2031| type     | [SensorId](#sensorid9).LINEAR_ACCELEROMETER                  | Yes  | Sensor type. The value is fixed at **SensorId.LINEAR_ACCELERATION**.        |
2032| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2033
2034**Example**
2035
2036```js
2037function callback1(data) {
2038    console.info('Callback1 data: ' + JSON.stringify(data));
2039}
2040function callback2(data) {
2041    console.info('Callback2 data: ' + JSON.stringify(data));
2042}
2043try {
2044    sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
2045    sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback2);
2046    // Unsubscribe from callback1.
2047    sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
2048    // Unsubscribe from all callbacks of the SensorId.LINEAR_ACCELEROMETER type.
2049    sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER);
2050} catch (err) {
2051    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2052}
2053```
2054
2055### MAGNETIC_FIELD<sup>9+</sup>
2056
2057off(type: SensorId.MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void
2058
2059Unsubscribes from data of the magnetic field sensor.
2060
2061**System capability**: SystemCapability.Sensors.Sensor
2062
2063**Parameters**
2064
2065| Name  | Type                                                        | Mandatory| Description                                                        |
2066| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2067| type     | [SensorId](#sensorid9).MAGNETIC_FIELD                        | Yes  | Sensor type. The value is fixed at **SensorId.MAGNETIC_FIELD**.             |
2068| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2069
2070**Example**
2071
2072```js
2073function callback1(data) {
2074    console.info('Callback1 data: ' + JSON.stringify(data));
2075}
2076function callback2(data) {
2077    console.info('Callback2 data: ' + JSON.stringify(data));
2078}
2079try {
2080    sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback1);
2081    sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2);
2082    // Unsubscribe from callback1.
2083    sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback1);
2084    // Unsubscribe from all callbacks of the SensorId.MAGNETIC_FIELD type.
2085    sensor.off(sensor.SensorId.MAGNETIC_FIELD);
2086} catch (err) {
2087    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2088}
2089```
2090
2091### MAGNETIC_FIELD_UNCALIBRATED<sup>9+</sup>
2092
2093off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
2094
2095Unsubscribes from data of the uncalibrated magnetic field sensor.
2096
2097**System capability**: SystemCapability.Sensors.Sensor
2098
2099**Parameters**
2100
2101| Name  | Type                                                        | Mandatory| Description                                                        |
2102| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2103| type     | [SensorId](#sensorid9).MAGNETIC_FIELD_UNCALIBRATED           | Yes  | Sensor type. The value is fixed at **SensorId.MAGNETIC_FIELD_UNCALIBRATED**.|
2104| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2105
2106**Example**
2107
2108```js
2109function callback1(data) {
2110    console.info('Callback1 data: ' + JSON.stringify(data));
2111}
2112function callback2(data) {
2113    console.info('Callback2 data: ' + JSON.stringify(data));
2114}
2115try {
2116    sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
2117    sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback2);
2118    // Unsubscribe from callback1.
2119    sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
2120    // Unsubscribe from all callbacks of the SensorId.MAGNETIC_FIELD_UNCALIBRATED type.
2121    sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED);
2122} catch (err) {
2123    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2124}
2125```
2126
2127### ORIENTATION<sup>9+</sup>
2128
2129off(type: SensorId.ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void
2130
2131Unsubscribes from data of the orientation sensor.
2132
2133**System capability**: SystemCapability.Sensors.Sensor
2134
2135**Parameters**
2136
2137| Name  | Type                                                       | Mandatory| Description                                                        |
2138| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
2139| type     | [SensorId](#sensorid9).ORIENTATION                          | Yes  | Sensor type. The value is fixed at **SensorId.ORIENTATION**.                |
2140| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2141
2142**Example**
2143
2144```js
2145function callback1(data) {
2146    console.info('Callback1 data: ' + JSON.stringify(data));
2147}
2148function callback2(data) {
2149    console.info('Callback2 data: ' + JSON.stringify(data));
2150}
2151try {
2152    sensor.on(sensor.SensorId.ORIENTATION, callback1);
2153    sensor.on(sensor.SensorId.ORIENTATION, callback2);
2154    // Unsubscribe from callback1.
2155    sensor.off(sensor.SensorId.ORIENTATION, callback1);
2156    // Unsubscribe from all callbacks of the SensorId.ORIENTATION type.
2157    sensor.off(sensor.SensorId.ORIENTATION);
2158} catch (err) {
2159    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2160}
2161```
2162
2163### PEDOMETER<sup>9+</sup>
2164
2165off(type: SensorId.PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void
2166
2167Unsubscribes from data of the pedometer sensor.
2168
2169**Required permissions**: ohos.permission.ACTIVITY_MOTION
2170
2171**System capability**: SystemCapability.Sensors.Sensor
2172
2173**Parameters**
2174
2175| Name  | Type                                                   | Mandatory| Description                                                        |
2176| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
2177| type     | [SensorId](#sensorid9).PEDOMETER                        | Yes  | Sensor type. The value is fixed at **SensorId.PEDOMETER**.                  |
2178| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2179
2180**Example**
2181
2182```js
2183function callback1(data) {
2184    console.info('Callback1 data: ' + JSON.stringify(data));
2185}
2186function callback2(data) {
2187    console.info('Callback2 data: ' + JSON.stringify(data));
2188}
2189try {
2190    sensor.on(sensor.SensorId.PEDOMETER, callback1);
2191    sensor.on(sensor.SensorId.PEDOMETER, callback2);
2192    // Unsubscribe from callback1.
2193    sensor.off(sensor.SensorId.PEDOMETER, callback1);
2194    // Unsubscribe from all callbacks of the SensorId.PEDOMETER type.
2195    sensor.off(sensor.SensorId.PEDOMETER);
2196} catch (err) {
2197    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2198}
2199```
2200
2201### PEDOMETER_DETECTION<sup>9+</sup>
2202
2203off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void
2204
2205Unsubscribes from data of the pedometer detection sensor.
2206
2207**Required permissions**: ohos.permission.ACTIVITY_MOTION
2208
2209**System capability**: SystemCapability.Sensors.Sensor
2210
2211**Parameters**
2212
2213| Name  | Type                                                        | Mandatory| Description                                                        |
2214| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2215| type     | [SensorId](#sensorid9).PEDOMETER_DETECTION                   | Yes  | Sensor type. The value is fixed at **SensorId.PEDOMETER_DETECTION**.        |
2216| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2217
2218**Example**
2219
2220```js
2221function callback1(data) {
2222    console.info('Callback1 data: ' + JSON.stringify(data));
2223}
2224function callback2(data) {
2225    console.info('Callback2 data: ' + JSON.stringify(data));
2226}
2227try {
2228    sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback1);
2229    sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2);
2230    // Unsubscribe from callback1.
2231    sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback1);
2232    // Unsubscribe from all callbacks of the SensorId.PEDOMETER_DETECTION type.
2233    sensor.off(sensor.SensorId.PEDOMETER_DETECTION);
2234} catch (err) {
2235    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2236}
2237```
2238
2239### PROXIMITY<sup>9+</sup>
2240
2241off(type: SensorId.PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void
2242
2243Unsubscribes from data of the proximity sensor.
2244
2245**System capability**: SystemCapability.Sensors.Sensor
2246
2247**Parameters**
2248
2249| Name  | Type                                                   | Mandatory| Description                                                        |
2250| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
2251| type     | [SensorId](#sensorid9).PROXIMITY                        | Yes  | Sensor type. The value is fixed at **SensorId.PROXIMITY**.                  |
2252| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2253
2254**Example**
2255
2256```js
2257function callback1(data) {
2258    console.info('Callback1 data: ' + JSON.stringify(data));
2259}
2260function callback2(data) {
2261    console.info('Callback2 data: ' + JSON.stringify(data));
2262}
2263try {
2264    sensor.on(sensor.SensorId.PROXIMITY, callback1);
2265    sensor.on(sensor.SensorId.PROXIMITY, callback2);
2266    // Unsubscribe from callback1.
2267    sensor.off(sensor.SensorId.PROXIMITY, callback1);
2268    // Unsubscribe from all callbacks of the SensorId.PROXIMITY type.
2269    sensor.off(sensor.SensorId.PROXIMITY);
2270} catch (err) {
2271    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2272}
2273```
2274
2275### ROTATION_VECTOR<sup>9+</sup>
2276
2277off(type: SensorId.ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void
2278
2279Unsubscribes from data of the rotation vector sensor.
2280
2281**System capability**: SystemCapability.Sensors.Sensor
2282
2283**Parameters**
2284
2285| Name  | Type                                                        | Mandatory| Description                                                        |
2286| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2287| type     | [SensorId](#sensorid9).ROTATION_VECTOR                       | Yes  | Sensor type. The value is fixed at **SensorId.ROTATION_VECTOR**.            |
2288| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2289
2290**Example**
2291
2292```js
2293function callback1(data) {
2294    console.info('Callback1 data: ' + JSON.stringify(data));
2295}
2296function callback2(data) {
2297    console.info('Callback2 data: ' + JSON.stringify(data));
2298}
2299try {
2300    sensor.on(sensor.SensorId.ROTATION_VECTOR, callback1);
2301    sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2);
2302    // Unsubscribe from callback1.
2303    sensor.off(sensor.SensorId.ROTATION_VECTOR, callback1);
2304    // Unsubscribe from all callbacks of the SensorId.ROTATION_VECTOR type.
2305    sensor.off(sensor.SensorId.ROTATION_VECTOR);
2306} catch (err) {
2307    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2308}
2309```
2310
2311### SIGNIFICANT_MOTION<sup>9+</sup>
2312
2313off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void
2314
2315Unsubscribes from data of the significant motion sensor.
2316
2317**System capability**: SystemCapability.Sensors.Sensor
2318
2319**Parameters**
2320
2321| Name  | Type                                                        | Mandatory| Description                                                        |
2322| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2323| type     | [SensorId](#sensorid9).SIGNIFICANT_MOTION                    | Yes  | Sensor type. The value is fixed at **SensorId.SIGNIFICANT_MOTION**.         |
2324| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2325
2326**Example**
2327
2328```js
2329function callback1(data) {
2330    console.info('Callback1 data: ' + JSON.stringify(data));
2331}
2332function callback2(data) {
2333    console.info('Callback2 data: ' + JSON.stringify(data));
2334}
2335try {
2336    sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
2337    sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback2);
2338    // Unsubscribe from callback1.
2339    sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
2340    // Unsubscribe from all callbacks of the SensorId.SIGNIFICANT_MOTION type.
2341    sensor.off(sensor.SensorId.SIGNIFICANT_MOTION);
2342} catch (err) {
2343    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2344}
2345```
2346
2347### WEAR_DETECTION<sup>9+</sup>
2348
2349off(type: SensorId.WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void
2350
2351Unsubscribes from data of the wear detection sensor.
2352
2353**System capability**: SystemCapability.Sensors.Sensor
2354
2355**Parameters**
2356
2357| Name  | Type                                                        | Mandatory| Description                                                        |
2358| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2359| type     | [SensorId](#sensorid9).WEAR_DETECTION                        | Yes  | Sensor type. The value is fixed at **SensorId.WEAR_DETECTION**.             |
2360| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified sensor type are unsubscribed from.|
2361
2362**Example**
2363
2364```js
2365function callback1(data) {
2366    console.info('Callback1 data: ' + JSON.stringify(data));
2367}
2368function callback2(data) {
2369    console.info('Callback2 data: ' + JSON.stringify(data));
2370}
2371try {
2372    sensor.on(sensor.SensorId.WEAR_DETECTION, callback1);
2373    sensor.on(sensor.SensorId.WEAR_DETECTION, callback2);
2374    // Unsubscribe from callback1.
2375    sensor.off(sensor.SensorId.WEAR_DETECTION, callback1);
2376    // Unsubscribe from all callbacks of the SensorId.WEAR_DETECTION type.
2377    sensor.off(sensor.SensorId.WEAR_DETECTION);
2378} catch (err) {
2379    console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
2380}
2381```
2382
2383## sensor.getGeomagneticInfo<sup>9+</sup>
2384
2385getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback&lt;GeomagneticResponse&gt;): void
2386
2387Obtains the geomagnetic field of a geographic location at a certain time. This API uses an asynchronous callback to return the result.
2388
2389**System capability**: SystemCapability.Sensors.Sensor
2390
2391**Parameters**
2392
2393| Name         | Type                                                        | Mandatory| Description                              |
2394| --------------- | ------------------------------------------------------------ | ---- | ---------------------------------- |
2395| locationOptions | [LocationOptions](#locationoptions)                          | Yes  | Geographic location, including the longitude, latitude, and altitude.                        |
2396| timeMillis      | number                                                       | Yes  | Time when the magnetic declination is obtained. The value is a Unix timestamp, in ms.|
2397| callback        | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes  | Callback used to return the geomagnetic field.                    |
2398
2399**Error code**
2400
2401For details about the following error codes, see [Error Codes of sensor.getGeomagneticInfo](../errorcodes/errorcode-sensor.md).
2402
2403| Error Code ID| Error Message          |
2404| -------- | ------------------ |
2405| 14500101 | Service exception. |
2406
2407**Example**
2408
2409```js
2410try {
2411    sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000, function (err, data) {
2412        if (err) {
2413            console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
2414            return;
2415        }
2416        console.info("GeomagneticInfo x" + data.x);
2417        console.info("GeomagneticInfo y" + data.y);
2418        console.info("GeomagneticInfo z" + data.z);
2419        console.info("GeomagneticInfo geomagneticDip" + data.geomagneticDip);
2420        console.info("GeomagneticInfo deflectionAngle" + data.deflectionAngle);
2421        console.info("GeomagneticInfo levelIntensity" + data.levelIntensity);
2422        console.info("GeomagneticInfo totalIntensity" + data.totalIntensity);
2423    });
2424} catch (err) {
2425    console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
2426}
2427```
2428
2429## sensor.getGeomagneticInfo<sup>9+</sup>
2430
2431getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt;
2432
2433Obtains the geomagnetic field of a geographic location at a certain time. This API uses a promise to return the result.
2434
2435**System capability**: SystemCapability.Sensors.Sensor
2436
2437**Parameters**
2438
2439| Name         | Type                               | Mandatory| Description                              |
2440| --------------- | ----------------------------------- | ---- | ---------------------------------- |
2441| locationOptions | [LocationOptions](#locationoptions) | Yes  | Geographic location, including the longitude, latitude, and altitude.                        |
2442| timeMillis      | number                              | Yes  | Time when the magnetic declination is obtained. The value is a Unix timestamp, in ms.|
2443
2444**Return value**
2445
2446| Type                                                      | Description          |
2447| ---------------------------------------------------------- | -------------- |
2448| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field.|
2449
2450**Error code**
2451
2452For details about the following error codes, see [Error Codes of sensor.getGeomagneticInfo](../errorcodes/errorcode-sensor.md).
2453
2454| Error Code ID| Error Message          |
2455| -------- | ------------------ |
2456| 14500101 | Service exception. |
2457
2458**Example**
2459
2460```js
2461try {
2462    const promise = sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000);
2463    promise.then((data) => {
2464        console.info("GeomagneticInfo x" + data.x);
2465        console.info("GeomagneticInfo y" + data.y);
2466        console.info("GeomagneticInfo z" + data.z);
2467        console.info("GeomagneticInfo geomagneticDip" + data.geomagneticDip);
2468        console.info("GeomagneticInfo deflectionAngle" + data.deflectionAngle);
2469        console.info("GeomagneticInfo levelIntensity" + data.levelIntensity);
2470        console.info("GeomagneticInfo totalIntensity" + data.totalIntensity);
2471    }, (err)=>{
2472        console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
2473    });
2474} catch (err) {
2475    console.error('Get geomagneticInfo. Error code: ' + err.code + '; message: ' + err.message);
2476}
2477```
2478
2479## sensor.getDeviceAltitude<sup>9+</sup>
2480
2481getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback&lt;number&gt;): void
2482
2483Obtains the altitude based on the atmospheric pressure. This API uses an asynchronous callback to return the result.
2484
2485**System capability**: SystemCapability.Sensors.Sensor
2486
2487**Parameters**
2488
2489| Name         | Type                       | Mandatory| Description                                 |
2490| --------------- | --------------------------- | ---- | ------------------------------------- |
2491| seaPressure     | number                      | Yes  | Sea-level atmospheric pressure, in hPa.        |
2492| currentPressure | number                      | Yes  | Specified atmospheric pressure, in hPa.|
2493| callback        | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the altitude, in meters.   |
2494
2495**Error code**
2496
2497For details about the following error codes, see [Error Codes of sensor.getDeviceAltitude](../errorcodes/errorcode-sensor.md).
2498
2499| Error Code ID| Error Message          |
2500| -------- | ------------------ |
2501| 14500101 | Service exception. |
2502
2503**Example**
2504
2505```js
2506try {
2507    let seaPressure = 1013.2;
2508    let currentPressure = 1500.0;
2509    sensor.getDeviceAltitude(seaPressure, currentPressure, function (err, data) {
2510        if (err) {
2511            console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
2512            return;
2513        }
2514        console.info('altitude: ' + data);
2515    });
2516} catch (err) {
2517    console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
2518}
2519```
2520
2521## sensor.getDeviceAltitude<sup>9+</sup>
2522
2523getDeviceAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
2524
2525Obtains the altitude based on the atmospheric pressure. This API uses a promise to return the result.
2526
2527**System capability**: SystemCapability.Sensors.Sensor
2528
2529**Parameters**
2530
2531| Name         | Type  | Mandatory| Description                                 |
2532| --------------- | ------ | ---- | ------------------------------------- |
2533| seaPressure     | number | Yes  | Sea-level atmospheric pressure, in hPa.        |
2534| currentPressure | number | Yes  | Specified atmospheric pressure, in hPa.|
2535
2536**Return value**
2537
2538| Type                 | Description                                |
2539| --------------------- | ------------------------------------ |
2540| Promise&lt;number&gt; | Promise used to return the altitude, in meters.|
2541
2542**Error code**
2543
2544For details about the following error codes, see [Error Codes of sensor.getDeviceAltitude](../errorcodes/errorcode-sensor.md).
2545
2546| Error Code ID| Error Message          |
2547| -------- | ------------------ |
2548| 14500101 | Service exception. |
2549
2550**Example**
2551
2552```js
2553try {
2554    let seaPressure = 1013.2;
2555    let currentPressure = 1500.0;
2556    const promise = sensor.getDeviceAltitude(seaPressure, currentPressure);
2557    promise.then((data) => {
2558        console.info('sensor_getDeviceAltitude_Promise success', data);
2559    }, (err) => {
2560        console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
2561    });
2562} catch (err) {
2563    console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
2564}
2565```
2566
2567## sensor.getInclination<sup>9+</sup>
2568
2569getInclination(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void
2570
2571Obtains the magnetic dip based on the inclination matrix. This API uses an asynchronous callback to return the result.
2572
2573**System capability**: SystemCapability.Sensors.Sensor
2574
2575**Parameters**
2576
2577| Name           | Type                       | Mandatory| Description                        |
2578| ----------------- | --------------------------- | ---- | ---------------------------- |
2579| inclinationMatrix | Array&lt;number&gt;         | Yes  | Inclination matrix.              |
2580| callback          | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the magnetic dip, in radians.|
2581
2582**Error code**
2583
2584For details about the following error codes, see [Error Codes of sensor.getInclination](../errorcodes/errorcode-sensor.md).
2585
2586| Error Code ID| Error Message          |
2587| -------- | ------------------ |
2588| 14500101 | Service exception. |
2589
2590**Example**
2591
2592```js
2593try {
2594    // inclinationMatrix can be 3*3 or 4*4.
2595    let inclinationMatrix = [
2596        1, 0, 0,
2597        0, 1, 0,
2598        0, 0, 1
2599    ]
2600    sensor.getInclination(inclinationMatrix, function (err, data) {
2601        if (err) {
2602            console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
2603            return;
2604        }
2605        console.info('Inclination: ' + data);
2606    })
2607} catch (err) {
2608    console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
2609}
2610```
2611
2612## sensor.getInclination<sup>9+</sup>
2613
2614 getInclination(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
2615
2616Obtains the magnetic dip based on the inclination matrix. This API uses a promise to return the result.
2617
2618**System capability**: SystemCapability.Sensors.Sensor
2619
2620**Parameters**
2621
2622| Name           | Type               | Mandatory| Description          |
2623| ----------------- | ------------------- | ---- | -------------- |
2624| inclinationMatrix | Array&lt;number&gt; | Yes  | Inclination matrix.|
2625
2626**Return value**
2627
2628| Type                 | Description                        |
2629| --------------------- | ---------------------------- |
2630| Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians.|
2631
2632**Error code**
2633
2634For details about the following error codes, see [Error Codes of sensor.getInclination](../errorcodes/errorcode-sensor.md).
2635
2636| Error Code ID| Error Message          |
2637| -------- | ------------------ |
2638| 14500101 | Service exception. |
2639
2640**Example**
2641
2642```js
2643try {
2644    // inclinationMatrix can be 3*3 or 4*4.
2645    let inclinationMatrix = [
2646        1, 0, 0,
2647        0, 1, 0,
2648        0, 0, 1
2649    ]
2650    const promise = sensor.getInclination(inclinationMatrix);
2651    promise.then((data) => {
2652        console.info('Inclination: ' + data);
2653    }, (err) => {
2654        console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
2655    });
2656} catch (err) {
2657    console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
2658}
2659```
2660
2661## sensor.getAngleVariation<sup>9+</sup>
2662
2663 getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;,
2664        callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
2665
2666Obtains the angle change between two rotation matrices. This API uses an asynchronous callback to return the result.
2667
2668**System capability**: SystemCapability.Sensors.Sensor
2669
2670**Parameters**
2671
2672| Name               | Type                                    | Mandatory| Description                             |
2673| --------------------- | ---------------------------------------- | ---- | --------------------------------- |
2674| currentRotationMatrix | Array&lt;number&gt;                      | Yes  | Current rotation matrix.               |
2675| preRotationMatrix     | Array&lt;number&gt;                      | Yes  | The other rotation matrix.                   |
2676| callback              | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes  | Callback used to return the angle change around the z, x, and y axes.|
2677
2678**Error code**
2679
2680For details about the following error codes, see [Error Codes of sensor.getAngleVariation](../errorcodes/errorcode-sensor.md).
2681
2682| Error Code ID| Error Message          |
2683| -------- | ------------------ |
2684| 14500101 | Service exception. |
2685
2686**Example**
2687
2688```js
2689try {
2690    // The rotation matrix can be 3*3 or 4*4.
2691    let currentRotationMatrix = [
2692        1, 0, 0,
2693        0, 1, 0,
2694        0, 0, 1
2695    ];
2696    let preRotationMatrix = [
2697        1, 0, 0,
2698        0, 0.87, -0.50,
2699        0, 0.50, 0.87
2700    ];
2701    sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix, function (err, data) {
2702        if (err) {
2703            console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
2704            return;
2705        }
2706        if (data.length < 3) {
2707            console.error("Get angle variation failed, length" + data.length);
2708        }
2709        console.info("Z: " + data[0]);
2710        console.info("X: " + data[1]);
2711        console.info("Y  : " + data[2]);
2712    })
2713} catch (err) {
2714    console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
2715}
2716```
2717
2718## sensor.getAngleVariation<sup>9+</sup>
2719
2720getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
2721
2722Obtains the angle change between two rotation matrices. This API uses a promise to return the result.
2723
2724**System capability**: SystemCapability.Sensors.Sensor
2725
2726**Parameters**
2727
2728| Name               | Type               | Mandatory| Description              |
2729| --------------------- | ------------------- | ---- | ------------------ |
2730| currentRotationMatrix | Array&lt;number&gt; | Yes  | Current rotation matrix.|
2731| preRotationMatrix     | Array&lt;number&gt; | Yes  | The other rotation matrix.                 |
2732
2733**Return value**
2734
2735| Type                              | Description                             |
2736| ---------------------------------- | --------------------------------- |
2737| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes.|
2738
2739**Error code**
2740
2741For details about the following error codes, see [Error Codes of sensor.getAngleVariation](../errorcodes/errorcode-sensor.md).
2742
2743| Error Code ID| Error Message          |
2744| -------- | ------------------ |
2745| 14500101 | Service exception. |
2746
2747**Example**
2748
2749```js
2750try {
2751    // The rotation matrix can be 3*3 or 4*4.
2752    let currentRotationMatrix = [
2753        1, 0, 0,
2754        0, 1, 0,
2755        0, 0, 1
2756    ];
2757    let preRotationMatrix = [
2758        1, 0, 0,
2759        0, 0.87, -0.50,
2760        0, 0.50, 0.87
2761    ];
2762    const promise = sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix);
2763    promise.then((data) => {
2764        if (data.length < 3) {
2765            console.error("Get angle variation failed, length" + data.length);
2766        }
2767        console.info("Z: " + data[0]);
2768        console.info("X: " + data[1]);
2769        console.info("Y  : " + data[2]);
2770    }, (err) => {
2771        console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
2772    });
2773} catch (err) {
2774    console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
2775}
2776```
2777
2778## sensor.getRotationMatrix<sup>9+</sup>
2779
2780getRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
2781
2782Obtains the rotation matrix from a rotation vector. This API uses an asynchronous callback to return the result.
2783
2784**System capability**: SystemCapability.Sensors.Sensor
2785
2786**Parameters**
2787
2788| Name        | Type                                    | Mandatory| Description          |
2789| -------------- | ---------------------------------------- | ---- | -------------- |
2790| rotationVector | Array&lt;number&gt;                      | Yes  | Rotation vector.|
2791| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes  | Callback used to return the rotation matrix.|
2792
2793**Error code**
2794
2795For details about the following error codes, see [Error Codes of sensor.getRotationMatrix](../errorcodes/errorcode-sensor.md).
2796
2797| Error Code ID| Error Message          |
2798| -------- | ------------------ |
2799| 14500101 | Service exception. |
2800
2801**Example**
2802
2803```js
2804try {
2805    let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
2806    sensor.getRotationMatrix(rotationVector, function (err, data) {
2807        if (err) {
2808            console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2809            return;
2810        }
2811        for (var i = 0; i < data.length; i++) {
2812            console.info('data[' + i + ']: ' + data[i]);
2813        }
2814    })
2815} catch (err) {
2816    console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2817}
2818```
2819
2820## sensor.getRotationMatrix<sup>9+</sup>
2821
2822getRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
2823
2824Obtains the rotation matrix from a rotation vector. This API uses a promise to return the result.
2825
2826**System capability**: SystemCapability.Sensors.Sensor
2827
2828**Parameters**
2829
2830| Name        | Type               | Mandatory| Description          |
2831| -------------- | ------------------- | ---- | -------------- |
2832| rotationVector | Array&lt;number&gt; | Yes  | Rotation vector.|
2833
2834**Return value**
2835
2836| Type                              | Description          |
2837| ---------------------------------- | -------------- |
2838| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix.|
2839
2840**Error code**
2841
2842For details about the following error codes, see [Error Codes of sensor.getRotationMatrix](../errorcodes/errorcode-sensor.md).
2843
2844| Error Code ID| Error Message          |
2845| -------- | ------------------ |
2846| 14500101 | Service exception. |
2847
2848**Example**
2849
2850```js
2851try {
2852    let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
2853    const promise = sensor.getRotationMatrix(rotationVector);
2854    promise.then((data) => {
2855        for (var i = 0; i < data.length; i++) {
2856            console.info('data[' + i + ']: ' + data[i]);
2857        }
2858    }, (err) => {
2859        console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2860    });
2861} catch (err) {
2862    console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2863}
2864```
2865
2866## sensor.transformRotationMatrix<sup>9+</sup>
2867
2868transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions,
2869        callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
2870
2871Transforms a rotation vector based on the coordinate system. This API uses an asynchronous callback to return the result.
2872
2873**System capability**: SystemCapability.Sensors.Sensor
2874
2875**Parameters**
2876
2877| Name          | Type                                     | Mandatory| Description                  |
2878| ---------------- | ----------------------------------------- | ---- | ---------------------- |
2879| inRotationVector | Array&lt;number&gt;                       | Yes  | Rotation vector.        |
2880| coordinates      | [CoordinatesOptions](#coordinatesoptions) | Yes  | Rotation vector to transform.      |
2881| callback         | AsyncCallback&lt;Array&lt;number&gt;&gt;  | Yes  | Callback used to return the rotation vector after being transformed.|
2882
2883**Error code**
2884
2885For details about the following error codes, see [Error Codes of sensor.transformRotationMatrix](../errorcodes/errorcode-sensor.md).
2886
2887| Error Code ID| Error Message          |
2888| -------- | ------------------ |
2889| 14500101 | Service exception. |
2890
2891**Example**
2892
2893```js
2894try {
2895    let rotationMatrix = [
2896        1, 0, 0,
2897        0, 0.87, -0.50,
2898        0, 0.50, 0.87
2899    ];
2900    sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 }, function (err, data) {
2901        if (err) {
2902            console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2903            return;
2904        }
2905        for (var i = 0; i < data.length; i++) {
2906            console.info('data[' + i + '] = ' + data[i]);
2907        }
2908    })
2909} catch (err) {
2910    console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2911}
2912```
2913
2914## sensor.transformRotationMatrix<sup>9+</sup>
2915
2916transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt;
2917
2918Transforms a rotation vector based on the coordinate system. This API uses a promise to return the result.
2919
2920**System capability**: SystemCapability.Sensors.Sensor
2921
2922**Parameters**
2923
2924| Name          | Type                                     | Mandatory| Description            |
2925| ---------------- | ----------------------------------------- | ---- | ---------------- |
2926| inRotationVector | Array&lt;number&gt;                       | Yes  | Rotation vector.  |
2927| coordinates      | [CoordinatesOptions](#coordinatesoptions) | Yes  | Rotation vector to transform.|
2928
2929**Return value**
2930
2931| Type                              | Description                  |
2932| ---------------------------------- | ---------------------- |
2933| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation vector after being transformed.|
2934
2935**Error code**
2936
2937For details about the following error codes, see [Error Codes of sensor.transformRotationMatrix](../errorcodes/errorcode-sensor.md).
2938
2939| Error Code ID| Error Message          |
2940| -------- | ------------------ |
2941| 14500101 | Service exception. |
2942
2943**Example**
2944
2945```js
2946try {
2947    let rotationMatrix = [
2948        1, 0, 0,
2949        0, 0.87, -0.50,
2950        0, 0.50, 0.87
2951    ];
2952    const promise = sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 });
2953    promise.then((data) => {
2954        for (var i = 0; i < data.length; i++) {
2955            console.info('data[' + i + ']: ' + data[i]);
2956        }
2957    }, (err) => {
2958        console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2959    });
2960} catch (err) {
2961    console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
2962}
2963```
2964
2965## sensor.getQuaternion<sup>9+</sup>
2966
2967getQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
2968
2969Obtains the quaternion from a rotation vector. This API uses an asynchronous callback to return the result.
2970
2971**System capability**: SystemCapability.Sensors.Sensor
2972
2973**Parameters**
2974
2975| Name        | Type                                    | Mandatory| Description          |
2976| -------------- | ---------------------------------------- | ---- | -------------- |
2977| rotationVector | Array&lt;number&gt;                      | Yes  | Rotation vector.|
2978| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes  | Callback used to return the quaternion.  |
2979
2980**Error code**
2981
2982For details about the following error codes, see [Error Codes of sensor.getQuaternion](../errorcodes/errorcode-sensor.md).
2983
2984| Error Code ID| Error Message          |
2985| -------- | ------------------ |
2986| 14500101 | Service exception. |
2987
2988**Example**
2989
2990```js
2991try {
2992    let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
2993    sensor.getQuaternion(rotationVector, function (err, data) {
2994        if (err) {
2995            console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
2996            return;
2997        }
2998        for (var i = 0; i < data.length; i++) {
2999            console.info('data[' + i + ']: ' + data[i]);
3000        }
3001    })
3002} catch (err) {
3003    console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
3004}
3005```
3006
3007## sensor.getQuaternion<sup>9+</sup>
3008
3009getQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
3010
3011Obtains the quaternion from a rotation vector. This API uses a promise to return the result.
3012
3013**System capability**: SystemCapability.Sensors.Sensor
3014
3015**Parameters**
3016
3017| Name        | Type               | Mandatory| Description          |
3018| -------------- | ------------------- | ---- | -------------- |
3019| rotationVector | Array&lt;number&gt; | Yes  | Rotation vector.|
3020
3021**Return value**
3022
3023| Type                              | Description        |
3024| ---------------------------------- | ------------ |
3025| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion.|
3026
3027**Error code**
3028
3029For details about the following error codes, see [Error Codes of sensor.getQuaternion](../errorcodes/errorcode-sensor.md).
3030
3031| Error Code ID| Error Message          |
3032| -------- | ------------------ |
3033| 14500101 | Service exception. |
3034
3035**Example**
3036
3037```js
3038try {
3039    let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
3040    const promise = sensor.getQuaternion(rotationVector);
3041    promise.then((data) => {
3042        for (var i = 0; i < data.length; i++) {
3043            console.info('data[' + i + ']: ' + data[i]);
3044        }
3045    }, (err) => {
3046        console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
3047    });
3048} catch (err) {
3049    console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
3050}
3051```
3052
3053## sensor.getOrientation<sup>9+</sup>
3054
3055getOrientation(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
3056
3057Obtains the device direction based on the rotation matrix. This API uses an asynchronous callback to return the result.
3058
3059**System capability**: SystemCapability.Sensors.Sensor
3060
3061**Parameters**
3062
3063| Name        | Type                                    | Mandatory| Description                             |
3064| -------------- | ---------------------------------------- | ---- | --------------------------------- |
3065| rotationMatrix | Array&lt;number&gt;                      | Yes  | Rotation matrix.                   |
3066| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes  | Callback used to return the rotation angle around the z, x, and y axes.|
3067
3068**Error code**
3069
3070For details about the following error codes, see [Error Codes of sensor.getOrientation](../errorcodes/errorcode-sensor.md).
3071
3072| Error Code ID| Error Message          |
3073| -------- | ------------------ |
3074| 14500101 | Service exception. |
3075
3076**Example**
3077
3078```js
3079try {
3080    let preRotationMatrix = [
3081        1, 0, 0,
3082        0, 0.87, -0.50,
3083        0, 0.50, 0.87
3084    ];
3085    sensor.getOrientation(preRotationMatrix, function (err, data) {
3086        if (err) {
3087            console.error('Get orientation failed. Error code: ' + err.code + '; message: ' + err.message);
3088            return;
3089        }
3090        if (data.length < 3) {
3091            console.error("Get orientation failed, length" + data.length);
3092        }
3093        console.info("Z: " + data[0]);
3094        console.info("X: " + data[1]);
3095        console.info("Y  : " + data[2]);
3096    })
3097} catch (err) {
3098    console.error('Get orientation failed. Error code: ' + err.code + '; message: ' + err.message);
3099}
3100```
3101
3102## sensor.getOrientation<sup>9+</sup>
3103
3104getOrientation(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
3105
3106Obtains the device direction based on the rotation matrix. This API uses a promise to return the result.
3107
3108**System capability**: SystemCapability.Sensors.Sensor
3109
3110**Parameters**
3111
3112| Name        | Type               | Mandatory| Description          |
3113| -------------- | ------------------- | ---- | -------------- |
3114| rotationMatrix | Array&lt;number&gt; | Yes  | Rotation matrix.|
3115
3116**Return value**
3117
3118| Type                              | Description                             |
3119| ---------------------------------- | --------------------------------- |
3120| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes.|
3121
3122**Error code**
3123
3124For details about the following error codes, see [Error Codes of sensor.getOrientation](../errorcodes/errorcode-sensor.md).
3125
3126| Error Code ID| Error Message          |
3127| -------- | ------------------ |
3128| 14500101 | Service exception. |
3129
3130**Example**
3131
3132```js
3133try {
3134    let preRotationMatrix = [
3135        1, 0, 0,
3136        0, 0.87, -0.50,
3137        0, 0.50, 0.87
3138    ];
3139    const promise = sensor.getOrientation(preRotationMatrix);
3140    promise.then((data) => {
3141        for (var i = 0; i < data.length; i++) {
3142            console.info('data[' + i + ']: ' + data[i]);
3143        }
3144    }, (err) => {
3145        console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message);
3146    });
3147} catch (err) {
3148    console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message);
3149}
3150```
3151
3152## sensor.getRotationMatrix<sup>9+</sup>
3153
3154getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;, callback: AsyncCallback&lt;RotationMatrixResponse&gt;): void
3155
3156Obtains the rotation matrix based on a gravity vector and geomagnetic vector. This API uses an asynchronous callback to return the result.
3157
3158**System capability**: SystemCapability.Sensors.Sensor
3159
3160**Parameters**
3161
3162| Name     | Type                                                        | Mandatory| Description          |
3163| ----------- | ------------------------------------------------------------ | ---- | -------------- |
3164| gravity     | Array&lt;number&gt;                                          | Yes  | Gravity vector.|
3165| geomagnetic | Array&lt;number&gt;                                          | Yes  | Geomagnetic vector.|
3166| callback    | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes  | Callback used to return the rotation matrix.|
3167
3168**Error code**
3169
3170For details about the following error codes, see [Error Codes of sensor.getRotationMatrix](../errorcodes/errorcode-sensor.md).
3171
3172| Error Code ID| Error Message          |
3173| -------- | ------------------ |
3174| 14500101 | Service exception. |
3175
3176**Example**
3177
3178```js
3179try {
3180    let gravity = [-0.27775216, 0.5351276, 9.788099];
3181    let geomagnetic = [210.87253, -78.6096, -111.44444];
3182    sensor.getRotationMatrix(gravity, geomagnetic, function (err, data) {
3183        if (err) {
3184            console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
3185            return;
3186        }
3187        console.info('RotationMatrix' + JSON.stringify(data));
3188    })
3189} catch (err) {
3190    console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
3191}
3192```
3193
3194## sensor.getRotationMatrix<sup>9+</sup>
3195
3196getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;): Promise&lt;RotationMatrixResponse&gt;
3197
3198Obtains the rotation matrix based on a gravity vector and geomagnetic vector. This API uses a promise to return the result.
3199
3200**System capability**: SystemCapability.Sensors.Sensor
3201
3202**Parameters**
3203
3204| Name     | Type               | Mandatory| Description          |
3205| ----------- | ------------------- | ---- | -------------- |
3206| gravity     | Array&lt;number&gt; | Yes  | Gravity vector.|
3207| geomagnetic | Array&lt;number&gt; | Yes  | Geomagnetic vector.|
3208
3209**Return value**
3210
3211| Type                                                        | Description          |
3212| ------------------------------------------------------------ | -------------- |
3213| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix.|
3214
3215**Error code**
3216
3217For details about the following error codes, see [Error Codes of sensor.getRotationMatrix](../errorcodes/errorcode-sensor.md).
3218
3219| Error Code ID| Error Message          |
3220| -------- | ------------------ |
3221| 14500101 | Service exception. |
3222
3223**Example**
3224
3225```js
3226try {
3227    let gravity = [-0.27775216, 0.5351276, 9.788099];
3228    let geomagnetic = [210.87253, -78.6096, -111.44444];
3229    const promise = sensor.getRotationMatrix(gravity, geomagnetic);
3230    promise.then((data) => {
3231        console.info('RotationMatrix' + JSON.stringify(data));
3232    }, (err) => {
3233        console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
3234    });
3235} catch (err) {
3236    console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
3237}
3238```
3239
3240## sensor.getSensorList<sup>9+</sup>
3241
3242getSensorList(callback: AsyncCallback&lt;Array&lt;Sensor&gt;&gt;): void
3243
3244Obtains information about all sensors on the device. This API uses an asynchronous callback to return the result.
3245
3246**System capability**: SystemCapability.Sensors.Sensor
3247
3248**Parameters**
3249
3250| Name  | Type                                          | Mandatory| Description            |
3251| -------- | ---------------------------------------------- | ---- | ---------------- |
3252| callback | AsyncCallback&lt;Array&lt;[Sensor](#sensor9)&gt;&gt; | Yes  | Callback used to return the sensor list.|
3253
3254**Error code**
3255
3256For details about the following error codes, see [Error Codes of sensor.getSensorList](../errorcodes/errorcode-sensor.md).
3257
3258| Error Code ID| Error Message          |
3259| -------- | ------------------ |
3260| 14500101 | Service exception. |
3261
3262**Example**
3263
3264```js
3265try {
3266    sensor.getSensorList((err, data) => {
3267        if (err) {
3268            console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
3269            return;
3270        }
3271        for (var i = 0; i < data.length; i++) {
3272            console.info('data[' + i + ']: ' + JSON.stringify(data[i]));
3273        }
3274    });
3275} catch (err) {
3276    console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
3277}
3278```
3279
3280## sensor.getSensorList<sup>9+</sup>
3281
3282 getSensorList(): Promise&lt;Array&lt;Sensor&gt;&gt;
3283
3284Obtains information about all sensors on the device. This API uses a promise to return the result.
3285
3286**System capability**: SystemCapability.Sensors.Sensor
3287
3288**Return value**
3289
3290| Name | Type                                    | Mandatory| Description            |
3291| ------- | ---------------------------------------- | ---- | ---------------- |
3292| promise | Promise&lt;Array&lt;[Sensor](#sensor9)&gt;&gt; | Yes  | Promise used to return the sensor list.|
3293
3294**Error code**
3295
3296For details about the following error codes, see [Error Codes of sensor.getSensorList](../errorcodes/errorcode-sensor.md).
3297
3298| Error Code ID| Error Message          |
3299| -------- | ------------------ |
3300| 14500101 | Service exception. |
3301
3302**Example**
3303
3304```js
3305try {
3306    sensor.getSensorList().then((data) => {
3307        for (var i = 0; i < data.length; i++) {
3308            console.info('data[' + i + ']: ' + JSON.stringify(data[i]));
3309        }
3310    }, (err) => {
3311        console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
3312    });
3313} catch (err) {
3314    console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
3315}
3316```
3317
3318##  sensor.getSingleSensor<sup>9+</sup>
3319
3320getSingleSensor(type: SensorId, callback: AsyncCallback&lt;Sensor&gt;): void
3321
3322Obtains information about the sensor of a specific type. This API uses an asynchronous callback to return the result.
3323
3324**System capability**: SystemCapability.Sensors.Sensor
3325
3326**Parameters**
3327
3328| Name  | Type                                   | Mandatory| Description            |
3329| -------- | --------------------------------------- | ---- | ---------------- |
3330| type     | [SensorId](#sensorid9)                  | Yes  | Sensor type.    |
3331| callback | AsyncCallback&lt;[Sensor](#sensor9)&gt; | Yes  | Callback used to return the sensor information.|
3332
3333**Error code**
3334
3335For details about the following error codes, see [Error Codes of sensor.getSingleSensor](../errorcodes/errorcode-sensor.md).
3336
3337| Error Code ID| Error Message          |
3338| -------- | ------------------ |
3339| 14500101 | Service exception. |
3340
3341**Example**
3342
3343```js
3344try {
3345    sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (err, data) => {
3346        if (err) {
3347            console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
3348            return;
3349        }
3350        console.info('Sensor: ' + JSON.stringify(data));
3351    });
3352} catch (err) {
3353    console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
3354}
3355```
3356
3357##  sensor.getSingleSensor<sup>9+</sup>
3358
3359 getSingleSensor(type: SensorId): Promise&lt;Sensor&gt;
3360
3361Obtains information about the sensor of a specific type. This API uses a promise to return the result.
3362
3363**System capability**: SystemCapability.Sensors.Sensor
3364
3365**Parameters**
3366
3367| Name| Type                  | Mandatory| Description        |
3368| ------ | ---------------------- | ---- | ------------ |
3369| type   | [SensorId](#sensorid9) | Yes  | Sensor type.|
3370
3371**Return value**
3372
3373| Name | Type                             | Mandatory| Description            |
3374| ------- | --------------------------------- | ---- | ---------------- |
3375| promise | Promise&lt;[Sensor](#sensor9)&gt; | Yes  | Promise used to return the sensor information.|
3376
3377**Error code**
3378
3379For details about the following error codes, see [Error Codes of sensor.getSingleSensor](../errorcodes/errorcode-sensor.md).
3380
3381| Error Code ID| Error Message          |
3382| -------- | ------------------ |
3383| 14500101 | Service exception. |
3384
3385**Example**
3386
3387```js
3388try {
3389    sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => {
3390        console.info('Sensor: ' + JSON.stringify(data));
3391    }, (err) => {
3392        console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
3393    });
3394} catch (err) {
3395    console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
3396}
3397```
3398
3399## SensorId<sup>9+</sup>
3400
3401Enumerates the sensor types.
3402
3403**System capability**: SystemCapability.Sensors.Sensor
3404
3405| Name                       | Value  | Description                  |
3406| --------------------------- | ---- | ---------------------- |
3407| ACCELEROMETER               | 1    | Acceleration sensor.        |
3408| GYROSCOPE                   | 2    | Gyroscope sensor.        |
3409| AMBIENT_LIGHT               | 5    | Ambient light sensor.        |
3410| MAGNETIC_FIELD              | 6    | Magnetic field sensor.          |
3411| BAROMETER                   | 8    | Barometer sensor.        |
3412| HALL                        | 10   | Hall effect sensor.          |
3413| PROXIMITY                   | 12   | Proximity sensor.        |
3414| HUMIDITY                    | 13   | Humidity sensor.          |
3415| ORIENTATION                 | 256  | Orientation sensor.          |
3416| GRAVITY                     | 257  | Gravity sensor.          |
3417| LINEAR_ACCELEROMETER        | 258  | Linear acceleration sensor.    |
3418| ROTATION_VECTOR             | 259  | Rotation vector sensor.      |
3419| AMBIENT_TEMPERATURE         | 260  | Ambient temperature sensor.      |
3420| MAGNETIC_FIELD_UNCALIBRATED | 261  | Uncalibrated magnetic field sensor.    |
3421| GYROSCOPE_UNCALIBRATED      | 263  | Uncalibrated gyroscope sensor.  |
3422| SIGNIFICANT_MOTION          | 264  | Significant motion sensor.      |
3423| PEDOMETER_DETECTION         | 265  | Pedometer detection sensor.      |
3424| PEDOMETER                   | 266  | Pedometer sensor.          |
3425| HEART_RATE                  | 278  | Heart rate sensor.          |
3426| WEAR_DETECTION              | 280  | Wear detection sensor.      |
3427| ACCELEROMETER_UNCALIBRATED  | 281  | Uncalibrated acceleration sensor.|
3428
3429## SensorType<sup>(deprecated)</sup>
3430
3431Enumerates the sensor types.
3432
3433**System capability**: SystemCapability.Sensors.Sensor
3434
3435
3436| Name                                      | Value  | Description                  |
3437| ------------------------------------------ | ---- | ---------------------- |
3438| SENSOR_TYPE_ID_ACCELEROMETER               | 1    | Acceleration sensor.        |
3439| SENSOR_TYPE_ID_GYROSCOPE                   | 2    | Gyroscope sensor.        |
3440| SENSOR_TYPE_ID_AMBIENT_LIGHT               | 5    | Ambient light sensor.        |
3441| SENSOR_TYPE_ID_MAGNETIC_FIELD              | 6    | Magnetic field sensor.          |
3442| SENSOR_TYPE_ID_BAROMETER                   | 8    | Barometer sensor.        |
3443| SENSOR_TYPE_ID_HALL                        | 10   | Hall effect sensor.          |
3444| SENSOR_TYPE_ID_PROXIMITY                   | 12   | Proximity sensor.        |
3445| SENSOR_TYPE_ID_HUMIDITY                    | 13   | Humidity sensor.          |
3446| SENSOR_TYPE_ID_ORIENTATION                 | 256  | Orientation sensor.          |
3447| SENSOR_TYPE_ID_GRAVITY                     | 257  | Gravity sensor.          |
3448| SENSOR_TYPE_ID_LINEAR_ACCELERATION         | 258  | Linear acceleration sensor.    |
3449| SENSOR_TYPE_ID_ROTATION_VECTOR             | 259  | Rotation vector sensor.      |
3450| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE         | 260  | Ambient temperature sensor.      |
3451| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261  | Uncalibrated magnetic field sensor.    |
3452| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED      | 263  | Uncalibrated gyroscope sensor.  |
3453| SENSOR_TYPE_ID_SIGNIFICANT_MOTION          | 264  | Significant motion sensor.      |
3454| SENSOR_TYPE_ID_PEDOMETER_DETECTION         | 265  | Pedometer detection sensor.      |
3455| SENSOR_TYPE_ID_PEDOMETER                   | 266  | Pedometer sensor.          |
3456| SENSOR_TYPE_ID_HEART_RATE                  | 278  | Heart rate sensor.          |
3457| SENSOR_TYPE_ID_WEAR_DETECTION              | 280  | Wear detection sensor.      |
3458| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED  | 281  | Uncalibrated acceleration sensor.|
3459
3460
3461## Response
3462
3463Describes the timestamp of the sensor data.
3464
3465**System capability**: SystemCapability.Sensors.Sensor
3466
3467| Name     | Type  | Readable| Writable| Description                    |
3468| --------- | ------ | ---- | ---- | ------------------------ |
3469| timestamp | number | Yes  | Yes  | Timestamp when the sensor reports data.|
3470
3471## Sensor<sup>9+</sup>
3472
3473Describes the sensor information.
3474
3475**System capability**: SystemCapability.Sensors.Sensor
3476
3477| Name           | Type| Readable| Writable| Description                  |
3478| --------------- | -------- | ---------------------- | ---------------------- | ---------------------- |
3479| sensorName      | string   | Yes | Yes | Sensor name.          |
3480| vendorName      | string   | Yes | Yes | Vendor of the sensor.        |
3481| firmwareVersion | string   | Yes | Yes | Firmware version of the sensor.      |
3482| hardwareVersion | string   | Yes | Yes | Hardware version of the sensor.      |
3483| sensorId        | number   | Yes | Yes | Sensor type ID.        |
3484| maxRange        | number   | Yes | Yes | Maximum measurement range of the sensor.|
3485| minSamplePeriod | number   | Yes | Yes | Minimum sampling period.  |
3486| maxSamplePeriod | number   | Yes | Yes | Maximum sampling period.  |
3487| precision       | number   | Yes | Yes | Precision of the sensor.          |
3488| power           | number   | Yes | Yes | Power of the sensor.          |
3489
3490## AccelerometerResponse
3491
3492Describes the acceleration sensor data. It extends from [Response](#response).
3493
3494**System capability**: SystemCapability.Sensors.Sensor
3495
3496
3497| Name| Type  | Readable| Writable| Description                                |
3498| ---- | ------ | ---- | ---- | ------------------------------------ |
3499| x    | number | Yes  | Yes  | Acceleration along the x-axis of the device, in m/s².|
3500| y    | number | Yes  | Yes  | Acceleration along the y-axis of the device, in m/s².|
3501| z    | number | Yes  | Yes  | Acceleration along the z-axis of the device, in m/s².|
3502
3503
3504## LinearAccelerometerResponse
3505
3506Describes the linear acceleration sensor data. It extends from [Response](#response).
3507
3508**System capability**: SystemCapability.Sensors.Sensor
3509
3510
3511| Name| Type  | Readable| Writable| Description                                    |
3512| ---- | ------ | ---- | ---- | ---------------------------------------- |
3513| x    | number | Yes  | Yes  | Linear acceleration along the x-axis of the device, in m/s².|
3514| y    | number | Yes  | Yes  | Linear acceleration along the y-axis of the device, in m/s².|
3515| z    | number | Yes  | Yes  | Linear acceleration along the z-axis of the device, in m/s².|
3516
3517
3518## AccelerometerUncalibratedResponse
3519
3520Describes the uncalibrated acceleration sensor data. It extends from [Response](#response).
3521
3522**System capability**: SystemCapability.Sensors.Sensor
3523
3524
3525| Name | Type  | Readable| Writable| Description                                            |
3526| ----- | ------ | ---- | ---- | ------------------------------------------------ |
3527| x     | number | Yes  | Yes  | Uncalibrated acceleration along the x-axis of the device, in m/s².      |
3528| y     | number | Yes  | Yes  | Uncalibrated acceleration along the y-axis of the device, in m/s².      |
3529| z     | number | Yes  | Yes  | Uncalibrated acceleration along the z-axis of the device, in m/s².      |
3530| biasX | number | Yes  | Yes  | Uncalibrated acceleration bias along the x-axis of the device, in m/s².  |
3531| biasY | number | Yes  | Yes  | Uncalibrated acceleration bias along the y-axis of the device, in m/s².|
3532| biasZ | number | Yes  | Yes  | Uncalibrated acceleration bias along the z-axis of the device, in m/s².  |
3533
3534
3535## GravityResponse
3536
3537Describes the gravity sensor data. It extends from [Response](#response).
3538
3539**System capability**: SystemCapability.Sensors.Sensor
3540
3541
3542| Name| Type  | Readable| Writable| Description                                    |
3543| ---- | ------ | ---- | ---- | ---------------------------------------- |
3544| x    | number | Yes  | Yes  | Gravitational acceleration along the x-axis of the device, in m/s².|
3545| y    | number | Yes  | Yes  | Gravitational acceleration along the y-axis of the device, in m/s².|
3546| z    | number | Yes  | Yes  | Gravitational acceleration along the z-axis of the device, in m/s².|
3547
3548
3549## OrientationResponse
3550
3551Describes the orientation sensor data. It extends from [Response](#response).
3552
3553**System capability**: SystemCapability.Sensors.Sensor
3554
3555
3556| Name | Type  | Readable| Writable| Description                             |
3557| ----- | ------ | ---- | ---- | --------------------------------- |
3558| alpha | number | Yes  | Yes  | Rotation angle of the device around the z-axis, in degrees.|
3559| beta  | number | Yes  | Yes  | Rotation angle of the device around the x-axis, in degrees.|
3560| gamma | number | Yes  | Yes  | Rotation angle of the device around the y-axis, in degrees.|
3561
3562
3563## RotationVectorResponse
3564
3565Describes the rotation vector sensor data. It extends from [Response](#response).
3566
3567**System capability**: SystemCapability.Sensors.Sensor
3568
3569
3570| Name| Type  | Readable| Writable| Description             |
3571| ---- | ------ | ---- | ---- | ----------------- |
3572| x    | number | Yes  | Yes  | X-component of the rotation vector.|
3573| y    | number | Yes  | Yes  | Y-component of the rotation vector.|
3574| z    | number | Yes  | Yes  | Z-component of the rotation vector.|
3575| w    | number | Yes  | Yes  | Scalar.           |
3576
3577
3578## GyroscopeResponse
3579
3580Describes the gyroscope sensor data. It extends from [Response](#response).
3581
3582**System capability**: SystemCapability.Sensors.Sensor
3583
3584
3585| Name| Type  | Readable| Writable| Description                            |
3586| ---- | ------ | ---- | ---- | -------------------------------- |
3587| x    | number | Yes  | Yes  | Angular velocity of rotation around the x-axis of the device, in rad/s.|
3588| y    | number | Yes  | Yes  | Angular velocity of rotation around the y-axis of the device, in rad/s.|
3589| z    | number | Yes  | Yes  | Angular velocity of rotation around the z-axis of the device, in rad/s.|
3590
3591
3592## GyroscopeUncalibratedResponse
3593
3594Describes the uncalibrated gyroscope sensor data. It extends from [Response](#response).
3595
3596**System capability**: SystemCapability.Sensors.Sensor
3597
3598
3599| Name | Type  | Readable| Writable| Description                                      |
3600| ----- | ------ | ---- | ---- | ------------------------------------------ |
3601| x     | number | Yes  | Yes  | Uncalibrated angular velocity of rotation around the x-axis of the device, in rad/s.    |
3602| y     | number | Yes  | Yes  | Uncalibrated angular velocity of rotation around the y-axis of the device, in rad/s.    |
3603| z     | number | Yes  | Yes  | Uncalibrated angular velocity of rotation around the z-axis of the device, in rad/s.    |
3604| biasX | number | Yes  | Yes  | Uncalibrated angular velocity bias of rotation around the x-axis of the device, in rad/s.|
3605| biasY | number | Yes  | Yes  | Uncalibrated angular velocity bias of rotation around the y-axis of the device, in rad/s.|
3606| biasZ | number | Yes  | Yes  | Uncalibrated angular velocity bias of rotation around the z-axis of the device, in rad/s.|
3607
3608
3609## SignificantMotionResponse
3610
3611Describes the significant motion sensor data. It extends from [Response](#response).
3612
3613**System capability**: SystemCapability.Sensors.Sensor
3614
3615
3616| Name  | Type  | Readable| Writable| Description                                                        |
3617| ------ | ------ | ---- | ---- | ------------------------------------------------------------ |
3618| scalar | number | Yes  | Yes  | Intensity of a motion. This parameter specifies whether a device has a significant motion on three physical axes (X, Y, and Z). The value **0** means that the device does not have a significant motion, and **1** means the opposite.|
3619
3620
3621## ProximityResponse
3622
3623Describes the proximity sensor data. It extends from [Response](#response).
3624
3625**System capability**: SystemCapability.Sensors.Sensor
3626
3627
3628| Name    | Type  | Readable| Writable| Description                                                  |
3629| -------- | ------ | ---- | ---- | ------------------------------------------------------ |
3630| distance | number | Yes  | Yes  | Proximity between the visible object and the device monitor. The value **0** means the two are close to each other, and **1** means that they are far away from each other.|
3631
3632
3633## LightResponse
3634
3635Describes the ambient light sensor data. It extends from [Response](#response).
3636
3637**System capability**: SystemCapability.Sensors.Sensor
3638
3639
3640| Name     | Type  | Readable| Writable| Description                  |
3641| --------- | ------ | ---- | ---- | ---------------------- |
3642| intensity | number | Yes  | Yes  | Illumination, in lux.|
3643
3644
3645## HallResponse
3646
3647Describes the Hall effect sensor data. It extends from [Response](#response).
3648
3649**System capability**: SystemCapability.Sensors.Sensor
3650
3651
3652| Name  | Type  | Readable| Writable| Description                                                        |
3653| ------ | ------ | ---- | ---- | ------------------------------------------------------------ |
3654| status | number | Yes  | Yes  | Hall effect sensor status. This parameter specifies whether a magnetic field exists around a device. The value **0** means that a magnetic field does not exist, and a value greater than **0** means the opposite.|
3655
3656
3657## MagneticFieldResponse
3658
3659Describes the magnetic field sensor data. It extends from [Response](#response).
3660
3661**System capability**: SystemCapability.Sensors.Sensor
3662
3663
3664| Name| Type  | Readable| Writable| Description                        |
3665| ---- | ------ | ---- | ---- | ---------------------------- |
3666| x    | number | Yes  | Yes  | Magnetic field strength on the x-axis, in μT.|
3667| y    | number | Yes  | Yes  | Magnetic field strength on the y-axis, in μT.|
3668| z    | number | Yes  | Yes  | Magnetic field strength on the z-axis, in μT.|
3669
3670
3671## MagneticFieldUncalibratedResponse
3672
3673Describes the uncalibrated magnetic field sensor data. It extends from [Response](#response).
3674
3675**System capability**: SystemCapability.Sensors.Sensor
3676
3677
3678| Name | Type  | Readable| Writable| Description                                  |
3679| ----- | ------ | ---- | ---- | -------------------------------------- |
3680| x     | number | Yes  | Yes  | Uncalibrated magnetic field strength on the x-axis, in μT.    |
3681| y     | number | Yes  | Yes  | Uncalibrated magnetic field strength on the y-axis, in μT.    |
3682| z     | number | Yes  | Yes  | Uncalibrated magnetic field strength on the z-axis, in μT.    |
3683| biasX | number | Yes  | Yes  | Bias of the uncalibrated magnetic field strength on the x-axis, in μT.|
3684| biasY | number | Yes  | Yes  | Bias of the uncalibrated magnetic field strength on the y-axis, in μT.|
3685| biasZ | number | Yes  | Yes  | Bias of the uncalibrated magnetic field strength on the z-axis, in μT.|
3686
3687
3688## PedometerResponse
3689
3690Describes the pedometer sensor data. It extends from [Response](#response).
3691
3692**System capability**: SystemCapability.Sensors.Sensor
3693
3694
3695| Name | Type  | Readable| Writable| Description            |
3696| ----- | ------ | ---- | ---- | ---------------- |
3697| steps | number | Yes  | Yes  | Number of steps a user has walked.|
3698
3699
3700## HumidityResponse
3701
3702Describes the humidity sensor data. It extends from [Response](#response).
3703
3704**System capability**: SystemCapability.Sensors.Sensor
3705
3706
3707| Name    | Type  | Readable| Writable| Description                                                     |
3708| -------- | ------ | ---- | ---- | --------------------------------------------------------- |
3709| humidity | number | Yes  | Yes  | Ambient relative humidity, in a percentage (%).|
3710
3711
3712## PedometerDetectionResponse
3713
3714Describes the pedometer detection sensor data. It extends from [Response](#response).
3715
3716**System capability**: SystemCapability.Sensors.Sensor
3717
3718
3719| Name  | Type  | Readable| Writable| Description                                                        |
3720| ------ | ------ | ---- | ---- | ------------------------------------------------------------ |
3721| scalar | number | Yes  | Yes  | Pedometer detection. This parameter specifies whether a user takes a step. The value **0** means that the user does not take a step, and **1** means that the user takes a step.|
3722
3723
3724## AmbientTemperatureResponse
3725
3726Describes the ambient temperature sensor data. It extends from [Response](#response).
3727
3728**System capability**: SystemCapability.Sensors.Sensor
3729
3730
3731| Name       | Type  | Readable| Writable| Description                      |
3732| ----------- | ------ | ---- | ---- | -------------------------- |
3733| temperature | number | Yes  | Yes  | Ambient temperature, in degree Celsius.|
3734
3735
3736## BarometerResponse
3737
3738Describes the barometer sensor data. It extends from [Response](#response).
3739
3740**System capability**: SystemCapability.Sensors.Sensor
3741
3742
3743| Name    | Type  | Readable| Writable| Description                    |
3744| -------- | ------ | ---- | ---- | ------------------------ |
3745| pressure | number | Yes  | Yes  | Atmospheric pressure, in pascal.|
3746
3747
3748## HeartRateResponse
3749
3750Describes the heart rate sensor data. It extends from [Response](#response).
3751
3752**System capability**: SystemCapability.Sensors.Sensor
3753
3754
3755| Name     | Type  | Readable| Writable| Description                                   |
3756| --------- | ------ | ---- | ---- | --------------------------------------- |
3757| heartRate | number | Yes  | Yes  | Heart rate, in beats per minute (bpm).|
3758
3759
3760## WearDetectionResponse
3761
3762Describes the wear detection sensor data. It extends from [Response](#response).
3763
3764**System capability**: SystemCapability.Sensors.Sensor
3765
3766
3767| Name | Type  | Readable| Writable| Description                                            |
3768| ----- | ------ | ---- | ---- | ------------------------------------------------ |
3769| value | number | Yes  | Yes  | Whether the device is being worn. The value **1** means that the device is being worn, and **0** means the opposite.|
3770
3771
3772## Options
3773
3774Describes the sensor data reporting frequency.
3775
3776**System capability**: SystemCapability.Sensors.Sensor
3777
3778| Name    | Type  | Readable| Writable| Description                                       |
3779| -------- | ------ | ---- | ---- | ------------------------------------------- |
3780| interval | number | Yes  | Yes  | Frequency at which a sensor reports data. The default value is 200,000,000 ns.|
3781
3782## RotationMatrixResponse
3783
3784Describes the response for setting the rotation matrix.
3785
3786**System capability**: SystemCapability.Sensors.Sensor
3787
3788| Name       | Type               | Readable| Writable| Description      |
3789| ----------- | ------------------- | ---- | ---- | ---------- |
3790| rotation    | Array&lt;number&gt; | Yes  | Yes  | Rotation matrix.|
3791| inclination | Array&lt;number&gt; | Yes  | Yes  | Inclination matrix.|
3792
3793
3794## CoordinatesOptions
3795
3796Describes the coordinate options.
3797
3798**System capability**: SystemCapability.Sensors.Sensor
3799
3800| Name| Type  | Readable| Writable| Description       |
3801| ---- | ------ | ---- | ---- | ----------- |
3802| x    | number | Yes  | Yes  | X coordinate direction.|
3803| y    | number | Yes  | Yes  | Y coordinate direction.|
3804
3805
3806## GeomagneticResponse
3807
3808Describes a geomagnetic response object. It extends from [Response](#response).
3809
3810**System capability**: SystemCapability.Sensors.Sensor
3811
3812| Name           | Type  | Readable| Writable| Description                                              |
3813| --------------- | ------ | ---- | ---- | -------------------------------------------------- |
3814| x               | number | Yes  | Yes  | North component of the geomagnetic field.                                  |
3815| y               | number | Yes  | Yes  | East component of the geomagnetic field.                                  |
3816| z               | number | Yes  | Yes  | Vertical component of the geomagnetic field.                                |
3817| geomagneticDip  | number | Yes  | Yes  | Magnetic dip, also called magnetic inclination, which is the angle measured from the horizontal plane to the magnetic field vector.            |
3818| deflectionAngle | number | Yes  | Yes  | Magnetic declination, which is the angle between true north (geographic north) and the magnetic north (the horizontal component of the field).|
3819| levelIntensity  | number | Yes  | Yes  | Horizontal intensity of the magnetic field vector field.                                |
3820| totalIntensity  | number | Yes  | Yes  | Total intensity of the magnetic field vector.                                  |
3821
3822## LocationOptions
3823
3824Describes the geographical location.
3825
3826**System capability**: SystemCapability.Sensors.Sensor
3827
3828| Name     | Type  | Readable| Writable| Description      |
3829| --------- | ------ | ---- | ---- | ---------- |
3830| latitude  | number | Yes  | Yes  | Latitude.    |
3831| longitude | number | Yes  | Yes  | Longitude.    |
3832| altitude  | number | Yes  | Yes  | Altitude.|
3833
3834## sensor.on<sup>(deprecated)</sup>
3835
3836### ACCELEROMETER<sup>(deprecated)</sup>
3837
3838on(type:  SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;,options?: Options): void
3839
3840Subscribes to data changes of the acceleration sensor. If this API is called multiple times for the same application, the last call takes effect.
3841
3842This API is deprecated since API version 9. You are advised to use [sensor.on.ACCELEROMETER](#accelerometer9) instead.
3843
3844**Required permissions**: ohos.permission.ACCELEROMETER
3845
3846**System capability**: SystemCapability.Sensors.Sensor
3847
3848**Parameters**
3849
3850| Name     | Type                                                         | Mandatory | Description                                                  |
3851| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
3852| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER       | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**. |
3853| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes       | Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**. |
3854| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3855
3856**Example**
3857
3858  ```js
3859  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
3860      console.info('X-coordinate component: ' + data.x);
3861      console.info('Y-coordinate component: ' + data.y);
3862      console.info('Z-coordinate component: ' + data.z);
3863  },
3864      {interval: 10000000}
3865  );
3866  ```
3867
3868### LINEAR_ACCELERATION<sup>(deprecated)</sup>
3869
3870on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;, options?: Options): void
3871
3872Subscribes to data changes of the linear acceleration sensor. If this API is called multiple times for the same application, the last call takes effect.
3873
3874This API is deprecated since API version 9. You are advised to use [sensor.on.LINEAR_ACCELEROMETER](#linear_accelerometer9) instead.
3875
3876**Required permissions**: ohos.permission.ACCELEROMETER
3877
3878**System capability**: SystemCapability.Sensors.Sensor
3879
3880**Parameters**
3881
3882| Name     | Type                                                         | Mandatory | Description                                                  |
3883| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
3884| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**. |
3885| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes       | Callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**. |
3886| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3887
3888### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
3889
3890on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;, options?: Options): void
3891
3892Subscribes to data changes of the uncalibrated acceleration sensor. If this API is called multiple times for the same application, the last call takes effect.
3893
3894This API is deprecated since API version 9. You are advised to use [sensor.on.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9) instead.
3895
3896**Required permissions**: ohos.permission.ACCELEROMETER
3897
3898**System capability**: SystemCapability.Sensors.Sensor
3899
3900**Parameters**
3901
3902| Name     | Type                                                         | Mandatory | Description                                                  |
3903| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
3904| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**. |
3905| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes       | Callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**. |
3906| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3907
3908**Example**
3909  ```js
3910  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
3911      console.info('X-coordinate component: ' + data.x);
3912      console.info('Y-coordinate component: ' + data.y);
3913      console.info('Z-coordinate component: ' + data.z);
3914      console.info('X-coordinate bias: ' + data.biasX);
3915      console.info('Y-coordinate bias: ' + data.biasY);
3916      console.info('Z-coordinate bias: ' + data.biasZ);
3917  },
3918      {interval: 10000000}
3919  );
3920  ```
3921
3922### GRAVITY<sup>(deprecated)</sup>
3923
3924on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void
3925
3926Subscribes to data changes of the gravity sensor. If this API is called multiple times for the same application, the last call takes effect.
3927
3928This API is deprecated since API version 9. You are advised to use [sensor.on.GRAVITY](#gravity9) instead.
3929
3930**System capability**: SystemCapability.Sensors.Sensor
3931
3932**Parameters**
3933
3934| Name     | Type                                                | Mandatory | Description                                                  |
3935| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ |
3936| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY    | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**. |
3937| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes       | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**. |
3938| options  | [Options](#options)                                 | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3939
3940**Example**
3941  ```js
3942  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
3943      console.info('X-coordinate component: ' + data.x);
3944      console.info('Y-coordinate component: ' + data.y);
3945      console.info('Z-coordinate component: ' + data.z);
3946  },
3947      {interval: 10000000}
3948  );
3949  ```
3950
3951### GYROSCOPE<sup>(deprecated)</sup>
3952
3953on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;, options?: Options): void
3954
3955Subscribes to data changes of the gyroscope sensor. If this API is called multiple times for the same application, the last call takes effect.
3956
3957This API is deprecated since API version 9. You are advised to use [sensor.on.GYROSCOPE](#gyroscope9) instead.
3958
3959**Required permissions**: ohos.permission.GYROSCOPE
3960
3961**System capability**: SystemCapability.Sensors.Sensor
3962
3963**Parameters**
3964
3965| Name     | Type                                                    | Mandatory | Description                                                  |
3966| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
3967| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
3968| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes       | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**. |
3969| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3970
3971**Example**
3972  ```js
3973  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
3974      console.info('X-coordinate component: ' + data.x);
3975      console.info('Y-coordinate component: ' + data.y);
3976      console.info('Z-coordinate component: ' + data.z);
3977  },
3978      {interval: 10000000}
3979  );
3980  ```
3981
3982### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
3983
3984on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;GyroscopeUncalibratedResponse&gt;, options?: Options): void
3985
3986Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is called multiple times for the same application, the last call takes effect.
3987
3988This API is deprecated since API version 9. You are advised to use [sensor.on.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9) instead.
3989
3990**Required permissions**: ohos.permission.GYROSCOPE
3991
3992**System capability**: SystemCapability.Sensors.Sensor
3993
3994**Parameters**
3995
3996| Name     | Type                                                         | Mandatory | Description                                                  |
3997| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
3998| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**. |
3999| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes       | Callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**. |
4000| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. |
4001
4002**Example**
4003  ```js
4004  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
4005      console.info('X-coordinate component: ' + data.x);
4006      console.info('Y-coordinate component: ' + data.y);
4007      console.info('Z-coordinate component: ' + data.z);
4008      console.info('X-coordinate bias: ' + data.biasX);
4009      console.info('Y-coordinate bias: ' + data.biasY);
4010      console.info('Z-coordinate bias: ' + data.biasZ);
4011  },
4012      {interval: 10000000}
4013  );
4014  ```
4015
4016### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
4017
4018on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;, options?: Options): void
4019
4020Subscribes to data changes of the significant motion sensor. If this API is called multiple times for the same application, the last call takes effect.
4021
4022This API is deprecated since API version 9. You are advised to use [sensor.on.SIGNIFICANT_MOTION](#significant_motion9) instead.
4023
4024**System capability**: SystemCapability.Sensors.Sensor
4025
4026**Parameters**
4027
4028| Name     | Type                                                         | Mandatory | Description                                                  |
4029| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4030| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION  | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**. |
4031| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes       | Callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**. |
4032| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4033
4034**Example**
4035  ```js
4036  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
4037      console.info('Scalar data: ' + data.scalar);
4038  },
4039      {interval: 10000000}
4040  );
4041  ```
4042
4043### PEDOMETER_DETECTION<sup>(deprecated)</sup>
4044
4045on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;, options?: Options): void
4046
4047Subscribes to data changes of the pedometer detection sensor. If this API is called multiple times for the same application, the last call takes effect.
4048
4049This API is deprecated since API version 9. You are advised to use [sensor.on.PEDOMETER_DETECTION](#pedometer_detection9) instead.
4050
4051**Required permissions**: ohos.permission.ACTIVITY_MOTION
4052
4053**System capability**: SystemCapability.Sensors.Sensor
4054
4055**Parameters**
4056
4057| Name     | Type                                                         | Mandatory | Description                                                  |
4058| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4059| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**. |
4060| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes       | Callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**. |
4061| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4062
4063**Example**
4064  ```js
4065  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
4066      console.info('Scalar data: ' + data.scalar);
4067  },
4068      {interval: 10000000}
4069  );
4070  ```
4071
4072### PEDOMETER<sup>(deprecated)</sup>
4073
4074on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void
4075
4076Subscribes to data changes of the pedometer sensor. If this API is called multiple times for the same application, the last call takes effect.
4077
4078This API is deprecated since API version 9. You are advised to use [sensor.on.PEDOMETER](#pedometer9) instead.
4079
4080**Required permissions**: ohos.permission.ACTIVITY_MOTION
4081
4082**System capability**: SystemCapability.Sensors.Sensor
4083
4084**Parameters**
4085
4086| Name     | Type                                                    | Mandatory | Description                                                  |
4087| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4088| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**. |
4089| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes       | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**. |
4090| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4091
4092**Example**
4093  ```js
4094  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
4095      console.info('Steps: ' + data.steps);
4096  },
4097      {interval: 10000000}
4098  );
4099  ```
4100
4101### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
4102
4103on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;AmbientTemperatureResponse&gt;,  options?: Options): void
4104
4105Subscribes to data changes of the ambient temperature sensor. If this API is called multiple times for the same application, the last call takes effect.
4106
4107This API is deprecated since API version 9. You are advised to use [sensor.on.AMBIENT_TEMPERATURE](#ambient_temperature9) instead.
4108
4109**System capability**: SystemCapability.Sensors.Sensor
4110
4111**Parameters**
4112
4113| Name     | Type                                                         | Mandatory | Description                                                  |
4114| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4115| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**. |
4116| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes       | Callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**. |
4117| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4118
4119**Example**
4120
4121  ```js
4122  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
4123      console.info('Temperature: ' + data.temperature);
4124  },
4125      {interval: 10000000}
4126  );
4127  ```
4128
4129### MAGNETIC_FIELD<sup>(deprecated)</sup>
4130
4131on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void
4132
4133Subscribes to data changes of the magnetic field sensor. If this API is called multiple times for the same application, the last call takes effect.
4134
4135This API is deprecated since API version 9. You are advised to use [sensor.on.MAGNETIC_FIELD](#magnetic_field9) instead.
4136
4137**System capability**: SystemCapability.Sensors.Sensor
4138
4139**Parameters**
4140
4141| Name     | Type                                                         | Mandatory | Description                                                  |
4142| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4143| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
4144| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes       | Callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**. |
4145| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4146
4147**Example**
4148
4149  ```js
4150  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
4151      console.info('X-coordinate component: ' + data.x);
4152      console.info('Y-coordinate component: ' + data.y);
4153      console.info('Z-coordinate component: ' + data.z);
4154  },
4155      {interval: 10000000}
4156  );
4157  ```
4158
4159### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
4160
4161on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void
4162
4163Subscribes to data changes of the uncalibrated magnetic field sensor. If this API is called multiple times for the same application, the last call takes effect.
4164
4165This API is deprecated since API version 9. You are advised to use [sensor.on.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9) instead.
4166
4167**System capability**: SystemCapability.Sensors.Sensor
4168
4169**Parameters**
4170
4171| Name     | Type                                                         | Mandatory | Description                                                  |
4172| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4173| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**. |
4174| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes       | Callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**. |
4175| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4176
4177**Example**
4178  ```js
4179  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
4180      console.info('X-coordinate component: ' + data.x);
4181      console.info('Y-coordinate component: ' + data.y);
4182      console.info('Z-coordinate component: ' + data.z);
4183      console.info('X-coordinate bias: ' + data.biasX);
4184      console.info('Y-coordinate bias: ' + data.biasY);
4185      console.info('Z-coordinate bias: ' + data.biasZ);
4186  },
4187      {interval: 10000000}
4188  );
4189  ```
4190
4191### PROXIMITY<sup>(deprecated)</sup>
4192
4193on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;,options?: Options): void
4194
4195Subscribes to data changes of the proximity sensor. If this API is called multiple times for the same application, the last call takes effect.
4196
4197This API is deprecated since API version 9. You are advised to use [sensor.on.PROXIMITY](#proximity9) instead.
4198
4199**System capability**: SystemCapability.Sensors.Sensor
4200
4201**Parameters**
4202
4203| Name     | Type                                                    | Mandatory | Description                                                  |
4204| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4205| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**. |
4206| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes       | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**. |
4207| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4208
4209**Example**
4210  ```js
4211  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
4212      console.info('Distance: ' + data.distance);
4213  },
4214      {interval: 10000000}
4215  );
4216  ```
4217
4218### HUMIDITY<sup>(deprecated)</sup>
4219
4220on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void
4221
4222Subscribes to data changes of the humidity sensor. If this API is called multiple times for the same application, the last call takes effect.
4223
4224This API is deprecated since API version 9. You are advised to use [sensor.on.HUMIDITY](#humidity9) instead.
4225
4226**System capability**: SystemCapability.Sensors.Sensor
4227
4228**Parameters**
4229
4230| Name     | Type                                                  | Mandatory | Description                                                  |
4231| -------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
4232| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**. |
4233| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes       | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**. |
4234| options  | [Options](#options)                                   | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4235
4236**Example**
4237
4238  ```js
4239  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
4240      console.info('Humidity: ' + data.humidity);
4241  },
4242      {interval: 10000000}
4243  );
4244  ```
4245
4246### BAROMETER<sup>(deprecated)</sup>
4247
4248on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;,options?: Options): void
4249
4250Subscribes to data changes of the barometer sensor. If this API is called multiple times for the same application, the last call takes effect.
4251
4252This API is deprecated since API version 9. You are advised to use [sensor.on.BAROMETER](#barometer9) instead.
4253
4254**System capability**: SystemCapability.Sensors.Sensor
4255
4256**Parameters**
4257
4258| Name     | Type                                                    | Mandatory | Description                                                  |
4259| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4260| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**. |
4261| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes       | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**. |
4262| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4263
4264**Example**
4265
4266  ```js
4267  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
4268      console.info('Atmospheric pressure: ' + data.pressure);
4269  },
4270      {interval: 10000000}
4271  );
4272  ```
4273
4274### HALL<sup>(deprecated)</sup>
4275
4276on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void
4277
4278Subscribes to data changes of the Hall effect sensor. If this API is called multiple times for the same application, the last call takes effect.
4279
4280This API is deprecated since API version 9. You are advised to use [sensor.on.HALL](#hall9) instead.
4281
4282**System capability**: SystemCapability.Sensors.Sensor
4283
4284**Parameters**
4285
4286| Name     | Type                                          | Mandatory | Description                                                  |
4287| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
4288| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**. |
4289| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes       | Callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**. |
4290| options  | [Options](#options)                           | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4291
4292**Example**
4293  ```js
4294  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
4295      console.info('Status: ' + data.status);
4296  },
4297      {interval: 10000000}
4298  );
4299  ```
4300
4301### AMBIENT_LIGHT<sup>(deprecated)</sup>
4302
4303on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void
4304
4305Subscribes to data changes of the ambient light sensor. If this API is called multiple times for the same application, the last call takes effect.
4306
4307This API is deprecated since API version 9. You are advised to use [sensor.on.AMBIENT_LIGHT](#ambient_light9) instead.
4308
4309**System capability**: SystemCapability.Sensors.Sensor
4310
4311**Parameters**
4312
4313| Name     | Type                                                   | Mandatory | Description                                                  |
4314| -------- | ------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4315| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**. |
4316| callback | Callback&lt;[LightResponse](#lightresponse)&gt;        | Yes       | Callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**. |
4317| options  | [Options](#options)                                    | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4318
4319**Example**
4320
4321  ```js
4322  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
4323      console.info(' Illumination: ' + data.intensity);
4324  },
4325      {interval: 10000000}
4326  );
4327  ```
4328
4329### ORIENTATION<sup>(deprecated)</sup>
4330
4331on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;, options?: Options): void
4332
4333Subscribes to data changes of the orientation sensor. If this API is called multiple times for the same application, the last call takes effect.
4334
4335This API is deprecated since API version 9. You are advised to use [sensor.on.ORIENTATION](#orientation9) instead.
4336
4337**System capability**: SystemCapability.Sensors.Sensor
4338
4339**Parameters**
4340
4341| Name     | Type                                                        | Mandatory | Description                                                  |
4342| -------- | ----------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4343| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION        | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**. |
4344| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes       | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**. |
4345| options  | [Options](#options)                                         | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4346
4347**Example**
4348  ```js
4349  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
4350      console.info('The device rotates at an angle around the X axis: ' + data.beta);
4351      console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
4352      console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
4353  },
4354      {interval: 10000000}
4355  );
4356  ```
4357
4358### HEART_RATE<sup>(deprecated)</sup>
4359
4360on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;, options?: Options): void
4361
4362Subscribes to only one data change of the heart rate sensor.
4363
4364This API is deprecated since API version 9. You are advised to use [sensor.on.HEART_RATE](#heart_rate9) instead.
4365
4366**Required permissions**: ohos.permission.HEALTH_DATA
4367
4368**System capability**: SystemCapability.Sensors.Sensor
4369
4370**Parameters**
4371
4372| Name     | Type                                                    | Mandatory | Description                                                  |
4373| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4374| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. |
4375| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes       | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**. |
4376
4377### ROTATION_VECTOR<sup>(deprecated)</sup>
4378
4379on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;RotationVectorResponse&gt;,options?: Options): void
4380
4381Subscribes to data changes of the rotation vector sensor. If this API is called multiple times for the same application, the last call takes effect.
4382
4383This API is deprecated since API version 9. You are advised to use [sensor.on.ROTATION_VECTOR](#rotation_vector9) instead.
4384
4385**System capability**: SystemCapability.Sensors.Sensor
4386
4387**Parameters**
4388
4389| Name     | Type                                                         | Mandatory | Description                                                  |
4390| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4391| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**. |
4392| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes       | Callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**. |
4393| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4394
4395**Example**
4396  ```js
4397  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
4398      console.info('X-coordinate component: ' + data.x);
4399      console.info('Y-coordinate component: ' + data.y);
4400      console.info('Z-coordinate component: ' + data.z);
4401      console.info('Scalar quantity: ' + data.w);
4402  },
4403      {interval: 10000000}
4404  );
4405  ```
4406
4407### WEAR_DETECTION<sup>(deprecated)</sup>
4408
4409on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,options?: Options): void
4410
4411Subscribes to data changes of the wear detection sensor. If this API is called multiple times for the same application, the last call takes effect.
4412
4413This API is deprecated since API version 9. You are advised to use [sensor.on.WEAR_DETECTION](#wear_detection9) instead.
4414
4415**System capability**: SystemCapability.Sensors.Sensor
4416
4417**Parameters**
4418
4419| Name     | Type                                                         | Mandatory | Description                                                  |
4420| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4421| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**. |
4422| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes       | Callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**. |
4423| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4424
4425**Example**
4426  ```js
4427  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
4428      console.info('Wear status: ' + data.value);
4429  },
4430      {interval: 10000000}
4431  );
4432  ```
4433
4434## sensor.once<sup>(deprecated)</sup>
4435
4436### ACCELEROMETER<sup>(deprecated)</sup>
4437
4438once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void
4439
4440Subscribes to only one data change of the acceleration sensor.
4441
4442This API is deprecated since API version 9. You are advised to use [sensor.once.ACCELEROMETER](#accelerometer9-1) instead.
4443
4444**Required permissions**: ohos.permission.ACCELEROMETER
4445
4446**System capability**: SystemCapability.Sensors.Sensor
4447
4448**Parameters**
4449
4450| Name     | Type                                                         | Mandatory | Description                                                  |
4451| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4452| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER       | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**. |
4453| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes       | One-shot callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**. |
4454
4455**Example**
4456  ```js
4457  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
4458      console.info('X-coordinate component: ' + data.x);
4459      console.info('Y-coordinate component: ' + data.y);
4460      console.info('Z-coordinate component: ' + data.z);
4461    }
4462  );
4463  ```
4464
4465### LINEAR_ACCELERATION<sup>(deprecated)</sup>
4466
4467once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;): void
4468
4469Subscribes to only one data change of the linear acceleration sensor.
4470
4471This API is deprecated since API version 9. You are advised to use [sensor.once.LINEAR_ACCELEROMETER](#linear_accelerometer9-1) instead.
4472
4473**Required permissions**: ohos.permission.ACCELERATION
4474
4475**System capability**: SystemCapability.Sensors.Sensor
4476
4477**Parameters**
4478
4479| Name     | Type                                                         | Mandatory | Description                                                  |
4480| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4481| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**. |
4482| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes       | One-shot callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**. |
4483
4484### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
4485
4486once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
4487
4488Subscribes to only one data change of the uncalibrated acceleration sensor.
4489
4490This API is deprecated since API version 9. You are advised to use [sensor.once.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-1) instead.
4491
4492**Required permissions**: ohos.permission.ACCELEROMETER
4493
4494**System capability**: SystemCapability.Sensors.Sensor
4495
4496**Parameters**
4497
4498| Name     | Type                                                         | Mandatory | Description                                                  |
4499| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4500| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**. |
4501| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes       | One-shot callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**. |
4502
4503**Example**
4504  ```
4505  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) {
4506      console.info('X-coordinate component: ' + data.x);
4507      console.info('Y-coordinate component: ' + data.y);
4508      console.info('Z-coordinate component: ' + data.z);
4509      console.info('X-coordinate bias: ' + data.biasX);
4510      console.info('Y-coordinate bias: ' + data.biasY);
4511      console.info('Z-coordinate bias: ' + data.biasZ);
4512    }
4513  );
4514  ```
4515
4516### GRAVITY<sup>(deprecated)</sup>
4517
4518once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;): void
4519
4520Subscribes to only one data change of the gravity sensor.
4521
4522This API is deprecated since API version 9. You are advised to use [sensor.once.GRAVITY](#gravity9-1) instead.
4523
4524**System capability**: SystemCapability.Sensors.Sensor
4525
4526**Parameters**
4527
4528| Name     | Type                                                | Mandatory | Description                                                  |
4529| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ |
4530| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY    | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**. |
4531| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes       | One-shot callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**. |
4532
4533**Example**
4534  ```js
4535  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
4536      console.info('X-coordinate component: ' + data.x);
4537      console.info('Y-coordinate component: ' + data.y);
4538      console.info('Z-coordinate component: ' + data.z);
4539    }
4540  );
4541  ```
4542
4543### GYROSCOPE<sup>(deprecated)</sup>
4544
4545once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void
4546
4547Subscribes to only one data change of the gyroscope sensor.
4548
4549This API is deprecated since API version 9. You are advised to use [sensor.once.GYROSCOPE](#gyroscope9-1) instead.
4550
4551**Required permissions**: ohos.permission.GYROSCOPE
4552
4553**System capability**: SystemCapability.Sensors.Sensor
4554
4555**Parameters**
4556
4557| Name     | Type                                                    | Mandatory | Description                                                  |
4558| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4559| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
4560| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes       | One-shot callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**. |
4561
4562**Example**
4563  ```js
4564  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
4565      console.info('X-coordinate component: ' + data.x);
4566      console.info('Y-coordinate component: ' + data.y);
4567      console.info('Z-coordinate component: ' + data.z);
4568    }
4569  );
4570  ```
4571
4572### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
4573
4574once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
4575
4576Subscribes to only one data change of the uncalibrated gyroscope sensor.
4577
4578This API is deprecated since API version 9. You are advised to use [sensor.once.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-1) instead.
4579
4580**Required permissions**: ohos.permission.GYROSCOPE
4581
4582**System capability**: SystemCapability.Sensors.Sensor
4583
4584**Parameters**
4585
4586| Name     | Type                                                         | Mandatory | Description                                                  |
4587| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4588| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**. |
4589| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes       | One-shot callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**. |
4590
4591**Example**
4592  ```js
4593  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
4594      console.info('X-coordinate component: ' + data.x);
4595      console.info('Y-coordinate component: ' + data.y);
4596      console.info('Z-coordinate component: ' + data.z);
4597      console.info('X-coordinate bias: ' + data.biasX);
4598      console.info('Y-coordinate bias: ' + data.biasY);
4599      console.info('Z-coordinate bias: ' + data.biasZ);
4600    }
4601  );
4602  ```
4603
4604### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
4605
4606once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;SignificantMotionResponse&gt;): void
4607
4608Subscribes to only one data change of the significant motion sensor.
4609
4610This API is deprecated since API version 9. You are advised to use [sensor.once.SIGNIFICANT_MOTION](#significant_motion9-1) instead.
4611
4612**System capability**: SystemCapability.Sensors.Sensor
4613
4614**Parameters**
4615
4616| Name     | Type                                                         | Mandatory | Description                                                  |
4617| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4618| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION  | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**. |
4619| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes       | One-shot callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**. |
4620
4621**Example**
4622  ```js
4623  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
4624      console.info('Scalar data: ' + data.scalar);
4625    }
4626  );
4627  ```
4628
4629### PEDOMETER_DETECTION<sup>(deprecated)</sup>
4630
4631once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;PedometerDetectionResponse&gt;): void
4632
4633Subscribes to only one data change of the pedometer detection sensor.
4634
4635This API is deprecated since API version 9. You are advised to use [sensor.once.PEDOMETER_DETECTION](#pedometer_detection9-1) instead.
4636
4637**Required permissions**: ohos.permission.ACTIVITY_MOTION
4638
4639**System capability**: SystemCapability.Sensors.Sensor
4640
4641**Parameters**
4642
4643| Name     | Type                                                         | Mandatory | Description                                                  |
4644| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4645| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**. |
4646| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes       | One-shot callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**. |
4647
4648**Example**
4649  ```js
4650  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
4651      console.info('Scalar data: ' + data.scalar);
4652    }
4653  );
4654  ```
4655
4656### PEDOMETER<sup>(deprecated)</sup>
4657
4658once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void
4659
4660Subscribes to only one data change of the pedometer sensor.
4661
4662This API is deprecated since API version 9. You are advised to use [sensor.once.PEDOMETER](#pedometer9-1) instead.
4663
4664**Required permissions**: ohos.permission.ACTIVITY_MOTION
4665
4666**System capability**: SystemCapability.Sensors.Sensor
4667
4668**Parameters**
4669
4670| Name     | Type                                                    | Mandatory | Description                                                  |
4671| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4672| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**. |
4673| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes       | One-shot callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**. |
4674
4675**Example**
4676  ```js
4677  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
4678      console.info('Steps: ' + data.steps);
4679    }
4680  );
4681  ```
4682
4683### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
4684
4685once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;AmbientTemperatureResponse&gt;): void
4686
4687Subscribes to only one data change of the ambient temperature sensor.
4688
4689This API is deprecated since API version 9. You are advised to use [sensor.once.AMBIENT_TEMPERATURE](#ambient_temperature9-1) instead.
4690
4691**System capability**: SystemCapability.Sensors.Sensor
4692
4693**Parameters**
4694
4695| Name     | Type                                                         | Mandatory | Description                                                  |
4696| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4697| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**. |
4698| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes       | One-shot callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**. |
4699
4700**Example**
4701  ```js
4702  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
4703      console.info('Temperature: ' + data.temperature);
4704    }
4705  );
4706  ```
4707
4708### MAGNETIC_FIELD<sup>(deprecated)</sup>
4709
4710once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void
4711
4712Subscribes to only one data change of the magnetic field sensor.
4713
4714This API is deprecated since API version 9. You are advised to use [sensor.once.MAGNETIC_FIELD](#magnetic_field9-1) instead.
4715
4716**System capability**: SystemCapability.Sensors.Sensor
4717
4718**Parameters**
4719
4720| Name     | Type                                                         | Mandatory | Description                                                  |
4721| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4722| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
4723| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes       | One-shot callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**. |
4724
4725**Example**
4726  ```js
4727  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
4728      console.info('X-coordinate component: ' + data.x);
4729      console.info('Y-coordinate component: ' + data.y);
4730      console.info('Z-coordinate component: ' + data.z);
4731    }
4732  );
4733  ```
4734
4735### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
4736
4737once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
4738
4739Subscribes to only one data change of the uncalibrated magnetic field sensor.
4740
4741This API is deprecated since API version 9. You are advised to use [sensor.once.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-1) instead.
4742
4743**System capability**: SystemCapability.Sensors.Sensor
4744
4745**Parameters**
4746
4747| Name     | Type                                                         | Mandatory | Description                                                  |
4748| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4749| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**. |
4750| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes       | One-shot callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**. |
4751
4752**Example**
4753  ```js
4754  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
4755      console.info('X-coordinate component: ' + data.x);
4756      console.info('Y-coordinate component: ' + data.y);
4757      console.info('Z-coordinate component: ' + data.z);
4758      console.info('X-coordinate bias: ' + data.biasX);
4759      console.info('Y-coordinate bias: ' + data.biasY);
4760      console.info('Z-coordinate bias: ' + data.biasZ);
4761    }
4762  );
4763  ```
4764
4765### PROXIMITY<sup>(deprecated)</sup>
4766
4767once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void
4768
4769Subscribes to only one data change of the proximity sensor.
4770
4771This API is deprecated since API version 9. You are advised to use [sensor.once.PROXIMITY](#proximity9-1) instead.
4772
4773**System capability**: SystemCapability.Sensors.Sensor
4774
4775**Parameters**
4776
4777| Name     | Type                                                    | Mandatory | Description                                                  |
4778| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4779| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**. |
4780| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes       | One-shot callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**. |
4781
4782**Example**
4783  ```js
4784  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) {
4785      console.info('Distance: ' + data.distance);
4786    }
4787  );
4788  ```
4789
4790### HUMIDITY<sup>(deprecated)</sup>
4791
4792once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void
4793
4794Subscribes to only one data change of the humidity sensor.
4795
4796This API is deprecated since API version 9. You are advised to use [sensor.once.HUMIDITY](#humidity9-1) instead.
4797
4798**System capability**: SystemCapability.Sensors.Sensor
4799
4800**Parameters**
4801
4802| Name     | Type                                                  | Mandatory | Description                                                  |
4803| -------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
4804| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**. |
4805| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes       | One-shot callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**. |
4806
4807**Example**
4808  ```js
4809  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
4810      console.info('Humidity: ' + data.humidity);
4811    }
4812  );
4813  ```
4814
4815### BAROMETER<sup>(deprecated)</sup>
4816
4817once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void
4818
4819Subscribes to only one data change of the barometer sensor.
4820
4821This API is deprecated since API version 9. You are advised to use [sensor.once.BAROMETER](#barometer9-1) instead.
4822
4823**System capability**: SystemCapability.Sensors.Sensor
4824
4825**Parameters**
4826
4827| Name     | Type                                                    | Mandatory | Description                                                  |
4828| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4829| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**. |
4830| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes       | One-shot callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**. |
4831
4832**Example**
4833  ```js
4834  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
4835      console.info('Atmospheric pressure: ' + data.pressure);
4836    }
4837  );
4838  ```
4839
4840### HALL<sup>(deprecated)</sup>
4841
4842once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;): void
4843
4844Subscribes to only one data change of the Hall effect sensor.
4845
4846This API is deprecated since API version 9. You are advised to use [sensor.once.HALL](#hall9-1) instead.
4847
4848**System capability**: SystemCapability.Sensors.Sensor
4849
4850**Parameters**
4851
4852| Name     | Type                                          | Mandatory | Description                                                  |
4853| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
4854| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**. |
4855| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes       | One-shot callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**. |
4856
4857**Example**
4858  ```js
4859  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
4860      console.info('Status: ' + data.status);
4861    }
4862  );
4863  ```
4864
4865### AMBIENT_LIGHT<sup>(deprecated)</sup>
4866
4867once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void
4868
4869Subscribes to only one data change of the ambient light sensor.
4870
4871This API is deprecated since API version 9. You are advised to use [sensor.once.AMBIENT_LIGHT](#ambient_light9-1) instead.
4872
4873**System capability**: SystemCapability.Sensors.Sensor
4874
4875**Parameters**
4876
4877| Name     | Type                                                   | Mandatory | Description                                                  |
4878| -------- | ------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4879| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**. |
4880| callback | Callback&lt;[LightResponse](#lightresponse)&gt;        | Yes       | One-shot callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**. |
4881
4882**Example**
4883
4884  ```js
4885  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
4886      console.info(' Illumination: ' + data.intensity);
4887    }
4888  );
4889  ```
4890
4891### ORIENTATION<sup>(deprecated)</sup>
4892
4893once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void
4894
4895Subscribes to only one data change of the orientation sensor.
4896
4897This API is deprecated since API version 9. You are advised to use [sensor.once.ORIENTATION](#orientation9-1) instead.
4898
4899**System capability**: SystemCapability.Sensors.Sensor
4900
4901**Parameters**
4902
4903| Name     | Type                                                        | Mandatory | Description                                                  |
4904| -------- | ----------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4905| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION        | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**. |
4906| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes       | One-shot callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**. |
4907
4908**Example**
4909  ```js
4910  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
4911      console.info('The device rotates at an angle around the X axis: ' + data.beta);
4912      console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
4913      console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
4914    }
4915  );
4916  ```
4917
4918### ROTATION_VECTOR<sup>(deprecated)</sup>
4919
4920once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void
4921
4922Subscribes to only one data change of the rotation vector sensor.
4923
4924This API is deprecated since API version 9. You are advised to use [sensor.once.ROTATION_VECTOR](#rotation_vector9-1) instead.
4925
4926**System capability**: SystemCapability.Sensors.Sensor
4927
4928**Parameters**
4929
4930| Name     | Type                                                         | Mandatory | Description                                                  |
4931| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4932| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**. |
4933| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes       | One-shot callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**. |
4934
4935**Example**
4936  ```js
4937  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
4938      console.info('X-coordinate component: ' + data.x);
4939      console.info('Y-coordinate component: ' + data.y);
4940      console.info('Z-coordinate component: ' + data.z);
4941      console.info('Scalar quantity: ' + data.w);
4942    }
4943  );
4944  ```
4945
4946### HEART_RATE<sup>(deprecated)</sup>
4947
4948once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void
4949
4950Subscribes to only one data change of the heart rate sensor.
4951
4952This API is deprecated since API version 9. You are advised to use [sensor.once.HEART_RATE](#heart_rate9-1) instead.
4953
4954**Required permissions**: ohos.permission.HEART_RATE
4955
4956**System capability**: SystemCapability.Sensors.Sensor
4957
4958**Parameters**
4959
4960| Name     | Type                                                    | Mandatory | Description                                                  |
4961| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4962| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. |
4963| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes       | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**. |
4964
4965### WEAR_DETECTION<sup>(deprecated)</sup>
4966
4967once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void
4968
4969Subscribes to only one data change of the wear detection sensor.
4970
4971This API is deprecated since API version 9. You are advised to use [sensor.once.WEAR_DETECTION](#wear_detection9-1) instead.
4972
4973**System capability**: SystemCapability.Sensors.Sensor
4974
4975**Parameters**
4976
4977| Name     | Type                                                         | Mandatory | Description                                                  |
4978| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4979| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**. |
4980| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes       | One-shot callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**. |
4981
4982**Example**
4983  ```js
4984  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
4985      console.info("Wear status: "+ data.value);
4986    }
4987  );
4988  ```
4989
4990## sensor.off<sup>(deprecated)</sup>
4991
4992### ACCELEROMETER<sup>(deprecated)</sup>
4993
4994off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void
4995
4996Unsubscribes from sensor data changes.
4997
4998This API is deprecated since API version 9. You are advised to use [sensor.off.ACCELEROMETER](#accelerometer9-2) instead.
4999
5000**Required permissions**: ohos.permission.ACCELEROMETER
5001
5002**System capability**: SystemCapability.Sensors.Sensor
5003
5004**Parameters**
5005
5006| Name     | Type                                                         | Mandatory | Description                                                  |
5007| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5008| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER       | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER**. |
5009| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | No        | Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**. |
5010
5011**Example**
5012
5013```js
5014function callback(data) {
5015    console.info('x-coordinate component: ' + data.x);
5016    console.info('Y-coordinate component: ' + data.y);
5017    console.info('Z-coordinate component: ' + data.z);
5018}
5019sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
5020```
5021
5022### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
5023
5024off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
5025
5026Unsubscribes from sensor data changes.
5027
5028This API is deprecated since API version 9. You are advised to use [sensor.off.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-2) instead.
5029
5030**Required permissions**: ohos.permission.ACCELEROMETER
5031
5032**System capability**: SystemCapability.Sensors.Sensor
5033
5034**Parameters**
5035
5036| Name     | Type                                                         | Mandatory | Description                                                  |
5037| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5038| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**. |
5039| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | No        | Callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**. |
5040
5041**Example**
5042
5043```js
5044function callback(data) {
5045    console.info('X-coordinate component: ' + data.x);
5046    console.info('Y-coordinate component: ' + data.y);
5047    console.info('Z-coordinate component: ' + data.z);
5048    console.info('X-coordinate bias: ' + data.biasX);
5049    console.info('Y-coordinate bias: ' + data.biasY);
5050    console.info('Z-coordinate bias: ' + data.biasZ);
5051}
5052sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback);
5053```
5054
5055### AMBIENT_LIGHT<sup>(deprecated)</sup>
5056
5057off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void
5058
5059Unsubscribes from sensor data changes.
5060
5061This API is deprecated since API version 9. You are advised to use [sensor.off.AMBIENT_LIGHT](#ambient_light9-2) instead.
5062
5063**System capability**: SystemCapability.Sensors.Sensor
5064
5065**Parameters**
5066
5067| Name     | Type                                                   | Mandatory | Description                                                  |
5068| -------- | ------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5069| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**. |
5070| callback | Callback&lt;[LightResponse](#lightresponse)&gt;        | No        | Callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**. |
5071
5072**Example**
5073
5074```js
5075function callback(data) {
5076    console.info(' Illumination: ' + data.intensity);
5077}
5078sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
5079```
5080
5081### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
5082
5083off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void
5084
5085Unsubscribes from sensor data changes.
5086
5087This API is deprecated since API version 9. You are advised to use [sensor.off.AMBIENT_TEMPERATURE](#ambient_temperature9-2) instead.
5088
5089**System capability**: SystemCapability.Sensors.Sensor
5090
5091**Parameters**
5092
5093| Name     | Type                                                         | Mandatory | Description                                                  |
5094| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5095| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**. |
5096| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | No        | Callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**. |
5097
5098**Example**
5099
5100```js
5101function callback(data) {
5102     console.info('Temperature: ' + data.temperature);
5103}
5104sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
5105```
5106
5107### BAROMETER<sup>(deprecated)</sup>
5108
5109off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void
5110
5111Unsubscribes from sensor data changes.
5112
5113This API is deprecated since API version 9. You are advised to use [sensor.off.BAROMETER](#barometer9-2) instead.
5114
5115**System capability**: SystemCapability.Sensors.Sensor
5116
5117**Parameters**
5118
5119| Name     | Type                                                    | Mandatory | Description                                                  |
5120| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5121| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_BAROMETER**. |
5122| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | No        | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**. |
5123
5124**Example**
5125
5126```js
5127function callback(data) {
5128     console.info('Atmospheric pressure: ' + data.pressure);
5129}
5130sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
5131```
5132
5133### GRAVITY<sup>(deprecated)</sup>
5134
5135off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
5136
5137Unsubscribes from sensor data changes.
5138
5139This API is deprecated since API version 9. You are advised to use [sensor.off.GRAVITY](#gravity9-2) instead.
5140
5141**System capability**: SystemCapability.Sensors.Sensor
5142
5143**Parameters**
5144
5145| Name     | Type                                                | Mandatory | Description                                                  |
5146| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ |
5147| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY    | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GRAVITY**. |
5148| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | No        | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**. |
5149
5150**Example**
5151
5152```js
5153function callback(data) {
5154    console.info('X-coordinate component: ' + data.x);
5155    console.info('Y-coordinate component: ' + data.y);
5156    console.info('Z-coordinate component: ' + data.z);
5157}
5158sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
5159```
5160
5161### GYROSCOPE<sup>(deprecated)</sup>
5162
5163off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void
5164
5165Unsubscribes from sensor data changes.
5166
5167This API is deprecated since API version 9. You are advised to use [sensor.off.GYROSCOPE](#gyroscope9-2) instead.
5168
5169**Required permissions**: ohos.permission.GYROSCOPE
5170
5171**System capability**: SystemCapability.Sensors.Sensor
5172
5173**Parameters**
5174
5175| Name     | Type                                                    | Mandatory | Description                                                  |
5176| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5177| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
5178| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | No        | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**. |
5179
5180**Example**
5181
5182```js
5183function callback(data) {
5184    console.info('X-coordinate component: ' + data.x);
5185    console.info('Y-coordinate component: ' + data.y);
5186    console.info('Z-coordinate component: ' + data.z);
5187}
5188sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
5189```
5190
5191### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
5192
5193off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
5194
5195Unsubscribes from sensor data changes.
5196
5197This API is deprecated since API version 9. You are advised to use [sensor.off.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-2) instead.
5198
5199**Required permissions**: ohos.permission.GYROSCOPE
5200
5201**System capability**: SystemCapability.Sensors.Sensor
5202
5203**Parameters**
5204
5205| Name     | Type                                                         | Mandatory | Description                                                  |
5206| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5207| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**. |
5208| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | No        | Callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**. |
5209
5210**Example**
5211
5212```js
5213function callback(data) {
5214    console.info('X-coordinate component: ' + data.x);
5215    console.info('Y-coordinate component: ' + data.y);
5216    console.info('Z-coordinate component: ' + data.z);
5217}
5218sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback);
5219```
5220
5221### HALL<sup>(deprecated)</sup>
5222
5223off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt;): void
5224
5225Unsubscribes from sensor data changes.
5226
5227This API is deprecated since API version 9. You are advised to use [sensor.off.HALL](#hall9-2) instead.
5228
5229**System capability**: SystemCapability.Sensors.Sensor
5230
5231**Parameters**
5232
5233| Name     | Type                                          | Mandatory | Description                                                  |
5234| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
5235| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HALL**. |
5236| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | No        | Callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**. |
5237
5238**Example**
5239
5240```js
5241function callback(data) {
5242    console.info('Status: ' + data.status);
5243}
5244sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
5245```
5246
5247### HEART_RATE<sup>(deprecated)</sup>
5248
5249off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void
5250
5251Unsubscribes from sensor data changes.
5252
5253This API is deprecated since API version 9. You are advised to use [sensor.off.HEART_RATE](#heart_rate9-2) instead.
5254
5255**Required permissions**: ohos.permission.HEALTH_DATA
5256
5257**System capability**: SystemCapability.Sensors.Sensor
5258
5259**Parameters**
5260
5261| Name     | Type                                                    | Mandatory | Description                                                  |
5262| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5263| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE     | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HEART_RATE**. |
5264| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | No        | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**. |
5265
5266### HUMIDITY<sup>(deprecated)</sup>
5267
5268off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
5269
5270Unsubscribes from sensor data changes.
5271
5272This API is deprecated since API version 9. You are advised to use [sensor.off.HUMIDITY](#humidity9-2) instead.
5273
5274**System capability**: SystemCapability.Sensors.Sensor
5275
5276**Parameters**
5277
5278| Name     | Type                                                  | Mandatory | Description                                                  |
5279| -------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
5280| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY     | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HUMIDITY**. |
5281| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | No        | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**. |
5282
5283**Example**
5284
5285```js
5286function callback(data) {
5287    console.info('Humidity: ' + data.humidity);
5288}
5289sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
5290```
5291
5292### LINEAR_ACCELERATION<sup>(deprecated)</sup>
5293
5294off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void
5295
5296Unsubscribes from sensor data changes.
5297
5298This API is deprecated since API version 9. You are advised to use [sensor.off.LINEAR_ACCELEROMETER](#linear_accelerometer9-2) instead.
5299
5300**Required permissions**: ohos.permission.ACCELEROMETER
5301
5302**System capability**: SystemCapability.Sensors.Sensor
5303
5304**Parameters**
5305
5306| Name     | Type                                                         | Mandatory | Description                                                  |
5307| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5308| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**. |
5309| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | No        | Callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**. |
5310
5311### MAGNETIC_FIELD<sup>(deprecated)</sup>
5312
5313 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void
5314
5315Unsubscribes from sensor data changes.
5316
5317This API is deprecated since API version 9. You are advised to use [sensor.off.MAGNETIC_FIELD](#magnetic_field9-2) instead.
5318
5319**System capability**: SystemCapability.Sensors.Sensor
5320
5321**Parameters**
5322
5323| Name             | Type                                                         | Mandatory | Description                                                  |
5324| ---------------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5325| type             | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
5326| callbackcallback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | No        | Callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**. |
5327
5328**Example**
5329
5330```js
5331function callback(data) {
5332    console.info('X-coordinate component: ' + data.x);
5333    console.info('Y-coordinate component: ' + data.y);
5334    console.info('Z-coordinate component: ' + data.z);
5335}
5336sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
5337```
5338
5339### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
5340
5341 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
5342
5343Unsubscribes from sensor data changes.
5344
5345This API is deprecated since API version 9. You are advised to use [sensor.off.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-2) instead.
5346
5347**System capability**: SystemCapability.Sensors.Sensor
5348
5349**Parameters**
5350
5351| Name     | Type                                                         | Mandatory | Description                                                  |
5352| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5353| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**. |
5354| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | No        | Callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**. |
5355
5356**Example**
5357
5358```js
5359function callback(data) {
5360    console.info('X-coordinate component: ' + data.x);
5361    console.info('Y-coordinate component: ' + data.y);
5362    console.info('Z-coordinate component: ' + data.z);
5363    console.info('X-coordinate bias: ' + data.biasX);
5364    console.info('Y-coordinate bias: ' + data.biasY);
5365    console.info('Z-coordinate bias: ' + data.biasZ);
5366}
5367sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback);
5368```
5369
5370### ORIENTATION<sup>(deprecated)</sup>
5371
5372 off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void
5373
5374Unsubscribes from sensor data changes.
5375
5376This API is deprecated since API version 9. You are advised to use [sensor.off.ORIENTATION](#orientation9-2) instead.
5377
5378**System capability**: SystemCapability.Sensors.Sensor
5379
5380**Parameters**
5381
5382| Name     | Type                                                        | Mandatory | Description                                                  |
5383| -------- | ----------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5384| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION        | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ORIENTATION**. |
5385| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | No        | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**. |
5386
5387**Example**
5388
5389```js
5390function callback(data) {
5391    console.info('The device rotates at an angle around the X axis: ' + data.beta);
5392    console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
5393    console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
5394}
5395sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
5396```
5397
5398### PEDOMETER<sup>(deprecated)</sup>
5399
5400off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void
5401
5402Unsubscribes from sensor data changes.
5403
5404This API is deprecated since API version 9. You are advised to use [sensor.off.PEDOMETER](#pedometer9-2) instead.
5405
5406**Required permissions**: ohos.permission.ACTIVITY_MOTION
5407
5408**System capability**: SystemCapability.Sensors.Sensor
5409
5410**Parameters**
5411
5412| Name     | Type                                                    | Mandatory | Description                                                  |
5413| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5414| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. |
5415| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | No        | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**. |
5416
5417**Example**
5418
5419```js
5420function callback(data) {
5421    console.info('Steps: ' + data.steps);
5422}
5423sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
5424```
5425
5426### PEDOMETER_DETECTION<sup>(deprecated)</sup>
5427
5428off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void
5429
5430Unsubscribes from sensor data changes.
5431
5432This API is deprecated since API version 9. You are advised to use [sensor.off.PEDOMETER_DETECTION](#pedometer_detection9-2) instead.
5433
5434**Required permissions**: ohos.permission.ACTIVITY_MOTION
5435
5436**System capability**: SystemCapability.Sensors.Sensor
5437
5438**Parameters**
5439
5440| Name     | Type                                                         | Mandatory | Description                                                  |
5441| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5442| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**. |
5443| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | No        | Callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**. |
5444
5445**Example**
5446
5447```js
5448function callback(data) {
5449    console.info('Scalar data: ' + data.scalar);
5450}
5451sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
5452```
5453
5454### PROXIMITY<sup>(deprecated)</sup>
5455
5456off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void
5457
5458Unsubscribes from sensor data changes.
5459
5460This API is deprecated since API version 9. You are advised to use [sensor.off.PROXIMITY](#proximity9-2) instead.
5461
5462**System capability**: SystemCapability.Sensors.Sensor
5463
5464**Parameters**
5465
5466| Name     | Type                                                    | Mandatory | Description                                                  |
5467| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5468| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PROXIMITY**. |
5469| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | No        | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**. |
5470
5471**Example**
5472
5473```js
5474function callback(data) {
5475    console.info('Distance: ' + data.distance);
5476}
5477sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
5478```
5479
5480### ROTATION_VECTOR<sup>(deprecated)</sup>
5481
5482off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void
5483
5484Unsubscribes from sensor data changes.
5485
5486This API is deprecated since API version 9. You are advised to use [sensor.off.ROTATION_VECTOR](#rotation_vector9-2) instead.
5487
5488**System capability**: SystemCapability.Sensors.Sensor
5489
5490**Parameters**
5491
5492| Name     | Type                                                         | Mandatory | Description                                                  |
5493| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5494| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR     | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**. |
5495| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | No        | Callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**. |
5496
5497**Example**
5498
5499```js
5500function callback(data) {
5501    console.info('X-coordinate component: ' + data.x);
5502    console.info('Y-coordinate component: ' + data.y);
5503    console.info('Z-coordinate component: ' + data.z);
5504    console.info('Scalar quantity: ' + data.w);
5505}
5506sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
5507```
5508
5509### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
5510
5511off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void
5512
5513Unsubscribes from sensor data changes.
5514
5515This API is deprecated since API version 9. You are advised to use [sensor.off.SIGNIFICANT_MOTION](#significant_motion9-2) instead.
5516
5517**System capability**: SystemCapability.Sensors.Sensor
5518
5519**Parameters**
5520
5521| Name     | Type                                                         | Mandatory | Description                                                  |
5522| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5523| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION  | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**. |
5524| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | No        | Callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**. |
5525
5526**Example**
5527
5528```js
5529function callback(data) {
5530    console.info('Scalar data: ' + data.scalar);
5531}
5532sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
5533```
5534
5535### WEAR_DETECTION<sup>(deprecated)</sup>
5536
5537off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void
5538
5539Unsubscribes from sensor data changes.
5540
5541This API is deprecated since API version 9. You are advised to use [sensor.off.WEAR_DETECTION](#wear_detection9-2) instead.
5542
5543**System capability**: SystemCapability.Sensors.Sensor
5544
5545**Parameters**
5546
5547| Name     | Type                                                         | Mandatory | Description                                                  |
5548| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5549| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_WEAR_DETECTION**. |
5550| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | No        | Callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**. |
5551
5552**Example**
5553
5554```js
5555function accCallback(data) {
5556    console.info('Wear status: ' + data.value);
5557}
5558sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback);
5559```
5560
5561## sensor.transformCoordinateSystem<sup>(deprecated)</sup>
5562
5563transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5564
5565Rotates a rotation vector so that it can represent the coordinate system in different ways. This API uses an asynchronous callback to return the result.
5566
5567This API is deprecated since API version 9. You are advised to use [sensor.transformRotationMatrix](#sensortransformrotationmatrix9) instead.
5568
5569**System capability**: SystemCapability.Sensors.Sensor
5570
5571**Parameters**
5572
5573| Name             | Type                                      | Mandatory | Description                                                  |
5574| ---------------- | ----------------------------------------- | --------- | ------------------------------------------------------------ |
5575| inRotationVector | Array&lt;number&gt;                       | Yes       | Rotation vector to rotate.                                   |
5576| coordinates      | [CoordinatesOptions](#coordinatesoptions) | Yes       | Direction of the coordinate system.                          |
5577| callback         | AsyncCallback&lt;Array&lt;number&gt;&gt;  | Yes       | Callback used to return the rotation vector after being rotated. |
5578
5579**Example**
5580
5581```js
5582sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
5583    if (err) {
5584        console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
5585        return;
5586    }
5587    console.info("Operation succeeded. Data obtained: " + data);
5588    for (var i=0; i < data.length; i++) {
5589        console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
5590    }
5591 })
5592```
5593## sensor.transformCoordinateSystem<sup>(deprecated)</sup>
5594
5595transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt;
5596
5597Rotates a rotation vector so that it can represent the coordinate system in different ways. This API uses a promise to return the result.
5598
5599This API is deprecated since API version 9. You are advised to use [sensor.transformRotationMatrix](#sensortransformrotationmatrix9-1) instead.
5600
5601**System capability**: SystemCapability.Sensors.Sensor
5602
5603**Parameters**
5604
5605| Name             | Type                                      | Mandatory | Description                         |
5606| ---------------- | ----------------------------------------- | --------- | ----------------------------------- |
5607| inRotationVector | Array&lt;number&gt;                       | Yes       | Rotation vector to rotate.          |
5608| coordinates      | [CoordinatesOptions](#coordinatesoptions) | Yes       | Direction of the coordinate system. |
5609
5610**Return value**
5611
5612| Type                               | Description                                                  |
5613| ---------------------------------- | ------------------------------------------------------------ |
5614| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation vector after being rotated. |
5615
5616**Example**
5617
5618```js
5619const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
5620    promise.then((data) => {
5621        console.info("Operation succeeded.");
5622        for (var i=0; i < data.length; i++) {
5623            console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
5624        }
5625    }).catch((err) => {
5626           console.info("Operation failed");
5627})
5628```
5629
5630## sensor.getGeomagneticField<sup>(deprecated)</sup>
5631
5632getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback&lt;GeomagneticResponse&gt;): void
5633
5634Obtains the geomagnetic field of a geographic location. This API uses an asynchronous callback to return the result.
5635
5636This API is deprecated since API version 9. You are advised to use [sensor.getGeomagneticInfo](#sensorgetgeomagneticinfo9) instead.
5637
5638**System capability**: SystemCapability.Sensors.Sensor
5639
5640**Parameters**
5641
5642| Name            | Type                                                         | Mandatory | Description                                                  |
5643| --------------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5644| locationOptions | [LocationOptions](#locationoptions)                          | Yes       | Geographic location.                                         |
5645| timeMillis      | number                                                       | Yes       | Time for obtaining the magnetic declination, in milliseconds. |
5646| callback        | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes       | Callback used to return the geomagnetic field.               |
5647
5648**Example**
5649```js
5650sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data)  {
5651    if (err) {
5652        console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
5653        return;
5654    }
5655    console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
5656	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
5657		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
5658});
5659```
5660## sensor.getGeomagneticField<sup>(deprecated)</sup>
5661
5662getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt;
5663
5664Obtains the geomagnetic field of a geographic location. This API uses a promise to return the result.
5665
5666This API is deprecated since API version 9. You are advised to use [sensor.getGeomagneticInfo](#sensorgetgeomagneticinfo9-1) instead.
5667
5668**System capability**: SystemCapability.Sensors.Sensor
5669
5670**Parameters**
5671
5672| Name            | Type                                | Mandatory | Description                                                  |
5673| --------------- | ----------------------------------- | --------- | ------------------------------------------------------------ |
5674| locationOptions | [LocationOptions](#locationoptions) | Yes       | Geographic location.                                         |
5675| timeMillis      | number                              | Yes       | Time for obtaining the magnetic declination, in milliseconds. |
5676
5677**Return value**
5678
5679| Type                                                       | Description                                   |
5680| ---------------------------------------------------------- | --------------------------------------------- |
5681| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field. |
5682
5683**Example**
5684  ```js
5685  const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
5686      promise.then((data) => {
5687          console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
5688  	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
5689  		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
5690      }).catch((reason) => {
5691          console.info('Operation failed.');
5692  })
5693  ```
5694
5695## sensor.getAltitude<sup>(deprecated)</sup>
5696
5697getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback&lt;number&gt;): void
5698
5699Obtains the altitude at which the device is located based on the sea-level atmospheric pressure and the current atmospheric pressure. This API uses an asynchronous callback to return the result.
5700
5701This API is deprecated since API version 9. You are advised to use [sensor.getDeviceAltitude](#sensorgetdevicealtitude9) instead.
5702
5703**System capability**: SystemCapability.Sensors.Sensor
5704
5705**Parameters**
5706
5707| Name            | Type                        | Mandatory | Description                                                  |
5708| --------------- | --------------------------- | --------- | ------------------------------------------------------------ |
5709| seaPressure     | number                      | Yes       | Sea-level atmospheric pressure, in hPa.                      |
5710| currentPressure | number                      | Yes       | Atmospheric pressure at the altitude where the device is located, in hPa. |
5711| callback        | AsyncCallback&lt;number&gt; | Yes       | Callback used to return the altitude, in meters.             |
5712
5713**Example**
5714
5715  ```js
5716  sensor.getAltitude(0, 200, function(err, data)  {
5717      if (err) {
5718          console.error(
5719  "Operation failed. Error code: " + err.code + ", message: " + err.message);
5720          return;
5721      }
5722          console.info("Succeeded to get getAltitude interface get data: " + data);
5723  });
5724  ```
5725
5726## sensor.getAltitude<sup>(deprecated)</sup>
5727
5728getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
5729
5730Obtains the altitude at which the device is located based on the sea-level atmospheric pressure and the current atmospheric pressure. This API uses a promise to return the result.
5731
5732This API is deprecated since API version 9. You are advised to use [sensor.getDeviceAltitude](#sensorgetdevicealtitude9-1) instead.
5733
5734**System capability**: SystemCapability.Sensors.Sensor
5735
5736**Parameters**
5737
5738| Name            | Type   | Mandatory | Description                                                  |
5739| --------------- | ------ | --------- | ------------------------------------------------------------ |
5740| seaPressure     | number | Yes       | Sea-level atmospheric pressure, in hPa.                      |
5741| currentPressure | number | Yes       | Atmospheric pressure at the altitude where the device is located, in hPa. |
5742
5743**Return value**
5744
5745| Type                  | Description                                     |
5746| --------------------- | ----------------------------------------------- |
5747| Promise&lt;number&gt; | Promise used to return the altitude, in meters. |
5748
5749**Example**
5750
5751  ```js
5752  const promise = sensor.getAltitude(0, 200);
5753      promise.then((data) => {
5754          console.info(' sensor_getAltitude_Promise success', data);
5755      }).catch((err) => {
5756          console.error("Operation failed");
5757  })
5758  ```
5759
5760
5761## sensor.getGeomagneticDip<sup>(deprecated)</sup>
5762
5763getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void
5764
5765Obtains the magnetic dip based on the inclination matrix. This API uses an asynchronous callback to return the result.
5766
5767This API is deprecated since API version 9. You are advised to use [sensor.getInclination](#sensorgetinclination9) instead.
5768
5769**System capability**: SystemCapability.Sensors.Sensor
5770
5771**Parameters**
5772
5773| Name              | Type                        | Mandatory | Description                                           |
5774| ----------------- | --------------------------- | --------- | ----------------------------------------------------- |
5775| inclinationMatrix | Array&lt;number&gt;         | Yes       | Inclination matrix.                                   |
5776| callback          | AsyncCallback&lt;number&gt; | Yes       | Callback used to return the magnetic dip, in radians. |
5777
5778**Example**
5779
5780  ```js
5781  sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
5782      if (err) {
5783          console.error('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' +
5784                        err.message);
5785          return;
5786      }
5787          console.info("Succeeded to get getGeomagneticDip interface get data: " + data);
5788  })
5789  ```
5790
5791## sensor.getGeomagneticDip<sup>(deprecated)</sup>
5792
5793getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
5794
5795Obtains the magnetic dip based on the inclination matrix. This API uses a promise to return the result.
5796
5797This API is deprecated since API version 9. You are advised to use [sensor.getInclination](#sensorgetinclination9-1) instead.
5798
5799**System capability**: SystemCapability.Sensors.Sensor
5800
5801**Parameters**
5802
5803| Name              | Type                | Mandatory | Description         |
5804| ----------------- | ------------------- | --------- | ------------------- |
5805| inclinationMatrix | Array&lt;number&gt; | Yes       | Inclination matrix. |
5806
5807**Return value**
5808
5809| Type                  | Description                                          |
5810| --------------------- | ---------------------------------------------------- |
5811| Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians. |
5812
5813**Example**
5814
5815  ```js
5816  const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
5817      promise.then((data) => {
5818          console.info('getGeomagneticDip_promise succeeded', data);
5819      }).catch((err) => {
5820           console.error("Operation failed");
5821  })
5822  ```
5823
5824## sensor. getAngleModify<sup>(deprecated)</sup>
5825
5826getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5827
5828Obtains the angle change between two rotation matrices. This API uses an asynchronous callback to return the result.
5829
5830This API is deprecated since API version 9. You are advised to use [sensor.getAngleVariation](#sensorgetanglevariation9) instead.
5831
5832**System capability**: SystemCapability.Sensors.Sensor
5833
5834**Parameters**
5835
5836| Name                  | Type                                     | Mandatory | Description                                                  |
5837| --------------------- | ---------------------------------------- | --------- | ------------------------------------------------------------ |
5838| currentRotationMatrix | Array&lt;number&gt;                      | Yes       | Current rotation matrix.                                     |
5839| preRotationMatrix     | Array&lt;number&gt;                      | Yes       | The other rotation matrix.                                   |
5840| callback              | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the angle change around the z, x, and y axes. |
5841
5842**Example**
5843
5844  ```js
5845  sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data)  {
5846      if (err) {
5847          console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
5848                        err.message);
5849          return;
5850      }
5851      for (var i=0; i < data.length; i++) {
5852          console.info("data[" + i + "]: " + data[i]);
5853      }
5854  })
5855  ```
5856
5857
5858## sensor. getAngleModify<sup>(deprecated)</sup>
5859
5860getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
5861
5862Obtains the angle change between two rotation matrices. This API uses a promise to return the result.
5863
5864This API is deprecated since API version 9. You are advised to use [sensor.getAngleVariation](#sensorgetanglevariation9-1) instead.
5865
5866**System capability**: SystemCapability.Sensors.Sensor
5867
5868**Parameters**
5869
5870| Name                  | Type                | Mandatory | Description                |
5871| --------------------- | ------------------- | --------- | -------------------------- |
5872| currentRotationMatrix | Array&lt;number&gt; | Yes       | Current rotation matrix.   |
5873| preRotationMatrix     | Array&lt;number&gt; | Yes       | The other rotation matrix. |
5874
5875**Return value**
5876
5877| Type                               | Description                                                  |
5878| ---------------------------------- | ------------------------------------------------------------ |
5879| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes. |
5880
5881**Example**
5882
5883  ```js
5884  const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
5885      promise.then((data) => {
5886          console.info('getAngleModify_promise success');
5887          for (var i=0; i < data.length; i++) {
5888              console.info("data[" + i + "]: " + data[i]);
5889          }
5890      }).catch((reason) => {
5891          console.info("promise::catch", reason);
5892  })
5893  ```
5894
5895
5896## sensor.createRotationMatrix<sup>(deprecated)</sup>
5897
5898createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5899
5900Converts a rotation vector into a rotation matrix. This API uses an asynchronous callback to return the result.
5901
5902This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9) instead.
5903
5904**System capability**: SystemCapability.Sensors.Sensor
5905
5906**Parameters**
5907
5908| Name           | Type                                     | Mandatory | Description                                  |
5909| -------------- | ---------------------------------------- | --------- | -------------------------------------------- |
5910| rotationVector | Array&lt;number&gt;                      | Yes       | Rotation vector to convert.                  |
5911| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the rotation matrix. |
5912
5913**Example**
5914
5915  ```js
5916  sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
5917      if (err) {
5918          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
5919                        err.message);
5920          return;
5921      }
5922      for (var i=0; i < data.length; i++) {
5923          console.info("data[" + i + "]: " + data[i]);
5924      }
5925  })
5926  ```
5927
5928
5929## sensor.createRotationMatrix<sup>(deprecated)</sup>
5930
5931createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
5932
5933Converts a rotation vector into a rotation matrix. This API uses a promise to return the result.
5934
5935This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9-1) instead.
5936
5937**System capability**: SystemCapability.Sensors.Sensor
5938
5939**Parameters**
5940
5941| Name           | Type                | Mandatory | Description                 |
5942| -------------- | ------------------- | --------- | --------------------------- |
5943| rotationVector | Array&lt;number&gt; | Yes       | Rotation vector to convert. |
5944
5945**Return value**
5946
5947| Type                               | Description                                 |
5948| ---------------------------------- | ------------------------------------------- |
5949| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix. |
5950
5951**Example**
5952
5953  ```js
5954  const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
5955      promise.then((data) => {
5956          console.info('createRotationMatrix_promise success');
5957          for (var i=0; i < data.length; i++) {
5958              console.info("data[" + i + "]: " + data[i]);
5959          }
5960      }).catch((reason) => {
5961          console.info("promise::catch", reason);
5962  })
5963  ```
5964
5965
5966## sensor.createQuaternion<sup>(deprecated)</sup>
5967
5968createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5969
5970Converts a rotation vector into a quaternion. This API uses an asynchronous callback to return the result.
5971
5972This API is deprecated since API version 9. You are advised to use [sensor.getQuaternion](#sensorgetquaternion9) instead.
5973
5974**System capability**: SystemCapability.Sensors.Sensor
5975
5976**Parameters**
5977
5978| Name           | Type                                     | Mandatory | Description                             |
5979| -------------- | ---------------------------------------- | --------- | --------------------------------------- |
5980| rotationVector | Array&lt;number&gt;                      | Yes       | Rotation vector to convert.             |
5981| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the quaternion. |
5982
5983**Example**
5984
5985  ```js
5986  sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data)  {
5987      if (err) {
5988          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
5989                        err.message);
5990          return;
5991      }
5992      for (var i=0; i < data.length; i++) {
5993          console.info("data[" + i + "]: " + data[i]);
5994      }
5995  })
5996  ```
5997
5998
5999## sensor.createQuaternion<sup>(deprecated)</sup>
6000
6001createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
6002
6003Converts a rotation vector into a quaternion. This API uses a promise to return the result.
6004
6005This API is deprecated since API version 9. You are advised to use [sensor.getQuaternion](#sensorgetquaternion9-1) instead.
6006
6007**System capability**: SystemCapability.Sensors.Sensor
6008
6009**Parameters**
6010
6011| Name           | Type                | Mandatory | Description                 |
6012| -------------- | ------------------- | --------- | --------------------------- |
6013| rotationVector | Array&lt;number&gt; | Yes       | Rotation vector to convert. |
6014
6015**Return value**
6016
6017| Type                               | Description                            |
6018| ---------------------------------- | -------------------------------------- |
6019| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion. |
6020
6021**Example**
6022
6023  ```js
6024  const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
6025      promise.then((data) => {
6026          console.info('createQuaternion_promise succeeded');
6027          for (var i=0; i < data.length; i++) {
6028              console.info("data[" + i + "]: " + data[i]);
6029          }
6030      }).catch((err) => {
6031          console.info('promise failed');
6032  })
6033  ```
6034
6035
6036## sensor.getDirection<sup>(deprecated)</sup>
6037
6038getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
6039
6040Obtains the device direction based on the rotation matrix. This API uses an asynchronous callback to return the result.
6041
6042This API is deprecated since API version 9. You are advised to use [sensor.getOrientation](#sensorgetorientation9) instead.
6043
6044**System capability**: SystemCapability.Sensors.Sensor
6045
6046**Parameters**
6047
6048| Name           | Type                                     | Mandatory | Description                                                  |
6049| -------------- | ---------------------------------------- | --------- | ------------------------------------------------------------ |
6050| rotationMatrix | Array&lt;number&gt;                      | Yes       | Rotation matrix.                                             |
6051| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the rotation angle around the z, x, and y axes. |
6052
6053**Example**
6054
6055  ```js
6056  sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
6057      if (err) {
6058          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
6059                        err.message);
6060          return;
6061      }
6062      console.info("SensorJsAPI--->Succeeded to get getDirection interface get data: " + data);
6063      for (var i = 1; i < data.length; i++) {
6064          console.info("sensor_getDirection_callback" + data[i]);
6065      }
6066  })
6067  ```
6068
6069
6070## sensor.getDirection<sup>(deprecated)</sup>
6071
6072getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
6073
6074Obtains the device direction based on the rotation matrix. This API uses a promise to return the result.
6075
6076This API is deprecated since API version 9. You are advised to use [sensor.getOrientation](#sensorgetorientation9-1) instead.
6077
6078**System capability**: SystemCapability.Sensors.Sensor
6079
6080**Parameters**
6081
6082| Name           | Type                | Mandatory | Description      |
6083| -------------- | ------------------- | --------- | ---------------- |
6084| rotationMatrix | Array&lt;number&gt; | Yes       | Rotation matrix. |
6085
6086**Return value**
6087
6088| Type                               | Description                                                  |
6089| ---------------------------------- | ------------------------------------------------------------ |
6090| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes. |
6091
6092**Example**
6093
6094  ```js
6095  const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
6096      promise.then((data) => {
6097          console.info('sensor_getAltitude_Promise success', data);
6098          for (var i = 1; i < data.length; i++) {
6099              console.info("sensor_getDirection_promise" + data[i]);
6100          }
6101      }).catch((err) => {
6102          console.info('promise failed');
6103  })
6104  ```
6105
6106
6107## sensor.createRotationMatrix<sup>(deprecated)</sup>
6108
6109createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;, callback: AsyncCallback&lt;RotationMatrixResponse&gt;): void
6110
6111Creates a rotation matrix based on the gravity vector and geomagnetic vector. This API uses an asynchronous callback to return the result.
6112
6113This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9-2) instead.
6114
6115**System capability**: SystemCapability.Sensors.Sensor
6116
6117**Parameters**
6118
6119| Name        | Type                                                         | Mandatory | Description                                  |
6120| ----------- | ------------------------------------------------------------ | --------- | -------------------------------------------- |
6121| gravity     | Array&lt;number&gt;                                          | Yes       | Gravity vector.                              |
6122| geomagnetic | Array&lt;number&gt;                                          | Yes       | Geomagnetic vector.                          |
6123| callback    | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes       | Callback used to return the rotation matrix. |
6124
6125**Example**
6126
6127  ```js
6128  sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data)  {
6129      if (err) {
6130          console.error('error code is: ' + err.code + ', message: ' + err.message);
6131          return;
6132      }
6133      console.info(JSON.stringify(data));
6134  })
6135  ```
6136
6137
6138## sensor.createRotationMatrix<sup>(deprecated)</sup>
6139
6140createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;,): Promise&lt;RotationMatrixResponse&gt;
6141
6142Creates a rotation matrix based on the gravity vector and geomagnetic vector. This API uses a promise to return the result.
6143
6144This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9-3) instead.
6145
6146**System capability**: SystemCapability.Sensors.Sensor
6147
6148**Parameters**
6149
6150| Name        | Type                | Mandatory | Description         |
6151| ----------- | ------------------- | --------- | ------------------- |
6152| gravity     | Array&lt;number&gt; | Yes       | Gravity vector.     |
6153| geomagnetic | Array&lt;number&gt; | Yes       | Geomagnetic vector. |
6154
6155**Return value**
6156
6157| Type                                                         | Description                                 |
6158| ------------------------------------------------------------ | ------------------------------------------- |
6159| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix. |
6160
6161**Example**
6162
6163  ```js
6164  const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
6165      promise.then((data) => {
6166          console.info(JSON.stringify(data));
6167      }).catch((err) => {
6168          console.info('promise failed');
6169  })
6170  ```