Skip to content

Commit e771c95

Browse files
committed
Enable shutdown mode of fuel gauge
1 parent 1d6b39b commit e771c95

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Diff for: examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino

+15-9
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,20 @@
3333
*/
3434

3535
#include "Arduino_PowerManagement.h"
36+
#include "MAX1726Driver.h"
3637

37-
Board board;
38+
Board board;
39+
Charger charger;
40+
MAX1726Driver fuelgauge(&Wire1);
3841

3942
void setup() {
40-
board = Board();
41-
4243
// When uploading this sketch to the M4 core, it just goes to standby mode.
4344
#if defined(ARDUINO_GENERIC_STM32H747_M4)
4445
board.standByUntilWakeupEvent();
4546
return;
4647
#endif
48+
49+
charger.begin();
4750

4851
// Turn off the built-in LED
4952
pinMode(LED_BUILTIN, OUTPUT);
@@ -64,14 +67,17 @@ void setup() {
6467
}
6568
}
6669

70+
charger.setEnabled(false); // -> Please measure if it makes a difference
71+
delay(10000); // -> Give time to take the measurement
6772

68-
board.enableWakeupFromRTC(0, 0, 10); // Sleep for 10 seconds
69-
73+
// Takes 45s to get into shutdown mode
74+
fuelgauge.setOperationMode(FuelGaugeOperationMode::shutdown);
75+
7076
// The LED should go off when the board goes to sleep
71-
board.setAllPeripheralsPower(false);
77+
board.setAllPeripheralsPower(false);
78+
79+
board.enableWakeupFromRTC(0, 0, 60); // Go to standby for 60 seconds
7280
board.standByUntilWakeupEvent();
7381
}
7482

75-
void loop() {
76-
// put your main code here, to run repeatedly:
77-
}
83+
void loop() {}

Diff for: src/BatteryConstants.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
#define E_DET_BIT 8 // FStat Register: Empty Detection. This bit is set to 1 when the IC detects that the cell empty point has been reached. This bit is reset to 0 when the cell voltage rises above the recovery threshold.
105105
#define FULL_DET_BIT 5 // Status2 Register: Full Detection.
106106
#define FQ_BIT 7 // FStat Register: Full Qualified. This bit is set when all charge termination conditions have been met. See the End-of-Charge Detection section for details.
107-
#define EN_HIBERNATION_BIT 15
107+
#define EN_HIBERNATION_BIT 15 // HibCfg Register: Enable Hibernate Mode. When set to 1, the IC will enter hibernate mode if conditions are met. When set to 0, the IC always remains in the active mode of operation.
108+
#define SHDN_BIT 7 // Config Register: Write this bit to logic 1 to force a shutdown of the device after timeout of the ShdnTimer register
108109
#define HIB_BIT 1 // Hibernate Status. This bit is set to a 1 when the device is in hibernate mode or 0 when the device is in active mode. Hib is set to 0 at power-up.
109110
#define R100_BIT 13 // The R100 bit needs to be set when using a 100k NTC resistor
110111
#define VCHG_BIT 10 // Set to 1 for charge voltage higher than 4.25V (4.3V–4.4V). Set VChg to 0 for 4.2V charge voltage.

0 commit comments

Comments
 (0)