Skip to content

Commit

Permalink
Enable shutdown mode of fuel gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed May 10, 2024
1 parent 1d6b39b commit ef544d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 16 additions & 9 deletions examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@
*/

#include "Arduino_PowerManagement.h"
#include "MAX1726Driver.h"

Board board;
Board board;
Charger charger;
MAX1726Driver fuelgauge(&Wire1);

void setup() {
board = Board();

// When uploading this sketch to the M4 core, it just goes to standby mode.
#if defined(ARDUINO_GENERIC_STM32H747_M4)
board.standByUntilWakeupEvent();
return;
#endif

charger = Charger();
charger.begin();

// Turn off the built-in LED
pinMode(LED_BUILTIN, OUTPUT);
Expand All @@ -64,14 +68,17 @@ void setup() {
}
}

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

board.enableWakeupFromRTC(0, 0, 10); // Sleep for 10 seconds

// Takes 45s to get into shutdown mode
fuelgauge.setOperationMode(FuelGaugeOperationMode::shutdown);

// The LED should go off when the board goes to sleep
board.setAllPeripheralsPower(false);
board.setAllPeripheralsPower(false);

board.enableWakeupFromRTC(0, 0, 60); // Go to standby for 60 seconds
board.standByUntilWakeupEvent();
}

void loop() {
// put your main code here, to run repeatedly:
}
void loop() {}
3 changes: 2 additions & 1 deletion src/BatteryConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
#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.
#define FULL_DET_BIT 5 // Status2 Register: Full Detection.
#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.
#define EN_HIBERNATION_BIT 15
#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.
#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
#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.
#define R100_BIT 13 // The R100 bit needs to be set when using a 100k NTC resistor
#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.
Expand Down

0 comments on commit ef544d3

Please sign in to comment.