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