Skip to content

Commit

Permalink
safer and more practical battery low power cutoff values #121
Browse files Browse the repository at this point in the history
  • Loading branch information
lmarzen committed Aug 25, 2024
1 parent 5ed07d2 commit bf0b556
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion platformio/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,14 @@ extern const long SLEEP_DURATION;
extern const int BED_TIME;
extern const int WAKE_TIME;
extern const int HOURLY_GRAPH_MAX;
extern const uint32_t MAX_BATTERY_VOLTAGE;
extern const uint32_t WARN_BATTERY_VOLTAGE;
extern const uint32_t LOW_BATTERY_VOLTAGE;
extern const uint32_t VERY_LOW_BATTERY_VOLTAGE;
extern const uint32_t CRIT_LOW_BATTERY_VOLTAGE;
extern const unsigned long LOW_BATTERY_SLEEP_INTERVAL;
extern const unsigned long VERY_LOW_BATTERY_SLEEP_INTERVAL;
extern const uint32_t MAX_BATTERY_VOLTAGE;
extern const uint32_t MIN_BATTERY_VOLTAGE;

// CONFIG VALIDATION - DO NOT MODIFY
#if !( defined(DISP_BW_V2) \
Expand Down
12 changes: 7 additions & 5 deletions platformio/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ const int HOURLY_GRAPH_MAX = 24;
// minutes). Once the battery voltage has fallen to CRIT_LOW_BATTERY_VOLTAGE,
// the esp32 will hibernate and a manual press of the reset (RST) button to
// begin operating again.
const uint32_t MAX_BATTERY_VOLTAGE = 4200; // (millivolts)
const uint32_t WARN_BATTERY_VOLTAGE = 3400; // (millivolts)
const uint32_t LOW_BATTERY_VOLTAGE = 3200; // (millivolts)
const uint32_t VERY_LOW_BATTERY_VOLTAGE = 3100; // (millivolts)
const uint32_t CRIT_LOW_BATTERY_VOLTAGE = 3000; // (millivolts)
const uint32_t WARN_BATTERY_VOLTAGE = 3535; // (millivolts) ~20%
const uint32_t LOW_BATTERY_VOLTAGE = 3462; // (millivolts) ~10%
const uint32_t VERY_LOW_BATTERY_VOLTAGE = 3442; // (millivolts) ~8%
const uint32_t CRIT_LOW_BATTERY_VOLTAGE = 3404; // (millivolts) ~5%
const unsigned long LOW_BATTERY_SLEEP_INTERVAL = 30; // (minutes)
const unsigned long VERY_LOW_BATTERY_SLEEP_INTERVAL = 120; // (minutes)
// Battery voltage calculations are based on a typical 3.7v LiPo.
const uint32_t MAX_BATTERY_VOLTAGE = 4200; // (millivolts)
const uint32_t MIN_BATTERY_VOLTAGE = 3000; // (millivolts)

// See config.h for the below options
// E-PAPER PANEL
Expand Down
4 changes: 2 additions & 2 deletions platformio/src/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,9 @@ void drawStatusBar(const String &statusStr, const String &refreshTimeStr,
const int sp = 2;

#if BATTERY_MONITORING
// battery
// battery - (expecting 3.7v LiPo)
uint32_t batPercent = calcBatPercent(batVoltage,
CRIT_LOW_BATTERY_VOLTAGE,
MIN_BATTERY_VOLTAGE,
MAX_BATTERY_VOLTAGE);
#if defined(DISP_3C_B) || defined(DISP_7C_F)
if (batVoltage < WARN_BATTERY_VOLTAGE)
Expand Down

0 comments on commit bf0b556

Please sign in to comment.