• 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
3910  ```js
3911  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
3912      console.info('X-coordinate component: ' + data.x);
3913      console.info('Y-coordinate component: ' + data.y);
3914      console.info('Z-coordinate component: ' + data.z);
3915      console.info('X-coordinate bias: ' + data.biasX);
3916      console.info('Y-coordinate bias: ' + data.biasY);
3917      console.info('Z-coordinate bias: ' + data.biasZ);
3918  },
3919      {interval: 10000000}
3920  );
3921  ```
3922
3923### GRAVITY<sup>(deprecated)</sup>
3924
3925on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void
3926
3927Subscribes to data changes of the gravity sensor. If this API is called multiple times for the same application, the last call takes effect.
3928
3929This API is deprecated since API version 9. You are advised to use [sensor.on.GRAVITY](#gravity9) instead.
3930
3931**System capability**: SystemCapability.Sensors.Sensor
3932
3933**Parameters**
3934
3935| Name     | Type                                                | Mandatory | Description                                                  |
3936| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ |
3937| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY    | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**. |
3938| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes       | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**. |
3939| options  | [Options](#options)                                 | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3940
3941**Example**
3942
3943  ```js
3944  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
3945      console.info('X-coordinate component: ' + data.x);
3946      console.info('Y-coordinate component: ' + data.y);
3947      console.info('Z-coordinate component: ' + data.z);
3948  },
3949      {interval: 10000000}
3950  );
3951  ```
3952
3953### GYROSCOPE<sup>(deprecated)</sup>
3954
3955on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;, options?: Options): void
3956
3957Subscribes to data changes of the gyroscope sensor. If this API is called multiple times for the same application, the last call takes effect.
3958
3959This API is deprecated since API version 9. You are advised to use [sensor.on.GYROSCOPE](#gyroscope9) instead.
3960
3961**Required permissions**: ohos.permission.GYROSCOPE
3962
3963**System capability**: SystemCapability.Sensors.Sensor
3964
3965**Parameters**
3966
3967| Name     | Type                                                    | Mandatory | Description                                                  |
3968| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
3969| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
3970| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes       | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**. |
3971| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
3972
3973**Example**
3974
3975  ```js
3976  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
3977      console.info('X-coordinate component: ' + data.x);
3978      console.info('Y-coordinate component: ' + data.y);
3979      console.info('Z-coordinate component: ' + data.z);
3980  },
3981      {interval: 10000000}
3982  );
3983  ```
3984
3985### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
3986
3987on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;GyroscopeUncalibratedResponse&gt;, options?: Options): void
3988
3989Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is called multiple times for the same application, the last call takes effect.
3990
3991This API is deprecated since API version 9. You are advised to use [sensor.on.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9) instead.
3992
3993**Required permissions**: ohos.permission.GYROSCOPE
3994
3995**System capability**: SystemCapability.Sensors.Sensor
3996
3997**Parameters**
3998
3999| Name     | Type                                                         | Mandatory | Description                                                  |
4000| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4001| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**. |
4002| 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**. |
4003| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. |
4004
4005**Example**
4006
4007  ```js
4008  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
4009      console.info('X-coordinate component: ' + data.x);
4010      console.info('Y-coordinate component: ' + data.y);
4011      console.info('Z-coordinate component: ' + data.z);
4012      console.info('X-coordinate bias: ' + data.biasX);
4013      console.info('Y-coordinate bias: ' + data.biasY);
4014      console.info('Z-coordinate bias: ' + data.biasZ);
4015  },
4016      {interval: 10000000}
4017  );
4018  ```
4019
4020### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
4021
4022on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;, options?: Options): void
4023
4024Subscribes to data changes of the significant motion sensor. If this API is called multiple times for the same application, the last call takes effect.
4025
4026This API is deprecated since API version 9. You are advised to use [sensor.on.SIGNIFICANT_MOTION](#significant_motion9) instead.
4027
4028**System capability**: SystemCapability.Sensors.Sensor
4029
4030**Parameters**
4031
4032| Name     | Type                                                         | Mandatory | Description                                                  |
4033| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4034| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION  | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**. |
4035| 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**. |
4036| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4037
4038**Example**
4039
4040  ```js
4041  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
4042      console.info('Scalar data: ' + data.scalar);
4043  },
4044      {interval: 10000000}
4045  );
4046  ```
4047
4048### PEDOMETER_DETECTION<sup>(deprecated)</sup>
4049
4050on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;, options?: Options): void
4051
4052Subscribes to data changes of the pedometer detection sensor. If this API is called multiple times for the same application, the last call takes effect.
4053
4054This API is deprecated since API version 9. You are advised to use [sensor.on.PEDOMETER_DETECTION](#pedometer_detection9) instead.
4055
4056**Required permissions**: ohos.permission.ACTIVITY_MOTION
4057
4058**System capability**: SystemCapability.Sensors.Sensor
4059
4060**Parameters**
4061
4062| Name     | Type                                                         | Mandatory | Description                                                  |
4063| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4064| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**. |
4065| 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**. |
4066| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4067
4068**Example**
4069
4070  ```js
4071  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
4072      console.info('Scalar data: ' + data.scalar);
4073  },
4074      {interval: 10000000}
4075  );
4076  ```
4077
4078### PEDOMETER<sup>(deprecated)</sup>
4079
4080on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void
4081
4082Subscribes to data changes of the pedometer sensor. If this API is called multiple times for the same application, the last call takes effect.
4083
4084This API is deprecated since API version 9. You are advised to use [sensor.on.PEDOMETER](#pedometer9) instead.
4085
4086**Required permissions**: ohos.permission.ACTIVITY_MOTION
4087
4088**System capability**: SystemCapability.Sensors.Sensor
4089
4090**Parameters**
4091
4092| Name     | Type                                                    | Mandatory | Description                                                  |
4093| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4094| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**. |
4095| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes       | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**. |
4096| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4097
4098**Example**
4099
4100  ```js
4101  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
4102      console.info('Steps: ' + data.steps);
4103  },
4104      {interval: 10000000}
4105  );
4106  ```
4107
4108### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
4109
4110on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;AmbientTemperatureResponse&gt;,  options?: Options): void
4111
4112Subscribes to data changes of the ambient temperature sensor. If this API is called multiple times for the same application, the last call takes effect.
4113
4114This API is deprecated since API version 9. You are advised to use [sensor.on.AMBIENT_TEMPERATURE](#ambient_temperature9) instead.
4115
4116**System capability**: SystemCapability.Sensors.Sensor
4117
4118**Parameters**
4119
4120| Name     | Type                                                         | Mandatory | Description                                                  |
4121| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4122| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**. |
4123| 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**. |
4124| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4125
4126**Example**
4127
4128  ```js
4129  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
4130      console.info('Temperature: ' + data.temperature);
4131  },
4132      {interval: 10000000}
4133  );
4134
4135  ```
4136
4137### MAGNETIC_FIELD<sup>(deprecated)</sup>
4138
4139on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void
4140
4141Subscribes to data changes of the magnetic field sensor. If this API is called multiple times for the same application, the last call takes effect.
4142
4143This API is deprecated since API version 9. You are advised to use [sensor.on.MAGNETIC_FIELD](#magnetic_field9) instead.
4144
4145**System capability**: SystemCapability.Sensors.Sensor
4146
4147**Parameters**
4148
4149| Name     | Type                                                         | Mandatory | Description                                                  |
4150| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4151| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
4152| 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**. |
4153| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4154
4155**Example**
4156
4157  ```js
4158  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
4159      console.info('X-coordinate component: ' + data.x);
4160      console.info('Y-coordinate component: ' + data.y);
4161      console.info('Z-coordinate component: ' + data.z);
4162  },
4163      {interval: 10000000}
4164  );
4165
4166  ```
4167
4168### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
4169
4170on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void
4171
4172Subscribes 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.
4173
4174This API is deprecated since API version 9. You are advised to use [sensor.on.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9) instead.
4175
4176**System capability**: SystemCapability.Sensors.Sensor
4177
4178**Parameters**
4179
4180| Name     | Type                                                         | Mandatory | Description                                                  |
4181| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4182| 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**. |
4183| 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**. |
4184| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4185
4186**Example**
4187
4188  ```js
4189  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
4190      console.info('X-coordinate component: ' + data.x);
4191      console.info('Y-coordinate component: ' + data.y);
4192      console.info('Z-coordinate component: ' + data.z);
4193      console.info('X-coordinate bias: ' + data.biasX);
4194      console.info('Y-coordinate bias: ' + data.biasY);
4195      console.info('Z-coordinate bias: ' + data.biasZ);
4196  },
4197      {interval: 10000000}
4198  );
4199
4200  ```
4201
4202### PROXIMITY<sup>(deprecated)</sup>
4203
4204on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;,options?: Options): void
4205
4206Subscribes to data changes of the proximity sensor. If this API is called multiple times for the same application, the last call takes effect.
4207
4208This API is deprecated since API version 9. You are advised to use [sensor.on.PROXIMITY](#proximity9) instead.
4209
4210**System capability**: SystemCapability.Sensors.Sensor
4211
4212**Parameters**
4213
4214| Name     | Type                                                    | Mandatory | Description                                                  |
4215| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4216| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**. |
4217| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes       | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**. |
4218| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4219
4220**Example**
4221
4222  ```js
4223  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
4224      console.info('Distance: ' + data.distance);
4225  },
4226      {interval: 10000000}
4227  );
4228
4229  ```
4230
4231### HUMIDITY<sup>(deprecated)</sup>
4232
4233on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void
4234
4235Subscribes to data changes of the humidity sensor. If this API is called multiple times for the same application, the last call takes effect.
4236
4237This API is deprecated since API version 9. You are advised to use [sensor.on.HUMIDITY](#humidity9) instead.
4238
4239**System capability**: SystemCapability.Sensors.Sensor
4240
4241**Parameters**
4242
4243| Name     | Type                                                  | Mandatory | Description                                                  |
4244| -------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
4245| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**. |
4246| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes       | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**. |
4247| options  | [Options](#options)                                   | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4248
4249**Example**
4250
4251  ```js
4252  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
4253      console.info('Humidity: ' + data.humidity);
4254  },
4255      {interval: 10000000}
4256  );
4257
4258  ```
4259
4260### BAROMETER<sup>(deprecated)</sup>
4261
4262on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;,options?: Options): void
4263
4264Subscribes to data changes of the barometer sensor. If this API is called multiple times for the same application, the last call takes effect.
4265
4266This API is deprecated since API version 9. You are advised to use [sensor.on.BAROMETER](#barometer9) instead.
4267
4268**System capability**: SystemCapability.Sensors.Sensor
4269
4270**Parameters**
4271
4272| Name     | Type                                                    | Mandatory | Description                                                  |
4273| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4274| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**. |
4275| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes       | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**. |
4276| options  | [Options](#options)                                     | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4277
4278**Example**
4279
4280  ```js
4281  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
4282      console.info('Atmospheric pressure: ' + data.pressure);
4283  },
4284      {interval: 10000000}
4285  );
4286
4287  ```
4288
4289### HALL<sup>(deprecated)</sup>
4290
4291on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void
4292
4293Subscribes to data changes of the Hall effect sensor. If this API is called multiple times for the same application, the last call takes effect.
4294
4295This API is deprecated since API version 9. You are advised to use [sensor.on.HALL](#hall9) instead.
4296
4297**System capability**: SystemCapability.Sensors.Sensor
4298
4299**Parameters**
4300
4301| Name     | Type                                          | Mandatory | Description                                                  |
4302| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
4303| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**. |
4304| 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**. |
4305| options  | [Options](#options)                           | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4306
4307**Example**
4308
4309  ```js
4310  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
4311      console.info('Status: ' + data.status);
4312  },
4313      {interval: 10000000}
4314  );
4315
4316  ```
4317
4318### AMBIENT_LIGHT<sup>(deprecated)</sup>
4319
4320on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void
4321
4322Subscribes to data changes of the ambient light sensor. If this API is called multiple times for the same application, the last call takes effect.
4323
4324This API is deprecated since API version 9. You are advised to use [sensor.on.AMBIENT_LIGHT](#ambient_light9) instead.
4325
4326**System capability**: SystemCapability.Sensors.Sensor
4327
4328**Parameters**
4329
4330| Name     | Type                                                   | Mandatory | Description                                                  |
4331| -------- | ------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4332| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**. |
4333| 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**. |
4334| options  | [Options](#options)                                    | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4335
4336**Example**
4337
4338  ```js
4339  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
4340      console.info(' Illumination: ' + data.intensity);
4341  },
4342      {interval: 10000000}
4343  );
4344
4345  ```
4346
4347### ORIENTATION<sup>(deprecated)</sup>
4348
4349on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;, options?: Options): void
4350
4351Subscribes to data changes of the orientation sensor. If this API is called multiple times for the same application, the last call takes effect.
4352
4353This API is deprecated since API version 9. You are advised to use [sensor.on.ORIENTATION](#orientation9) instead.
4354
4355**System capability**: SystemCapability.Sensors.Sensor
4356
4357**Parameters**
4358
4359| Name     | Type                                                        | Mandatory | Description                                                  |
4360| -------- | ----------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4361| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION        | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**. |
4362| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes       | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**. |
4363| options  | [Options](#options)                                         | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4364
4365**Example**
4366
4367  ```js
4368  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
4369      console.info('The device rotates at an angle around the X axis: ' + data.beta);
4370      console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
4371      console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
4372  },
4373      {interval: 10000000}
4374  );
4375
4376  ```
4377
4378### HEART_RATE<sup>(deprecated)</sup>
4379
4380on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;, options?: Options): void
4381
4382Subscribes to only one data change of the heart rate sensor.
4383
4384This API is deprecated since API version 9. You are advised to use [sensor.on.HEART_RATE](#heart_rate9) instead.
4385
4386**Required permissions**: ohos.permission.HEALTH_DATA
4387
4388**System capability**: SystemCapability.Sensors.Sensor
4389
4390**Parameters**
4391
4392| Name     | Type                                                    | Mandatory | Description                                                  |
4393| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4394| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. |
4395| 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**. |
4396
4397### ROTATION_VECTOR<sup>(deprecated)</sup>
4398
4399on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;RotationVectorResponse&gt;,options?: Options): void
4400
4401Subscribes to data changes of the rotation vector sensor. If this API is called multiple times for the same application, the last call takes effect.
4402
4403This API is deprecated since API version 9. You are advised to use [sensor.on.ROTATION_VECTOR](#rotation_vector9) instead.
4404
4405**System capability**: SystemCapability.Sensors.Sensor
4406
4407**Parameters**
4408
4409| Name     | Type                                                         | Mandatory | Description                                                  |
4410| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4411| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**. |
4412| 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**. |
4413| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4414
4415**Example**
4416
4417  ```js
4418  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
4419      console.info('X-coordinate component: ' + data.x);
4420      console.info('Y-coordinate component: ' + data.y);
4421      console.info('Z-coordinate component: ' + data.z);
4422      console.info('Scalar quantity: ' + data.w);
4423  },
4424      {interval: 10000000}
4425  );
4426
4427  ```
4428
4429### WEAR_DETECTION<sup>(deprecated)</sup>
4430
4431on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,options?: Options): void
4432
4433Subscribes to data changes of the wear detection sensor. If this API is called multiple times for the same application, the last call takes effect.
4434
4435This API is deprecated since API version 9. You are advised to use [sensor.on.WEAR_DETECTION](#wear_detection9) instead.
4436
4437**System capability**: SystemCapability.Sensors.Sensor
4438
4439**Parameters**
4440
4441| Name     | Type                                                         | Mandatory | Description                                                  |
4442| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4443| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**. |
4444| 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**. |
4445| options  | [Options](#options)                                          | No        | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
4446
4447**Example**
4448
4449  ```js
4450  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
4451      console.info('Wear status: ' + data.value);
4452  },
4453      {interval: 10000000}
4454  );
4455
4456  ```
4457
4458## sensor.once<sup>(deprecated)</sup>
4459
4460### ACCELEROMETER<sup>(deprecated)</sup>
4461
4462once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void
4463
4464Subscribes to only one data change of the acceleration sensor.
4465
4466This API is deprecated since API version 9. You are advised to use [sensor.once.ACCELEROMETER](#accelerometer9-1) instead.
4467
4468**Required permissions**: ohos.permission.ACCELEROMETER
4469
4470**System capability**: SystemCapability.Sensors.Sensor
4471
4472**Parameters**
4473
4474| Name     | Type                                                         | Mandatory | Description                                                  |
4475| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4476| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER       | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**. |
4477| 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**. |
4478
4479**Example**
4480
4481  ```js
4482  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
4483      console.info('X-coordinate component: ' + data.x);
4484      console.info('Y-coordinate component: ' + data.y);
4485      console.info('Z-coordinate component: ' + data.z);
4486    }
4487  );
4488
4489  ```
4490
4491### LINEAR_ACCELERATION<sup>(deprecated)</sup>
4492
4493once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;): void
4494
4495Subscribes to only one data change of the linear acceleration sensor.
4496
4497This API is deprecated since API version 9. You are advised to use [sensor.once.LINEAR_ACCELEROMETER](#linear_accelerometer9-1) instead.
4498
4499**Required permissions**: ohos.permission.ACCELERATION
4500
4501**System capability**: SystemCapability.Sensors.Sensor
4502
4503**Parameters**
4504
4505| Name     | Type                                                         | Mandatory | Description                                                  |
4506| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4507| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**. |
4508| 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**. |
4509
4510### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
4511
4512once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
4513
4514Subscribes to only one data change of the uncalibrated acceleration sensor.
4515
4516This API is deprecated since API version 9. You are advised to use [sensor.once.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-1) instead.
4517
4518**Required permissions**: ohos.permission.ACCELEROMETER
4519
4520**System capability**: SystemCapability.Sensors.Sensor
4521
4522**Parameters**
4523
4524| Name     | Type                                                         | Mandatory | Description                                                  |
4525| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4526| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**. |
4527| 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**. |
4528
4529**Example**
4530
4531  ```
4532  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) {
4533      console.info('X-coordinate component: ' + data.x);
4534      console.info('Y-coordinate component: ' + data.y);
4535      console.info('Z-coordinate component: ' + data.z);
4536      console.info('X-coordinate bias: ' + data.biasX);
4537      console.info('Y-coordinate bias: ' + data.biasY);
4538      console.info('Z-coordinate bias: ' + data.biasZ);
4539    }
4540  );
4541
4542  ```
4543
4544### GRAVITY<sup>(deprecated)</sup>
4545
4546once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;): void
4547
4548Subscribes to only one data change of the gravity sensor.
4549
4550This API is deprecated since API version 9. You are advised to use [sensor.once.GRAVITY](#gravity9-1) instead.
4551
4552**System capability**: SystemCapability.Sensors.Sensor
4553
4554**Parameters**
4555
4556| Name     | Type                                                | Mandatory | Description                                                  |
4557| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ |
4558| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY    | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**. |
4559| 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**. |
4560
4561**Example**
4562
4563  ```js
4564  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, 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
4573### GYROSCOPE<sup>(deprecated)</sup>
4574
4575once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void
4576
4577Subscribes to only one data change of the gyroscope sensor.
4578
4579This API is deprecated since API version 9. You are advised to use [sensor.once.GYROSCOPE](#gyroscope9-1) instead.
4580
4581**Required permissions**: ohos.permission.GYROSCOPE
4582
4583**System capability**: SystemCapability.Sensors.Sensor
4584
4585**Parameters**
4586
4587| Name     | Type                                                    | Mandatory | Description                                                  |
4588| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4589| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
4590| 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**. |
4591
4592**Example**
4593
4594  ```js
4595  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
4596      console.info('X-coordinate component: ' + data.x);
4597      console.info('Y-coordinate component: ' + data.y);
4598      console.info('Z-coordinate component: ' + data.z);
4599    }
4600  );
4601
4602  ```
4603
4604### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
4605
4606once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
4607
4608Subscribes to only one data change of the uncalibrated gyroscope sensor.
4609
4610This API is deprecated since API version 9. You are advised to use [sensor.once.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-1) instead.
4611
4612**Required permissions**: ohos.permission.GYROSCOPE
4613
4614**System capability**: SystemCapability.Sensors.Sensor
4615
4616**Parameters**
4617
4618| Name     | Type                                                         | Mandatory | Description                                                  |
4619| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4620| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**. |
4621| 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**. |
4622
4623**Example**
4624
4625  ```js
4626  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
4627      console.info('X-coordinate component: ' + data.x);
4628      console.info('Y-coordinate component: ' + data.y);
4629      console.info('Z-coordinate component: ' + data.z);
4630      console.info('X-coordinate bias: ' + data.biasX);
4631      console.info('Y-coordinate bias: ' + data.biasY);
4632      console.info('Z-coordinate bias: ' + data.biasZ);
4633    }
4634  );
4635
4636  ```
4637
4638### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
4639
4640once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;SignificantMotionResponse&gt;): void
4641
4642Subscribes to only one data change of the significant motion sensor.
4643
4644This API is deprecated since API version 9. You are advised to use [sensor.once.SIGNIFICANT_MOTION](#significant_motion9-1) instead.
4645
4646**System capability**: SystemCapability.Sensors.Sensor
4647
4648**Parameters**
4649
4650| Name     | Type                                                         | Mandatory | Description                                                  |
4651| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4652| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION  | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**. |
4653| 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**. |
4654
4655**Example**
4656
4657  ```js
4658  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
4659      console.info('Scalar data: ' + data.scalar);
4660    }
4661  );
4662
4663  ```
4664
4665### PEDOMETER_DETECTION<sup>(deprecated)</sup>
4666
4667once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;PedometerDetectionResponse&gt;): void
4668
4669Subscribes to only one data change of the pedometer detection sensor.
4670
4671This API is deprecated since API version 9. You are advised to use [sensor.once.PEDOMETER_DETECTION](#pedometer_detection9-1) instead.
4672
4673**Required permissions**: ohos.permission.ACTIVITY_MOTION
4674
4675**System capability**: SystemCapability.Sensors.Sensor
4676
4677**Parameters**
4678
4679| Name     | Type                                                         | Mandatory | Description                                                  |
4680| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4681| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**. |
4682| 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**. |
4683
4684**Example**
4685
4686  ```js
4687  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
4688      console.info('Scalar data: ' + data.scalar);
4689    }
4690  );
4691
4692  ```
4693
4694### PEDOMETER<sup>(deprecated)</sup>
4695
4696once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void
4697
4698Subscribes to only one data change of the pedometer sensor.
4699
4700This API is deprecated since API version 9. You are advised to use [sensor.once.PEDOMETER](#pedometer9-1) instead.
4701
4702**Required permissions**: ohos.permission.ACTIVITY_MOTION
4703
4704**System capability**: SystemCapability.Sensors.Sensor
4705
4706**Parameters**
4707
4708| Name     | Type                                                    | Mandatory | Description                                                  |
4709| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4710| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**. |
4711| 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**. |
4712
4713**Example**
4714
4715  ```js
4716  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
4717      console.info('Steps: ' + data.steps);
4718    }
4719  );
4720
4721  ```
4722
4723### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
4724
4725once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;AmbientTemperatureResponse&gt;): void
4726
4727Subscribes to only one data change of the ambient temperature sensor.
4728
4729This API is deprecated since API version 9. You are advised to use [sensor.once.AMBIENT_TEMPERATURE](#ambient_temperature9-1) instead.
4730
4731**System capability**: SystemCapability.Sensors.Sensor
4732
4733**Parameters**
4734
4735| Name     | Type                                                         | Mandatory | Description                                                  |
4736| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4737| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**. |
4738| 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**. |
4739
4740**Example**
4741
4742  ```js
4743  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
4744      console.info('Temperature: ' + data.temperature);
4745    }
4746  );
4747
4748  ```
4749
4750### MAGNETIC_FIELD<sup>(deprecated)</sup>
4751
4752once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void
4753
4754Subscribes to only one data change of the magnetic field sensor.
4755
4756This API is deprecated since API version 9. You are advised to use [sensor.once.MAGNETIC_FIELD](#magnetic_field9-1) instead.
4757
4758**System capability**: SystemCapability.Sensors.Sensor
4759
4760**Parameters**
4761
4762| Name     | Type                                                         | Mandatory | Description                                                  |
4763| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4764| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
4765| 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**. |
4766
4767**Example**
4768
4769  ```js
4770  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
4771      console.info('X-coordinate component: ' + data.x);
4772      console.info('Y-coordinate component: ' + data.y);
4773      console.info('Z-coordinate component: ' + data.z);
4774    }
4775  );
4776
4777  ```
4778
4779### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
4780
4781once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
4782
4783Subscribes to only one data change of the uncalibrated magnetic field sensor.
4784
4785This API is deprecated since API version 9. You are advised to use [sensor.once.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-1) instead.
4786
4787**System capability**: SystemCapability.Sensors.Sensor
4788
4789**Parameters**
4790
4791| Name     | Type                                                         | Mandatory | Description                                                  |
4792| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4793| 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**. |
4794| 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**. |
4795
4796**Example**
4797
4798  ```js
4799  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
4800      console.info('X-coordinate component: ' + data.x);
4801      console.info('Y-coordinate component: ' + data.y);
4802      console.info('Z-coordinate component: ' + data.z);
4803      console.info('X-coordinate bias: ' + data.biasX);
4804      console.info('Y-coordinate bias: ' + data.biasY);
4805      console.info('Z-coordinate bias: ' + data.biasZ);
4806    }
4807  );
4808
4809  ```
4810
4811### PROXIMITY<sup>(deprecated)</sup>
4812
4813once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void
4814
4815Subscribes to only one data change of the proximity sensor.
4816
4817This API is deprecated since API version 9. You are advised to use [sensor.once.PROXIMITY](#proximity9-1) instead.
4818
4819**System capability**: SystemCapability.Sensors.Sensor
4820
4821**Parameters**
4822
4823| Name     | Type                                                    | Mandatory | Description                                                  |
4824| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4825| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**. |
4826| 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**. |
4827
4828**Example**
4829
4830  ```js
4831  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) {
4832      console.info('Distance: ' + data.distance);
4833    }
4834  );
4835
4836  ```
4837
4838### HUMIDITY<sup>(deprecated)</sup>
4839
4840once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void
4841
4842Subscribes to only one data change of the humidity sensor.
4843
4844This API is deprecated since API version 9. You are advised to use [sensor.once.HUMIDITY](#humidity9-1) instead.
4845
4846**System capability**: SystemCapability.Sensors.Sensor
4847
4848**Parameters**
4849
4850| Name     | Type                                                  | Mandatory | Description                                                  |
4851| -------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
4852| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**. |
4853| 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**. |
4854
4855**Example**
4856
4857  ```js
4858  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
4859      console.info('Humidity: ' + data.humidity);
4860    }
4861  );
4862
4863  ```
4864
4865### BAROMETER<sup>(deprecated)</sup>
4866
4867once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void
4868
4869Subscribes to only one data change of the barometer sensor.
4870
4871This API is deprecated since API version 9. You are advised to use [sensor.once.BAROMETER](#barometer9-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_BAROMETER      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**. |
4880| 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**. |
4881
4882**Example**
4883
4884  ```js
4885  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
4886      console.info('Atmospheric pressure: ' + data.pressure);
4887    }
4888  );
4889
4890  ```
4891
4892### HALL<sup>(deprecated)</sup>
4893
4894once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;): void
4895
4896Subscribes to only one data change of the Hall effect sensor.
4897
4898This API is deprecated since API version 9. You are advised to use [sensor.once.HALL](#hall9-1) instead.
4899
4900**System capability**: SystemCapability.Sensors.Sensor
4901
4902**Parameters**
4903
4904| Name     | Type                                          | Mandatory | Description                                                  |
4905| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
4906| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**. |
4907| 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**. |
4908
4909**Example**
4910
4911  ```js
4912  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
4913      console.info('Status: ' + data.status);
4914    }
4915  );
4916
4917  ```
4918
4919### AMBIENT_LIGHT<sup>(deprecated)</sup>
4920
4921once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void
4922
4923Subscribes to only one data change of the ambient light sensor.
4924
4925This API is deprecated since API version 9. You are advised to use [sensor.once.AMBIENT_LIGHT](#ambient_light9-1) instead.
4926
4927**System capability**: SystemCapability.Sensors.Sensor
4928
4929**Parameters**
4930
4931| Name     | Type                                                   | Mandatory | Description                                                  |
4932| -------- | ------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4933| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**. |
4934| 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**. |
4935
4936**Example**
4937
4938  ```js
4939  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
4940      console.info(' Illumination: ' + data.intensity);
4941    }
4942  );
4943
4944  ```
4945
4946### ORIENTATION<sup>(deprecated)</sup>
4947
4948once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void
4949
4950Subscribes to only one data change of the orientation sensor.
4951
4952This API is deprecated since API version 9. You are advised to use [sensor.once.ORIENTATION](#orientation9-1) instead.
4953
4954**System capability**: SystemCapability.Sensors.Sensor
4955
4956**Parameters**
4957
4958| Name     | Type                                                        | Mandatory | Description                                                  |
4959| -------- | ----------------------------------------------------------- | --------- | ------------------------------------------------------------ |
4960| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION        | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**. |
4961| 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**. |
4962
4963**Example**
4964
4965  ```js
4966  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
4967      console.info('The device rotates at an angle around the X axis: ' + data.beta);
4968      console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
4969      console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
4970    }
4971  );
4972
4973  ```
4974
4975### ROTATION_VECTOR<sup>(deprecated)</sup>
4976
4977once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void
4978
4979Subscribes to only one data change of the rotation vector sensor.
4980
4981This API is deprecated since API version 9. You are advised to use [sensor.once.ROTATION_VECTOR](#rotation_vector9-1) instead.
4982
4983**System capability**: SystemCapability.Sensors.Sensor
4984
4985**Parameters**
4986
4987| Name     | Type                                                         | Mandatory | Description                                                  |
4988| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
4989| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**. |
4990| 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**. |
4991
4992**Example**
4993
4994  ```js
4995  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
4996      console.info('X-coordinate component: ' + data.x);
4997      console.info('Y-coordinate component: ' + data.y);
4998      console.info('Z-coordinate component: ' + data.z);
4999      console.info('Scalar quantity: ' + data.w);
5000    }
5001  );
5002
5003  ```
5004
5005### HEART_RATE<sup>(deprecated)</sup>
5006
5007once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void
5008
5009Subscribes to only one data change of the heart rate sensor.
5010
5011This API is deprecated since API version 9. You are advised to use [sensor.once.HEART_RATE](#heart_rate9-1) instead.
5012
5013**Required permissions**: ohos.permission.HEART_RATE
5014
5015**System capability**: SystemCapability.Sensors.Sensor
5016
5017**Parameters**
5018
5019| Name     | Type                                                    | Mandatory | Description                                                  |
5020| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5021| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE     | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. |
5022| 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**. |
5023
5024### WEAR_DETECTION<sup>(deprecated)</sup>
5025
5026once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void
5027
5028Subscribes to only one data change of the wear detection sensor.
5029
5030This API is deprecated since API version 9. You are advised to use [sensor.once.WEAR_DETECTION](#wear_detection9-1) instead.
5031
5032**System capability**: SystemCapability.Sensors.Sensor
5033
5034**Parameters**
5035
5036| Name     | Type                                                         | Mandatory | Description                                                  |
5037| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5038| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION      | Yes       | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**. |
5039| 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**. |
5040
5041**Example**
5042
5043  ```js
5044  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
5045      console.info("Wear status: "+ data.value);
5046    }
5047  );
5048
5049  ```
5050
5051## sensor.off<sup>(deprecated)</sup>
5052
5053### ACCELEROMETER<sup>(deprecated)</sup>
5054
5055off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void
5056
5057Unsubscribes from sensor data changes.
5058
5059This API is deprecated since API version 9. You are advised to use [sensor.off.ACCELEROMETER](#accelerometer9-2) instead.
5060
5061**Required permissions**: ohos.permission.ACCELEROMETER
5062
5063**System capability**: SystemCapability.Sensors.Sensor
5064
5065**Parameters**
5066
5067| Name     | Type                                                         | Mandatory | Description                                                  |
5068| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5069| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER       | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER**. |
5070| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | No        | Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**. |
5071
5072**Example**
5073
5074```js
5075function callback(data) {
5076    console.info('x-coordinate component: ' + data.x);
5077    console.info('Y-coordinate component: ' + data.y);
5078    console.info('Z-coordinate component: ' + data.z);
5079}
5080sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
5081
5082```
5083
5084### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
5085
5086off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
5087
5088Unsubscribes from sensor data changes.
5089
5090This API is deprecated since API version 9. You are advised to use [sensor.off.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-2) instead.
5091
5092**Required permissions**: ohos.permission.ACCELEROMETER
5093
5094**System capability**: SystemCapability.Sensors.Sensor
5095
5096**Parameters**
5097
5098| Name     | Type                                                         | Mandatory | Description                                                  |
5099| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5100| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**. |
5101| 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**. |
5102
5103**Example**
5104
5105```js
5106function callback(data) {
5107    console.info('X-coordinate component: ' + data.x);
5108    console.info('Y-coordinate component: ' + data.y);
5109    console.info('Z-coordinate component: ' + data.z);
5110    console.info('X-coordinate bias: ' + data.biasX);
5111    console.info('Y-coordinate bias: ' + data.biasY);
5112    console.info('Z-coordinate bias: ' + data.biasZ);
5113}
5114sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback);
5115
5116```
5117
5118### AMBIENT_LIGHT<sup>(deprecated)</sup>
5119
5120off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void
5121
5122Unsubscribes from sensor data changes.
5123
5124This API is deprecated since API version 9. You are advised to use [sensor.off.AMBIENT_LIGHT](#ambient_light9-2) instead.
5125
5126**System capability**: SystemCapability.Sensors.Sensor
5127
5128**Parameters**
5129
5130| Name     | Type                                                   | Mandatory | Description                                                  |
5131| -------- | ------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5132| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**. |
5133| 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**. |
5134
5135**Example**
5136
5137```js
5138function callback(data) {
5139    console.info(' Illumination: ' + data.intensity);
5140}
5141sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
5142
5143```
5144
5145### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
5146
5147off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void
5148
5149Unsubscribes from sensor data changes.
5150
5151This API is deprecated since API version 9. You are advised to use [sensor.off.AMBIENT_TEMPERATURE](#ambient_temperature9-2) instead.
5152
5153**System capability**: SystemCapability.Sensors.Sensor
5154
5155**Parameters**
5156
5157| Name     | Type                                                         | Mandatory | Description                                                  |
5158| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5159| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**. |
5160| 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**. |
5161
5162**Example**
5163
5164```js
5165function callback(data) {
5166     console.info('Temperature: ' + data.temperature);
5167}
5168sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
5169
5170```
5171
5172### BAROMETER<sup>(deprecated)</sup>
5173
5174off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void
5175
5176Unsubscribes from sensor data changes.
5177
5178This API is deprecated since API version 9. You are advised to use [sensor.off.BAROMETER](#barometer9-2) instead.
5179
5180**System capability**: SystemCapability.Sensors.Sensor
5181
5182**Parameters**
5183
5184| Name     | Type                                                    | Mandatory | Description                                                  |
5185| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5186| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_BAROMETER**. |
5187| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | No        | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**. |
5188
5189**Example**
5190
5191```js
5192function callback(data) {
5193     console.info('Atmospheric pressure: ' + data.pressure);
5194}
5195sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
5196
5197```
5198
5199### GRAVITY<sup>(deprecated)</sup>
5200
5201off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
5202
5203Unsubscribes from sensor data changes.
5204
5205This API is deprecated since API version 9. You are advised to use [sensor.off.GRAVITY](#gravity9-2) instead.
5206
5207**System capability**: SystemCapability.Sensors.Sensor
5208
5209**Parameters**
5210
5211| Name     | Type                                                | Mandatory | Description                                                  |
5212| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ |
5213| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY    | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GRAVITY**. |
5214| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | No        | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**. |
5215
5216**Example**
5217
5218```js
5219function callback(data) {
5220    console.info('X-coordinate component: ' + data.x);
5221    console.info('Y-coordinate component: ' + data.y);
5222    console.info('Z-coordinate component: ' + data.z);
5223}
5224sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
5225
5226```
5227
5228### GYROSCOPE<sup>(deprecated)</sup>
5229
5230off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void
5231
5232Unsubscribes from sensor data changes.
5233
5234This API is deprecated since API version 9. You are advised to use [sensor.off.GYROSCOPE](#gyroscope9-2) instead.
5235
5236**Required permissions**: ohos.permission.GYROSCOPE
5237
5238**System capability**: SystemCapability.Sensors.Sensor
5239
5240**Parameters**
5241
5242| Name     | Type                                                    | Mandatory | Description                                                  |
5243| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5244| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
5245| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | No        | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**. |
5246
5247**Example**
5248
5249```js
5250function callback(data) {
5251    console.info('X-coordinate component: ' + data.x);
5252    console.info('Y-coordinate component: ' + data.y);
5253    console.info('Z-coordinate component: ' + data.z);
5254}
5255sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
5256
5257```
5258
5259### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
5260
5261off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
5262
5263Unsubscribes from sensor data changes.
5264
5265This API is deprecated since API version 9. You are advised to use [sensor.off.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-2) instead.
5266
5267**Required permissions**: ohos.permission.GYROSCOPE
5268
5269**System capability**: SystemCapability.Sensors.Sensor
5270
5271**Parameters**
5272
5273| Name     | Type                                                         | Mandatory | Description                                                  |
5274| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5275| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**. |
5276| 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**. |
5277
5278**Example**
5279
5280```js
5281function callback(data) {
5282    console.info('X-coordinate component: ' + data.x);
5283    console.info('Y-coordinate component: ' + data.y);
5284    console.info('Z-coordinate component: ' + data.z);
5285}
5286sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback);
5287
5288```
5289
5290### HALL<sup>(deprecated)</sup>
5291
5292off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt;): void
5293
5294Unsubscribes from sensor data changes.
5295
5296This API is deprecated since API version 9. You are advised to use [sensor.off.HALL](#hall9-2) instead.
5297
5298**System capability**: SystemCapability.Sensors.Sensor
5299
5300**Parameters**
5301
5302| Name     | Type                                          | Mandatory | Description                                                  |
5303| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
5304| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HALL**. |
5305| 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**. |
5306
5307**Example**
5308
5309```js
5310function callback(data) {
5311    console.info('Status: ' + data.status);
5312}
5313sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
5314
5315```
5316
5317### HEART_RATE<sup>(deprecated)</sup>
5318
5319off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void
5320
5321Unsubscribes from sensor data changes.
5322
5323This API is deprecated since API version 9. You are advised to use [sensor.off.HEART_RATE](#heart_rate9-2) instead.
5324
5325**Required permissions**: ohos.permission.HEALTH_DATA
5326
5327**System capability**: SystemCapability.Sensors.Sensor
5328
5329**Parameters**
5330
5331| Name     | Type                                                    | Mandatory | Description                                                  |
5332| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5333| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE     | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HEART_RATE**. |
5334| 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**. |
5335
5336### HUMIDITY<sup>(deprecated)</sup>
5337
5338off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
5339
5340Unsubscribes from sensor data changes.
5341
5342This API is deprecated since API version 9. You are advised to use [sensor.off.HUMIDITY](#humidity9-2) instead.
5343
5344**System capability**: SystemCapability.Sensors.Sensor
5345
5346**Parameters**
5347
5348| Name     | Type                                                  | Mandatory | Description                                                  |
5349| -------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
5350| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY     | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HUMIDITY**. |
5351| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | No        | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**. |
5352
5353**Example**
5354
5355```js
5356function callback(data) {
5357    console.info('Humidity: ' + data.humidity);
5358}
5359sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
5360
5361```
5362
5363### LINEAR_ACCELERATION<sup>(deprecated)</sup>
5364
5365off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void
5366
5367Unsubscribes from sensor data changes.
5368
5369This API is deprecated since API version 9. You are advised to use [sensor.off.LINEAR_ACCELEROMETER](#linear_accelerometer9-2) instead.
5370
5371**Required permissions**: ohos.permission.ACCELEROMETER
5372
5373**System capability**: SystemCapability.Sensors.Sensor
5374
5375**Parameters**
5376
5377| Name     | Type                                                         | Mandatory | Description                                                  |
5378| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5379| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**. |
5380| 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**. |
5381
5382### MAGNETIC_FIELD<sup>(deprecated)</sup>
5383
5384 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void
5385
5386Unsubscribes from sensor data changes.
5387
5388This API is deprecated since API version 9. You are advised to use [sensor.off.MAGNETIC_FIELD](#magnetic_field9-2) instead.
5389
5390**System capability**: SystemCapability.Sensors.Sensor
5391
5392**Parameters**
5393
5394| Name             | Type                                                         | Mandatory | Description                                                  |
5395| ---------------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5396| type             | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
5397| 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**. |
5398
5399**Example**
5400
5401```js
5402function callback(data) {
5403    console.info('X-coordinate component: ' + data.x);
5404    console.info('Y-coordinate component: ' + data.y);
5405    console.info('Z-coordinate component: ' + data.z);
5406}
5407sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
5408
5409```
5410
5411### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
5412
5413 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
5414
5415Unsubscribes from sensor data changes.
5416
5417This API is deprecated since API version 9. You are advised to use [sensor.off.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-2) instead.
5418
5419**System capability**: SystemCapability.Sensors.Sensor
5420
5421**Parameters**
5422
5423| Name     | Type                                                         | Mandatory | Description                                                  |
5424| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5425| 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**. |
5426| 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**. |
5427
5428**Example**
5429
5430```js
5431function callback(data) {
5432    console.info('X-coordinate component: ' + data.x);
5433    console.info('Y-coordinate component: ' + data.y);
5434    console.info('Z-coordinate component: ' + data.z);
5435    console.info('X-coordinate bias: ' + data.biasX);
5436    console.info('Y-coordinate bias: ' + data.biasY);
5437    console.info('Z-coordinate bias: ' + data.biasZ);
5438}
5439sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback);
5440
5441```
5442
5443### ORIENTATION<sup>(deprecated)</sup>
5444
5445 off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void
5446
5447Unsubscribes from sensor data changes.
5448
5449This API is deprecated since API version 9. You are advised to use [sensor.off.ORIENTATION](#orientation9-2) instead.
5450
5451**System capability**: SystemCapability.Sensors.Sensor
5452
5453**Parameters**
5454
5455| Name     | Type                                                        | Mandatory | Description                                                  |
5456| -------- | ----------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5457| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION        | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ORIENTATION**. |
5458| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | No        | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**. |
5459
5460**Example**
5461
5462```js
5463function callback(data) {
5464    console.info('The device rotates at an angle around the X axis: ' + data.beta);
5465    console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
5466    console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
5467}
5468sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
5469
5470```
5471
5472### PEDOMETER<sup>(deprecated)</sup>
5473
5474off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void
5475
5476Unsubscribes from sensor data changes.
5477
5478This API is deprecated since API version 9. You are advised to use [sensor.off.PEDOMETER](#pedometer9-2) instead.
5479
5480**Required permissions**: ohos.permission.ACTIVITY_MOTION
5481
5482**System capability**: SystemCapability.Sensors.Sensor
5483
5484**Parameters**
5485
5486| Name     | Type                                                    | Mandatory | Description                                                  |
5487| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5488| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. |
5489| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | No        | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**. |
5490
5491**Example**
5492
5493```js
5494function callback(data) {
5495    console.info('Steps: ' + data.steps);
5496}
5497sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
5498
5499```
5500
5501### PEDOMETER_DETECTION<sup>(deprecated)</sup>
5502
5503off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void
5504
5505Unsubscribes from sensor data changes.
5506
5507This API is deprecated since API version 9. You are advised to use [sensor.off.PEDOMETER_DETECTION](#pedometer_detection9-2) instead.
5508
5509**Required permissions**: ohos.permission.ACTIVITY_MOTION
5510
5511**System capability**: SystemCapability.Sensors.Sensor
5512
5513**Parameters**
5514
5515| Name     | Type                                                         | Mandatory | Description                                                  |
5516| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5517| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**. |
5518| 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**. |
5519
5520**Example**
5521
5522```js
5523function callback(data) {
5524    console.info('Scalar data: ' + data.scalar);
5525}
5526sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
5527
5528```
5529
5530### PROXIMITY<sup>(deprecated)</sup>
5531
5532off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void
5533
5534Unsubscribes from sensor data changes.
5535
5536This API is deprecated since API version 9. You are advised to use [sensor.off.PROXIMITY](#proximity9-2) instead.
5537
5538**System capability**: SystemCapability.Sensors.Sensor
5539
5540**Parameters**
5541
5542| Name     | Type                                                    | Mandatory | Description                                                  |
5543| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
5544| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PROXIMITY**. |
5545| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | No        | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**. |
5546
5547**Example**
5548
5549```js
5550function callback(data) {
5551    console.info('Distance: ' + data.distance);
5552}
5553sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
5554
5555```
5556
5557### ROTATION_VECTOR<sup>(deprecated)</sup>
5558
5559off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void
5560
5561Unsubscribes from sensor data changes.
5562
5563This API is deprecated since API version 9. You are advised to use [sensor.off.ROTATION_VECTOR](#rotation_vector9-2) instead.
5564
5565**System capability**: SystemCapability.Sensors.Sensor
5566
5567**Parameters**
5568
5569| Name     | Type                                                         | Mandatory | Description                                                  |
5570| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5571| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR     | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**. |
5572| 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**. |
5573
5574**Example**
5575
5576```js
5577function callback(data) {
5578    console.info('X-coordinate component: ' + data.x);
5579    console.info('Y-coordinate component: ' + data.y);
5580    console.info('Z-coordinate component: ' + data.z);
5581    console.info('Scalar quantity: ' + data.w);
5582}
5583sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
5584
5585```
5586
5587### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
5588
5589off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void
5590
5591Unsubscribes from sensor data changes.
5592
5593This API is deprecated since API version 9. You are advised to use [sensor.off.SIGNIFICANT_MOTION](#significant_motion9-2) instead.
5594
5595**System capability**: SystemCapability.Sensors.Sensor
5596
5597**Parameters**
5598
5599| Name     | Type                                                         | Mandatory | Description                                                  |
5600| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5601| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION  | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**. |
5602| 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**. |
5603
5604**Example**
5605
5606```js
5607function callback(data) {
5608    console.info('Scalar data: ' + data.scalar);
5609}
5610sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
5611
5612```
5613
5614### WEAR_DETECTION<sup>(deprecated)</sup>
5615
5616off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void
5617
5618Unsubscribes from sensor data changes.
5619
5620This API is deprecated since API version 9. You are advised to use [sensor.off.WEAR_DETECTION](#wear_detection9-2) instead.
5621
5622**System capability**: SystemCapability.Sensors.Sensor
5623
5624**Parameters**
5625
5626| Name     | Type                                                         | Mandatory | Description                                                  |
5627| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5628| type     | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION      | Yes       | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_WEAR_DETECTION**. |
5629| 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**. |
5630
5631**Example**
5632
5633```js
5634function accCallback(data) {
5635    console.info('Wear status: ' + data.value);
5636}
5637sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback);
5638
5639```
5640
5641## sensor.transformCoordinateSystem<sup>(deprecated)</sup>
5642
5643transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5644
5645Rotates a rotation vector so that it can represent the coordinate system in different ways. This API uses an asynchronous callback to return the result.
5646
5647This API is deprecated since API version 9. You are advised to use [sensor.transformRotationMatrix](#sensortransformrotationmatrix9) instead.
5648
5649**System capability**: SystemCapability.Sensors.Sensor
5650
5651**Parameters**
5652
5653| Name             | Type                                      | Mandatory | Description                                                  |
5654| ---------------- | ----------------------------------------- | --------- | ------------------------------------------------------------ |
5655| inRotationVector | Array&lt;number&gt;                       | Yes       | Rotation vector to rotate.                                   |
5656| coordinates      | [CoordinatesOptions](#coordinatesoptions) | Yes       | Direction of the coordinate system.                          |
5657| callback         | AsyncCallback&lt;Array&lt;number&gt;&gt;  | Yes       | Callback used to return the rotation vector after being rotated. |
5658
5659**Example**
5660
5661```js
5662sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
5663    if (err) {
5664        console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
5665        return;
5666    }
5667    console.info("Operation successed. Data obtained: " + data);
5668    for (var i=0; i < data.length; i++) {
5669        console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
5670    }
5671 })
5672
5673```
5674
5675## sensor.transformCoordinateSystem<sup>(deprecated)</sup>
5676
5677transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt;
5678
5679Rotates a rotation vector so that it can represent the coordinate system in different ways. This API uses a promise to return the result.
5680
5681This API is deprecated since API version 9. You are advised to use [sensor.transformRotationMatrix](#sensortransformrotationmatrix9-1) instead.
5682
5683**System capability**: SystemCapability.Sensors.Sensor
5684
5685**Parameters**
5686
5687| Name             | Type                                      | Mandatory | Description                         |
5688| ---------------- | ----------------------------------------- | --------- | ----------------------------------- |
5689| inRotationVector | Array&lt;number&gt;                       | Yes       | Rotation vector to rotate.          |
5690| coordinates      | [CoordinatesOptions](#coordinatesoptions) | Yes       | Direction of the coordinate system. |
5691
5692**Return value**
5693
5694| Type                               | Description                                                  |
5695| ---------------------------------- | ------------------------------------------------------------ |
5696| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation vector after being rotated. |
5697
5698**Example**
5699
5700```js
5701const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
5702    promise.then((data) => {
5703        console.info("Operation successed.");
5704        for (var i=0; i < data.length; i++) {
5705            console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
5706        }
5707    }).catch((err) => {
5708           console.info("Operation failed");
5709})
5710
5711```
5712
5713## sensor.getGeomagneticField<sup>(deprecated)</sup>
5714
5715getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback&lt;GeomagneticResponse&gt;): void
5716
5717Obtains the geomagnetic field of a geographic location. This API uses an asynchronous callback to return the result.
5718
5719This API is deprecated since API version 9. You are advised to use [sensor.getGeomagneticInfo](#sensorgetgeomagneticinfo9) instead.
5720
5721**System capability**: SystemCapability.Sensors.Sensor
5722
5723**Parameters**
5724
5725| Name            | Type                                                         | Mandatory | Description                                                  |
5726| --------------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
5727| locationOptions | [LocationOptions](#locationoptions)                          | Yes       | Geographic location.                                         |
5728| timeMillis      | number                                                       | Yes       | Time for obtaining the magnetic declination, in milliseconds. |
5729| callback        | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes       | Callback used to return the geomagnetic field.               |
5730
5731**Example**
5732
5733```js
5734sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data)  {
5735    if (err) {
5736        console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
5737        return;
5738    }
5739    console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
5740	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
5741		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
5742});
5743
5744```
5745
5746## sensor.getGeomagneticField<sup>(deprecated)</sup>
5747
5748getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt;
5749
5750Obtains the geomagnetic field of a geographic location. This API uses a promise to return the result.
5751
5752This API is deprecated since API version 9. You are advised to use [sensor.getGeomagneticInfo](#sensorgetgeomagneticinfo9-1) instead.
5753
5754**System capability**: SystemCapability.Sensors.Sensor
5755
5756**Parameters**
5757
5758| Name            | Type                                | Mandatory | Description                                                  |
5759| --------------- | ----------------------------------- | --------- | ------------------------------------------------------------ |
5760| locationOptions | [LocationOptions](#locationoptions) | Yes       | Geographic location.                                         |
5761| timeMillis      | number                              | Yes       | Time for obtaining the magnetic declination, in milliseconds. |
5762
5763**Return value**
5764
5765| Type                                                       | Description                                   |
5766| ---------------------------------------------------------- | --------------------------------------------- |
5767| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field. |
5768
5769**Example**
5770
5771  ```js
5772  const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
5773      promise.then((data) => {
5774          console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
5775  	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
5776  		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
5777      }).catch((reason) => {
5778          console.info('Operation failed.');
5779  })
5780
5781  ```
5782
5783## sensor.getAltitude<sup>(deprecated)</sup>
5784
5785getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback&lt;number&gt;): void
5786
5787Obtains 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.
5788
5789This API is deprecated since API version 9. You are advised to use [sensor.getDeviceAltitude](#sensorgetdevicealtitude9) instead.
5790
5791**System capability**: SystemCapability.Sensors.Sensor
5792
5793**Parameters**
5794
5795| Name            | Type                        | Mandatory | Description                                                  |
5796| --------------- | --------------------------- | --------- | ------------------------------------------------------------ |
5797| seaPressure     | number                      | Yes       | Sea-level atmospheric pressure, in hPa.                      |
5798| currentPressure | number                      | Yes       | Atmospheric pressure at the altitude where the device is located, in hPa. |
5799| callback        | AsyncCallback&lt;number&gt; | Yes       | Callback used to return the altitude, in meters.             |
5800
5801**Example**
5802
5803  ```js
5804  sensor.getAltitude(0, 200, function(err, data)  {
5805      if (err) {
5806          console.error(
5807  "Operation failed. Error code: " + err.code + ", message: " + err.message);
5808          return;
5809      }
5810          console.info("Successed to get getAltitude interface get data: " + data);
5811  });
5812
5813  ```
5814
5815## sensor.getAltitude<sup>(deprecated)</sup>
5816
5817getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
5818
5819Obtains 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.
5820
5821This API is deprecated since API version 9. You are advised to use [sensor.getDeviceAltitude](#sensorgetdevicealtitude9-1) instead.
5822
5823**System capability**: SystemCapability.Sensors.Sensor
5824
5825**Parameters**
5826
5827| Name            | Type   | Mandatory | Description                                                  |
5828| --------------- | ------ | --------- | ------------------------------------------------------------ |
5829| seaPressure     | number | Yes       | Sea-level atmospheric pressure, in hPa.                      |
5830| currentPressure | number | Yes       | Atmospheric pressure at the altitude where the device is located, in hPa. |
5831
5832**Return value**
5833
5834| Type                  | Description                                     |
5835| --------------------- | ----------------------------------------------- |
5836| Promise&lt;number&gt; | Promise used to return the altitude, in meters. |
5837
5838**Example**
5839
5840  ```js
5841  const promise = sensor.getAltitude(0, 200);
5842      promise.then((data) => {
5843          console.info(' sensor_getAltitude_Promise success', data);
5844      }).catch((err) => {
5845          console.error("Operation failed");
5846  })
5847
5848  ```
5849
5850
5851## sensor.getGeomagneticDip<sup>(deprecated)</sup>
5852
5853getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void
5854
5855Obtains the magnetic dip based on the inclination matrix. This API uses an asynchronous callback to return the result.
5856
5857This API is deprecated since API version 9. You are advised to use [sensor.getInclination](#sensorgetinclination9) instead.
5858
5859**System capability**: SystemCapability.Sensors.Sensor
5860
5861**Parameters**
5862
5863| Name              | Type                        | Mandatory | Description                                           |
5864| ----------------- | --------------------------- | --------- | ----------------------------------------------------- |
5865| inclinationMatrix | Array&lt;number&gt;         | Yes       | Inclination matrix.                                   |
5866| callback          | AsyncCallback&lt;number&gt; | Yes       | Callback used to return the magnetic dip, in radians. |
5867
5868**Example**
5869
5870  ```js
5871  sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
5872      if (err) {
5873          console.error('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' +
5874                        err.message);
5875          return;
5876      }
5877          console.info("Successed to get getGeomagneticDip interface get data: " + data);
5878  })
5879
5880  ```
5881
5882## sensor.getGeomagneticDip<sup>(deprecated)</sup>
5883
5884getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
5885
5886Obtains the magnetic dip based on the inclination matrix. This API uses a promise to return the result.
5887
5888This API is deprecated since API version 9. You are advised to use [sensor.getInclination](#sensorgetinclination9-1) instead.
5889
5890**System capability**: SystemCapability.Sensors.Sensor
5891
5892**Parameters**
5893
5894| Name              | Type                | Mandatory | Description         |
5895| ----------------- | ------------------- | --------- | ------------------- |
5896| inclinationMatrix | Array&lt;number&gt; | Yes       | Inclination matrix. |
5897
5898**Return value**
5899
5900| Type                  | Description                                          |
5901| --------------------- | ---------------------------------------------------- |
5902| Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians. |
5903
5904**Example**
5905
5906  ```js
5907  const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
5908      promise.then((data) => {
5909          console.info('getGeomagneticDip_promise successed', data);
5910      }).catch((err) => {
5911           console.error("Operation failed");
5912  })
5913
5914  ```
5915
5916## sensor. getAngleModify<sup>(deprecated)</sup>
5917
5918getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5919
5920Obtains the angle change between two rotation matrices. This API uses an asynchronous callback to return the result.
5921
5922This API is deprecated since API version 9. You are advised to use [sensor.getAngleVariation](#sensorgetanglevariation9) instead.
5923
5924**System capability**: SystemCapability.Sensors.Sensor
5925
5926**Parameters**
5927
5928| Name                  | Type                                     | Mandatory | Description                                                  |
5929| --------------------- | ---------------------------------------- | --------- | ------------------------------------------------------------ |
5930| currentRotationMatrix | Array&lt;number&gt;                      | Yes       | Current rotation matrix.                                     |
5931| preRotationMatrix     | Array&lt;number&gt;                      | Yes       | The other rotation matrix.                                   |
5932| callback              | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the angle change around the z, x, and y axes. |
5933
5934**Example**
5935
5936  ```js
5937  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)  {
5938      if (err) {
5939          console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
5940                        err.message);
5941          return;
5942      }
5943      for (var i=0; i < data.length; i++) {
5944          console.info("data[" + i + "]: " + data[i]);
5945      }
5946  })
5947
5948  ```
5949
5950
5951## sensor. getAngleModify<sup>(deprecated)</sup>
5952
5953getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
5954
5955Obtains the angle change between two rotation matrices. This API uses a promise to return the result.
5956
5957This API is deprecated since API version 9. You are advised to use [sensor.getAngleVariation](#sensorgetanglevariation9-1) instead.
5958
5959**System capability**: SystemCapability.Sensors.Sensor
5960
5961**Parameters**
5962
5963| Name                  | Type                | Mandatory | Description                |
5964| --------------------- | ------------------- | --------- | -------------------------- |
5965| currentRotationMatrix | Array&lt;number&gt; | Yes       | Current rotation matrix.   |
5966| preRotationMatrix     | Array&lt;number&gt; | Yes       | The other rotation matrix. |
5967
5968**Return value**
5969
5970| Type                               | Description                                                  |
5971| ---------------------------------- | ------------------------------------------------------------ |
5972| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes. |
5973
5974**Example**
5975
5976  ```js
5977  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]);
5978      promise.then((data) => {
5979          console.info('getAngleModifiy_promise success');
5980          for (var i=0; i < data.length; i++) {
5981              console.info("data[" + i + "]: " + data[i]);
5982          }
5983      }).catch((reason) => {
5984          console.info("promise::catch", reason);
5985  })
5986
5987  ```
5988
5989
5990## sensor.createRotationMatrix<sup>(deprecated)</sup>
5991
5992createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
5993
5994Converts a rotation vector into a rotation matrix. This API uses an asynchronous callback to return the result.
5995
5996This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9) instead.
5997
5998**System capability**: SystemCapability.Sensors.Sensor
5999
6000**Parameters**
6001
6002| Name           | Type                                     | Mandatory | Description                                  |
6003| -------------- | ---------------------------------------- | --------- | -------------------------------------------- |
6004| rotationVector | Array&lt;number&gt;                      | Yes       | Rotation vector to convert.                  |
6005| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the rotation matrix. |
6006
6007**Example**
6008
6009  ```js
6010  sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
6011      if (err) {
6012          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
6013                        err.message);
6014          return;
6015      }
6016      for (var i=0; i < data.length; i++) {
6017          console.info("data[" + i + "]: " + data[i]);
6018      }
6019  })
6020
6021  ```
6022
6023
6024## sensor.createRotationMatrix<sup>(deprecated)</sup>
6025
6026createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
6027
6028Converts a rotation vector into a rotation matrix. This API uses a promise to return the result.
6029
6030This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9-1) instead.
6031
6032**System capability**: SystemCapability.Sensors.Sensor
6033
6034**Parameters**
6035
6036| Name           | Type                | Mandatory | Description                 |
6037| -------------- | ------------------- | --------- | --------------------------- |
6038| rotationVector | Array&lt;number&gt; | Yes       | Rotation vector to convert. |
6039
6040**Return value**
6041
6042| Type                               | Description                                 |
6043| ---------------------------------- | ------------------------------------------- |
6044| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix. |
6045
6046**Example**
6047
6048  ```js
6049  const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
6050      promise.then((data) => {
6051          console.info('createRotationMatrix_promise success');
6052          for (var i=0; i < data.length; i++) {
6053              console.info("data[" + i + "]: " + data[i]);
6054          }
6055      }).catch((reason) => {
6056          console.info("promise::catch", reason);
6057  })
6058
6059  ```
6060
6061
6062## sensor.createQuaternion<sup>(deprecated)</sup>
6063
6064createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
6065
6066Converts a rotation vector into a quaternion. This API uses an asynchronous callback to return the result.
6067
6068This API is deprecated since API version 9. You are advised to use [sensor.getQuaternion](#sensorgetquaternion9) instead.
6069
6070**System capability**: SystemCapability.Sensors.Sensor
6071
6072**Parameters**
6073
6074| Name           | Type                                     | Mandatory | Description                             |
6075| -------------- | ---------------------------------------- | --------- | --------------------------------------- |
6076| rotationVector | Array&lt;number&gt;                      | Yes       | Rotation vector to convert.             |
6077| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the quaternion. |
6078
6079**Example**
6080
6081  ```js
6082  sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data)  {
6083      if (err) {
6084          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
6085                        err.message);
6086          return;
6087      }
6088      for (var i=0; i < data.length; i++) {
6089          console.info("data[" + i + "]: " + data[i]);
6090      }
6091  })
6092
6093  ```
6094
6095
6096## sensor.createQuaternion<sup>(deprecated)</sup>
6097
6098createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
6099
6100Converts a rotation vector into a quaternion. This API uses a promise to return the result.
6101
6102This API is deprecated since API version 9. You are advised to use [sensor.getQuaternion](#sensorgetquaternion9-1) instead.
6103
6104**System capability**: SystemCapability.Sensors.Sensor
6105
6106**Parameters**
6107
6108| Name           | Type                | Mandatory | Description                 |
6109| -------------- | ------------------- | --------- | --------------------------- |
6110| rotationVector | Array&lt;number&gt; | Yes       | Rotation vector to convert. |
6111
6112**Return value**
6113
6114| Type                               | Description                            |
6115| ---------------------------------- | -------------------------------------- |
6116| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion. |
6117
6118**Example**
6119
6120  ```js
6121  const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
6122      promise.then((data) => {
6123          console.info('createQuaternion_promise successed');
6124          for (var i=0; i < data.length; i++) {
6125              console.info("data[" + i + "]: " + data[i]);
6126          }
6127      }).catch((err) => {
6128          console.info('promise failed');
6129  })
6130
6131  ```
6132
6133
6134## sensor.getDirection<sup>(deprecated)</sup>
6135
6136getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
6137
6138Obtains the device direction based on the rotation matrix. This API uses an asynchronous callback to return the result.
6139
6140This API is deprecated since API version 9. You are advised to use [sensor.getOrientation](#sensorgetorientation9) instead.
6141
6142**System capability**: SystemCapability.Sensors.Sensor
6143
6144**Parameters**
6145
6146| Name           | Type                                     | Mandatory | Description                                                  |
6147| -------------- | ---------------------------------------- | --------- | ------------------------------------------------------------ |
6148| rotationMatrix | Array&lt;number&gt;                      | Yes       | Rotation matrix.                                             |
6149| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes       | Callback used to return the rotation angle around the z, x, and y axes. |
6150
6151**Example**
6152
6153  ```js
6154  sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
6155      if (err) {
6156          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
6157                        err.message);
6158          return;
6159      }
6160      console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data);
6161      for (var i = 1; i < data.length; i++) {
6162          console.info("sensor_getDirection_callback" + data[i]);
6163      }
6164  })
6165
6166  ```
6167
6168
6169## sensor.getDirection<sup>(deprecated)</sup>
6170
6171getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
6172
6173Obtains the device direction based on the rotation matrix. This API uses a promise to return the result.
6174
6175This API is deprecated since API version 9. You are advised to use [sensor.getOrientation](#sensorgetorientation9-1) instead.
6176
6177**System capability**: SystemCapability.Sensors.Sensor
6178
6179**Parameters**
6180
6181| Name           | Type                | Mandatory | Description      |
6182| -------------- | ------------------- | --------- | ---------------- |
6183| rotationMatrix | Array&lt;number&gt; | Yes       | Rotation matrix. |
6184
6185**Return value**
6186
6187| Type                               | Description                                                  |
6188| ---------------------------------- | ------------------------------------------------------------ |
6189| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes. |
6190
6191**Example**
6192
6193  ```js
6194  const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
6195      promise.then((data) => {
6196          console.info('sensor_getAltitude_Promise success', data);
6197          for (var i = 1; i < data.length; i++) {
6198              console.info("sensor_getDirection_promise" + data[i]);
6199          }
6200      }).catch((err) => {
6201          console.info('promise failed');
6202  })
6203  ```
6204
6205
6206## sensor.createRotationMatrix<sup>(deprecated)</sup>
6207
6208createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;, callback: AsyncCallback&lt;RotationMatrixResponse&gt;): void
6209
6210Creates a rotation matrix based on the gravity vector and geomagnetic vector. This API uses an asynchronous callback to return the result.
6211
6212This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9-2) instead.
6213
6214**System capability**: SystemCapability.Sensors.Sensor
6215
6216**Parameters**
6217
6218| Name        | Type                                                         | Mandatory | Description                                  |
6219| ----------- | ------------------------------------------------------------ | --------- | -------------------------------------------- |
6220| gravity     | Array&lt;number&gt;                                          | Yes       | Gravity vector.                              |
6221| geomagnetic | Array&lt;number&gt;                                          | Yes       | Geomagnetic vector.                          |
6222| callback    | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes       | Callback used to return the rotation matrix. |
6223
6224**Example**
6225
6226  ```js
6227  sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data)  {
6228      if (err) {
6229          console.error('error code is: ' + err.code + ', message: ' + err.message);
6230          return;
6231      }
6232      console.info(JSON.stringify(data));
6233  })
6234  ```
6235
6236
6237## sensor.createRotationMatrix<sup>(deprecated)</sup>
6238
6239createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;,): Promise&lt;RotationMatrixResponse&gt;
6240
6241Creates a rotation matrix based on the gravity vector and geomagnetic vector. This API uses a promise to return the result.
6242
6243This API is deprecated since API version 9. You are advised to use [sensor.getRotationMatrix](#sensorgetrotationmatrix9-3) instead.
6244
6245**System capability**: SystemCapability.Sensors.Sensor
6246
6247**Parameters**
6248
6249| Name        | Type                | Mandatory | Description         |
6250| ----------- | ------------------- | --------- | ------------------- |
6251| gravity     | Array&lt;number&gt; | Yes       | Gravity vector.     |
6252| geomagnetic | Array&lt;number&gt; | Yes       | Geomagnetic vector. |
6253
6254**Return value**
6255
6256| Type                                                         | Description                                 |
6257| ------------------------------------------------------------ | ------------------------------------------- |
6258| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix. |
6259
6260**Example**
6261
6262  ```js
6263  const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
6264      promise.then((data) => {
6265          console.info(JSON.stringify(data));
6266      }).catch((err) => {
6267          console.info('promise failed');
6268  })
6269  ```