Skip to content

Commit 9b2b0b7

Browse files
Update README.md to reflect updates in battery class
1 parent 70b2666 commit 9b2b0b7

File tree

1 file changed

+62
-26
lines changed

1 file changed

+62
-26
lines changed

Diff for: docs/README.md

+62-26
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,86 @@
77
#include <vector>
88
#include <string>
99

10-
PowerManagement manager = PowerManagement();
1110
Battery battery;
12-
Board board;
1311
Charger charger;
12+
Board board;
1413

1514
void setup(){
16-
manager.begin();
17-
battery = manager.getBattery();
18-
board = manager.getBoard();
19-
charger = manager.getCharger();
20-
15+
battery.begin();
16+
charger.begin();
17+
board.begin();
2118
/* Rest of your setup() code */
2219
}
2320
```
2421

2522

2623
## Battery
27-
The battery object contains methods to read battery usage and health metrics. You can get current and average values for voltage, percentage, current and time as well as an estimated of the time left to charge completely and time left to discharge.
24+
The Battery class in the PowerManagement library provides a comprehensive set of tools for monitoring and managing the health and usage of your battery. This includes real-time data on voltage, current, power, temperature, and overall battery capacity, enabling you to optimize your application for better energy efficiency and battery longevity.
2825

29-
```cpp
30-
Serial.print("* Voltage: ");
31-
Serial.println(String(battery.readVoltageAvg()) + "mV");
26+
### Voltage Monitoring
27+
28+
| Method | Data Type | Description |
29+
|:-------------------------|:------------|:-------------------------------------------------|
30+
| battery.voltage() | float | Read the current voltage of the battery. |
31+
| battery.averageVoltage() | float | Get the average voltage. |
32+
| battery.minimumVoltage() | float | Access the minimum voltage since the last reset. |
33+
| battery.maximumVoltage() | float | Access the maximum voltage since the last reset. |
34+
35+
### Current Monitoring
36+
37+
| Method | Data Type | Description |
38+
|:-------------------------|:------------|:-------------------------------------------------|
39+
| battery.current() | int16_t | Measure the current flow from the battery. |
40+
| battery.averageCurrent() | int16_t | Obtain the average current. |
41+
| battery.minimumCurrent() | int16_t | Access the minimum current since the last reset. |
42+
| battery.maximumCurrent() | int16_t | Access the maximum current since the last reset. |
3243

33-
Serial.print("* Current: ");
34-
Serial.println(String(battery.readCurrent()) + "mA");
44+
### Power Monitoring
3545

36-
Serial.print("* Percentage: ");
37-
Serial.println(String(battery.readPercentage()) + "%");
46+
| Method | Data Type | Description |
47+
|:-----------------------|:------------|:------------------------------------------------------|
48+
| battery.power() | int16_t | Calculate the current power usage in milliwatts (mW). |
49+
| battery.averagePower() | int16_t | Get the average power usage in milliwatts (mW). |
3850

39-
Serial.print("* Remaining Capacity: ");
40-
Serial.println(String(battery.readRemainingCapacity()) + "mAh");
51+
### Temperature Monitoring
4152

42-
Serial.print("* Temperature: ");
43-
Serial.println(String(battery.readTempAvg()));
53+
| Method | Data Type | Description |
54+
|:-------------------------------------|:------------|:---------------------------------------------------------|
55+
| battery.internalTemperature() | uint8_t | Read the internal temperature of the battery gauge chip. |
56+
| battery.averageInternalTemperature() | uint8_t | Obtain the average internal temperature. |
4457

45-
Serial.print("* Time-to-full: ");
46-
Serial.println(String(battery.readTimeToFull()) + "s");
58+
### Capacity and State of Charge
4759

48-
Serial.print("* Time-to-empty: ");
49-
Serial.println(String(battery.readTimeToEmpty()) + "s");
60+
| Method | Data Type | Description |
61+
|:----------------------------|:------------|:------------------------------------------------------------|
62+
| battery.remainingCapacity() | uint16_t | Monitor the battery's remaining capacity in mAh. |
63+
| battery.percentage() | uint8_t | Get the battery's state of charge as a percentage (0-100%). |
5064

65+
### Time Estimates
66+
67+
| Method | Data Type | Description |
68+
|:----------------------|:------------|:------------------------------------------------------|
69+
| battery.timeToEmpty() | int32_t | Estimate the time until the battery is empty. |
70+
| battery.timeToFull() | int32_t | Estimate the time until the battery is fully charged. |
71+
72+
### Configuring Battery Characteristics
73+
74+
To ensure accurate readings and effective battery management, you can configure the `BatteryCharacteristics` struct to match the specific attributes of your battery:
75+
76+
```cpp
77+
BatteryCharacteristics characteristics = BatteryCharacteristics();
78+
79+
characteristics.capacity = 200; // Set the battery's capacity in mAh
80+
characteristics.emptyVoltage = 3.3f; // Voltage at which the battery is considered empty
81+
characteristics.chargeVoltage = 4.2f; // Voltage at which the battery is charged
82+
characteristics.endOfChargeCurrent = 50; // End of charge current in mA
83+
characteristics.ntcResistor = NTCResistor::Resistor10K; // Set NTC resistor value (10K or 100K Ohm)
84+
characteristics.recoveryVoltage = 3.88f; // Voltage to reset empty detection
5185
```
5286

87+
This configuration ensures that the Battery class operates with parameters that match your battery’s specifications, providing more accurate and reliable monitoring and management.
88+
89+
5390
## Charger
5491
Charging a LiPo battery is done in three stages. This library allows you to monitor what charging stage we are in as well as control some of the chagring parameters.
5592

@@ -250,9 +287,8 @@ Here's an overview of the reduction in power usage that you can expect from this
250287
![](https://raw.githubusercontent.com/arduino-libraries/Arduino_LowPowerPortentaC33/main/docs/assets/deep_sleep_peripherals_on.png)
251288

252289

253-
254-
### Portenta H7/Nicla Vison Low Power
255-
When utilizing Mbed with STM32-based microcontrollers such as the Portenta H7 and Nicla Vision, the approach to managing sleep modes exhibits some unique characteristics. Mbed is designed to transition the board to a sleep-like state—akin to the Sleep Mode found on the Portenta C33—whenever the system is not actively processing tasks. This energy-saving feature can be activated by invoking the `board.enableSleepWhenIdle()` method within your code.
290+
### Portenta H7 Low Power
291+
When utilizing Mbed with STM32-based microcontrollers such as the Portenta H7, the approach to managing sleep modes exhibits some unique characteristics. Mbed is designed to transition the board to a sleep-like state—akin to the Sleep Mode found on the Portenta C33—whenever the system is not actively processing tasks. This energy-saving feature can be activated by invoking the `board.enableSleepWhenIdle()` method within your code.
256292

257293
However, initiating this command doesn't guarantee automatic entry into sleep mode due to the presence of Sleep Locks. These locks act as safeguards, preventing the system from sleeping under certain conditions to ensure ongoing operations remain uninterrupted. Common peripherals, such as the USB Stack, may engage a sleep lock, effectively keeping the board awake even during periods of apparent inactivity. This behavior underscores how the effectiveness of sleep mode is closely linked to the specific operations and configurations defined in your sketch.
258294

0 commit comments

Comments
 (0)