1e41f4b71Sopenharmony_ci# @ohos.batteryInfo (Battery Information)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **batteryInfo** module provides APIs for querying the charger type, battery health status, and battery charging status.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```js
13e41f4b71Sopenharmony_ciimport {batteryInfo} from '@kit.BasicServicesKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## batteryInfo
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciDescribes battery information.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Core
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| Name     | Type       | Readable| Writable|  Description    |
23e41f4b71Sopenharmony_ci| --------------- | ------------------- | ---- | ---- | ---------------------|
24e41f4b71Sopenharmony_ci| batterySOC                                | number                                         | Yes  | No  | Battery state of charge (SoC) of the device, in unit of percentage.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                          |
25e41f4b71Sopenharmony_ci| chargingStatus                            | [BatteryChargeState](#batterychargestate)      | Yes  | No  | Battery charging state of the current device.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                              |
26e41f4b71Sopenharmony_ci| healthStatus                              | [BatteryHealthState](#batteryhealthstate)      | Yes  | No  | Battery health status of the device.                              |
27e41f4b71Sopenharmony_ci| pluggedType                               | [BatteryPluggedType](#batterypluggedtype)      | Yes  | No  | Charger type of the device.                            |
28e41f4b71Sopenharmony_ci| voltage                                   | number                                         | Yes  | No  | Battery voltage of the device, in unit of microvolt.                        |
29e41f4b71Sopenharmony_ci| technology                                | string                                         | Yes  | No  | Battery technology of the device.                              |
30e41f4b71Sopenharmony_ci| batteryTemperature                        | number                                         | Yes  | No  | Battery temperature of the device, in unit of 0.1°C.                   |
31e41f4b71Sopenharmony_ci| isBatteryPresent<sup>7+</sup>             | boolean                                        | Yes  | No  | Whether the battery is supported or present.                |
32e41f4b71Sopenharmony_ci| batteryCapacityLevel<sup>9+</sup>         | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes  | No  | Battery level of the device.                                                 
33e41f4b71Sopenharmony_ci| nowCurrent<sup>12+</sup>                  | number                                         | Yes  | No  | Battery current of the device, in unit of mA.                       |         
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**Example**
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci  ```ts
38e41f4b71Sopenharmony_ci  import {batteryInfo} from '@kit.BasicServicesKit';
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci  let batterySOCInfo: number = batteryInfo.batterySOC;
41e41f4b71Sopenharmony_ci  console.info("The batterySOCInfo is: " + batterySOCInfo);
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci  let chargingStatusInfo = batteryInfo.chargingStatus;
44e41f4b71Sopenharmony_ci  console.info("The chargingStatusInfo is: " + chargingStatusInfo);
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci  let healthStatusInfo = batteryInfo.healthStatus;
47e41f4b71Sopenharmony_ci  console.info("The healthStatusInfo is: " + healthStatusInfo);
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci  let pluggedTypeInfo = batteryInfo.pluggedType;
50e41f4b71Sopenharmony_ci  console.info("The pluggedTypeInfo is: " + pluggedTypeInfo);
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci  let voltageInfo: number = batteryInfo.voltage;
53e41f4b71Sopenharmony_ci  console.info("The voltageInfo is: " + voltageInfo);
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci  let technologyInfo: string = batteryInfo.technology;
56e41f4b71Sopenharmony_ci  console.info("The technologyInfo is: " + technologyInfo);
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci  let batteryTemperatureInfo: number = batteryInfo.batteryTemperature;
59e41f4b71Sopenharmony_ci  console.info("The batteryTemperatureInfo is: " + batteryTemperatureInfo);
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci  let isBatteryPresentInfo: boolean = batteryInfo.isBatteryPresent;
62e41f4b71Sopenharmony_ci  console.info("The isBatteryPresentInfo is: " + isBatteryPresentInfo);
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci  let batteryCapacityLevelInfo = batteryInfo.batteryCapacityLevel;
65e41f4b71Sopenharmony_ci  console.info("The batteryCapacityLevelInfo is: " + batteryCapacityLevelInfo);
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci  let nowCurrentInfo: number = batteryInfo.nowCurrent;
68e41f4b71Sopenharmony_ci  console.info("The nowCurrentInfo is: " + nowCurrentInfo);
69e41f4b71Sopenharmony_ci  ```
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci## BatteryPluggedType
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ciEnumerates charger types.
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Core
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci| Name      | Value | Description             |
78e41f4b71Sopenharmony_ci| -------- | ---- | ----------------- |
79e41f4b71Sopenharmony_ci| NONE     | 0    | Unknown charger type.     |
80e41f4b71Sopenharmony_ci| AC       | 1    | AC charger.|
81e41f4b71Sopenharmony_ci| USB      | 2    | USB charger.  |
82e41f4b71Sopenharmony_ci| WIRELESS | 3    | Wireless charger.|
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci## BatteryChargeState
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ciEnumerates charging states.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Core
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| Name     | Value | Description           |
93e41f4b71Sopenharmony_ci| ------- | ---- | --------------- |
94e41f4b71Sopenharmony_ci| NONE    | 0    | Unknown state.    |
95e41f4b71Sopenharmony_ci| ENABLE  | 1    | The battery is being charged. |
96e41f4b71Sopenharmony_ci| DISABLE | 2    | The battery is not being charged. |
97e41f4b71Sopenharmony_ci| FULL    | 3    | The battery is fully charged.|
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci## BatteryHealthState
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ciEnumerates battery health states.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Core
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci| Name         | Value | Description          |
106e41f4b71Sopenharmony_ci| ----------- | ---- | -------------- |
107e41f4b71Sopenharmony_ci| UNKNOWN     | 0    | Unknown state.   |
108e41f4b71Sopenharmony_ci| GOOD        | 1    | The battery is in the healthy state.  |
109e41f4b71Sopenharmony_ci| OVERHEAT    | 2    | The battery is overheated.  |
110e41f4b71Sopenharmony_ci| OVERVOLTAGE | 3    | The battery voltage is over high.  |
111e41f4b71Sopenharmony_ci| COLD        | 4    | The battery temperature is low.  |
112e41f4b71Sopenharmony_ci| DEAD        | 5    | The battery is dead.|
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci## BatteryCapacityLevel<sup>9+</sup>
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ciEnumerates battery levels.
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Core
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| Name          | Value| Description                      |
121e41f4b71Sopenharmony_ci| -------------- | ------ | ---------------------------- |
122e41f4b71Sopenharmony_ci| LEVEL_FULL     | 1      | Full battery level.  |
123e41f4b71Sopenharmony_ci| LEVEL_HIGH     | 2      | High battery level.  |
124e41f4b71Sopenharmony_ci| LEVEL_NORMAL   | 3      | Normal battery level.|
125e41f4b71Sopenharmony_ci| LEVEL_LOW      | 4      | Low battery level.  |
126e41f4b71Sopenharmony_ci| LEVEL_WARNING  | 5      | Alarm battery level.|
127e41f4b71Sopenharmony_ci| LEVEL_CRITICAL | 6      | Ultra-low battery level.|
128e41f4b71Sopenharmony_ci| LEVEL_SHUTDOWN | 7      | Power-down battery level.|
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci## CommonEventBatteryChangedKey<sup>9+</sup>
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ciEnumerates keys for querying the additional information about the **COMMON_EVENT_BATTERY_CHANGED** event.
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Core
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci| Name                | Value| Description                                            |
137e41f4b71Sopenharmony_ci| -------------------- | ------ | -------------------------------------------------- |
138e41f4b71Sopenharmony_ci| EXTRA_SOC            | "soc" | Remaining battery level in percentage.                  |
139e41f4b71Sopenharmony_ci| EXTRA_CHARGE_STATE   | "chargeState" | Battery charging status of the device.                |
140e41f4b71Sopenharmony_ci| EXTRA_HEALTH_STATE   | "healthState" | Battery health status of the device.                |
141e41f4b71Sopenharmony_ci| EXTRA_PLUGGED_TYPE   | "pluggedType" | Type of the charger connected to the device.            |
142e41f4b71Sopenharmony_ci| EXTRA_VOLTAGE        | "voltage" | Battery voltage of the device.                    |
143e41f4b71Sopenharmony_ci| EXTRA_TECHNOLOGY     | "technology" | Battery technology of the device.                |
144e41f4b71Sopenharmony_ci| EXTRA_TEMPERATURE    | "temperature" | Battery temperature of the device.                    |
145e41f4b71Sopenharmony_ci| EXTRA_PRESENT        | "present" | Whether the battery is supported by the device or installed.|
146e41f4b71Sopenharmony_ci| EXTRA_CAPACITY_LEVEL | "capacityLevel" | Battery level of the device.                |
147