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