From 4eb30ac24555ffc0176e24dcdcddf2e22f2e8b60 Mon Sep 17 00:00:00 2001 From: Token Date: Fri, 6 Sep 2024 14:49:05 +0200 Subject: [PATCH 1/9] Fix: Battery voltage reading It seems to be off. Trying to make it a bit more robust and the badge go less into soft_brownout_detection if it is not really needed. --- lib/EFBoard/EFBoard.cpp | 19 ++++++++++++++++++- lib/EFBoard/EFBoard.h | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/EFBoard/EFBoard.cpp b/lib/EFBoard/EFBoard.cpp index cf94ae1..2f11a51 100644 --- a/lib/EFBoard/EFBoard.cpp +++ b/lib/EFBoard/EFBoard.cpp @@ -139,6 +139,8 @@ const char *EFBoardClass::getWakeupReason() { const float EFBoardClass::getBatteryVoltage() { // voltageBattery = adcValue * voltPerADCStep * voltageDividerRatio + // adc_cal_raw_to_voltage + // esp_adc_cal_raw_to_voltage(analogRead(EFBOARD_PIN_VBAT)); return (analogRead(EFBOARD_PIN_VBAT) * (3.3 / 4095.0)) * ((51.1 + 100.0) / 100.0); } @@ -169,7 +171,22 @@ const EFBoardPowerState EFBoardClass::updatePowerState() { if (!this->isBatteryPowered()) { this->power_state = EFBoardPowerState::USB; } else { - const float vbat = this->getBatteryVoltage(); + float vbat = this->getBatteryVoltage(); + + // if (vbat <= EFBOARD_BROWN_OUT_SOFT) { + // // A low-battery state could be a momentary spike that we can handle and do not need to shut off + // // We take the highest of three measurements to make sure + // delay(10); + // float newVbat = this->getBatteryVoltage(); + // vbat = newVbat > vbat ? newVbat : vbat; + // delay(10); + // newVbat = this->getBatteryVoltage(); + // vbat = newVbat > vbat ? newVbat : vbat; + // delay(10); + // newVbat = this->getBatteryVoltage(); + // vbat = newVbat > vbat ? newVbat : vbat; + // } + if (vbat <= EFBOARD_BROWN_OUT_HARD || this->power_state == EFBoardPowerState::BAT_BROWN_OUT_HARD) { this->power_state = EFBoardPowerState::BAT_BROWN_OUT_HARD; } else if (vbat <= EFBOARD_BROWN_OUT_SOFT || this->power_state == EFBoardPowerState::BAT_BROWN_OUT_SOFT) { diff --git a/lib/EFBoard/EFBoard.h b/lib/EFBoard/EFBoard.h index cdb8a83..8a57329 100644 --- a/lib/EFBoard/EFBoard.h +++ b/lib/EFBoard/EFBoard.h @@ -34,7 +34,7 @@ #define EFBOARD_SERIAL_BAUD 115200 //!< Baudrate for the serial device // The Step-Down converter still manages to hold 3.00V with 3,32V input. The ESP needs 3.0V at least -#define EFBOARD_PIN_VBAT 10 //!< Pin the analog voltage divider for V_BAT is connected to +#define EFBOARD_PIN_VBAT 10 //!< Pin the analog voltage divider for V_BAT is connected to (ADC1_CH9) #define EFBOARD_NUM_BATTERIES 3 //!< Number of battery cells used for V_BAT #define EFBOARD_VBAT_MAX (1.60 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered full #define EFBOARD_VBAT_MIN (1.12 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered empty From 57656bfa9911adfb8560b0a07d18811e70a60c53 Mon Sep 17 00:00:00 2001 From: Token Date: Sat, 7 Sep 2024 01:58:43 +0200 Subject: [PATCH 2/9] fix: improve battery voltage calculation accuracy The old measurements were off and always cut off a lot of battery runtime from the badges! --- lib/EFBoard/EFBoard.cpp | 13 +++++++++---- lib/EFBoard/EFBoard.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/EFBoard/EFBoard.cpp b/lib/EFBoard/EFBoard.cpp index 2f11a51..29abb2b 100644 --- a/lib/EFBoard/EFBoard.cpp +++ b/lib/EFBoard/EFBoard.cpp @@ -138,10 +138,14 @@ const char *EFBoardClass::getWakeupReason() { } const float EFBoardClass::getBatteryVoltage() { - // voltageBattery = adcValue * voltPerADCStep * voltageDividerRatio - // adc_cal_raw_to_voltage - // esp_adc_cal_raw_to_voltage(analogRead(EFBOARD_PIN_VBAT)); - return (analogRead(EFBOARD_PIN_VBAT) * (3.3 / 4095.0)) * ((51.1 + 100.0) / 100.0); + // R11 = 51.1k, R12 = 100k + constexpr float factor = 1 / (100 / (51.1 + 100.0)); + // According to the datasheet, this should be more like 3.3. But this is off across all boards -> 3.41 seems more accurate! + constexpr float voltage_range = 3.41f; + uint16_t rawValue = analogRead(EFBOARD_PIN_VBAT); + float millivolts = rawValue * (voltage_range / 4095.0f) * factor; + LOGF_DEBUG("Battery voltage: %f\r\n", millivolts); + return millivolts / 1000.0f; } const bool EFBoardClass::isBatteryPowered() { @@ -162,6 +166,7 @@ const uint8_t EFBoardClass::getBatteryCapacityPercent() { * - 1.20 V = 23 % * - 1.16 V = 0 % */ + // TODO: This is a bit outdated/off double vBatCell = this->getBatteryVoltage() / 3.0; double percent = (14.9679 * pow(vBatCell, 3) - 68.9823 * pow(vBatCell, 2) + 106.4289 * vBatCell - 54.0063) * 100.0; return max(min((int) round(percent), 100), 0); diff --git a/lib/EFBoard/EFBoard.h b/lib/EFBoard/EFBoard.h index 8a57329..899f80b 100644 --- a/lib/EFBoard/EFBoard.h +++ b/lib/EFBoard/EFBoard.h @@ -28,6 +28,7 @@ */ #include "EFBoardPowerState.h" +#include "driver/adc.h" #define EFBOARD_FIRMWARE_VERSION "v1.1.0" #define EFBOARD_SERIAL_DEVICE USBSerial //!< Serial device to use for logging @@ -35,6 +36,7 @@ // The Step-Down converter still manages to hold 3.00V with 3,32V input. The ESP needs 3.0V at least #define EFBOARD_PIN_VBAT 10 //!< Pin the analog voltage divider for V_BAT is connected to (ADC1_CH9) +#define EFBOARD_ADC_CHANNEL ADC1_CHANNEL_9 //!< ESP32 ADC1 Channel #define EFBOARD_NUM_BATTERIES 3 //!< Number of battery cells used for V_BAT #define EFBOARD_VBAT_MAX (1.60 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered full #define EFBOARD_VBAT_MIN (1.12 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered empty From 048c9d11b6563484dd846b27131e3367e096c128 Mon Sep 17 00:00:00 2001 From: Token Date: Sat, 7 Sep 2024 02:00:10 +0200 Subject: [PATCH 3/9] fix: improve low power handling --- lib/EFBoard/EFBoard.cpp | 29 ++++++++++++++--------------- lib/EFBoard/EFBoard.h | 4 ++-- src/main.cpp | 13 ++++++++----- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/EFBoard/EFBoard.cpp b/lib/EFBoard/EFBoard.cpp index 29abb2b..55ff64d 100644 --- a/lib/EFBoard/EFBoard.cpp +++ b/lib/EFBoard/EFBoard.cpp @@ -33,7 +33,6 @@ #include "EFBoard.h" - RTC_DATA_ATTR uint32_t bootCount = 0; volatile int8_t ota_last_progress = -1; @@ -74,6 +73,7 @@ void EFBoardClass::setup() { randomSeed(analogRead(0)); // Check power state + this->updatePowerState(); const EFBoardPowerState pwrstate = this->getPowerState(); if (pwrstate == EFBoardPowerState::BAT_BROWN_OUT_HARD) { LOGF_ERROR("(EFBoard) HARD BROWN OUT DETECTED (V_BAT = %.2f V). Panic!\r\n", this->getBatteryVoltage()); @@ -155,7 +155,7 @@ const bool EFBoardClass::isBatteryPowered() { const uint8_t EFBoardClass::getBatteryCapacityPercent() { /* Used Varta Longlife AA cells discharge curve as a base. * - * We consider 1.16 V as empty even though the cells are not empty at that + * We consider 1.12 V as empty even though the cells are not empty at that * point due to the brown out voltage of the DC/DC for the 3.3V rail. * * Data points used to fit cubic function to: @@ -178,19 +178,18 @@ const EFBoardPowerState EFBoardClass::updatePowerState() { } else { float vbat = this->getBatteryVoltage(); - // if (vbat <= EFBOARD_BROWN_OUT_SOFT) { - // // A low-battery state could be a momentary spike that we can handle and do not need to shut off - // // We take the highest of three measurements to make sure - // delay(10); - // float newVbat = this->getBatteryVoltage(); - // vbat = newVbat > vbat ? newVbat : vbat; - // delay(10); - // newVbat = this->getBatteryVoltage(); - // vbat = newVbat > vbat ? newVbat : vbat; - // delay(10); - // newVbat = this->getBatteryVoltage(); - // vbat = newVbat > vbat ? newVbat : vbat; - // } + if (vbat <= EFBOARD_BROWN_OUT_SOFT) { + // A low-battery state could be a momentary spike + // We take multiple samples to make sure we are really low on battery + float sum = 0.0f; + constexpr uint8_t samples = 5; + for (uint8_t i = 0; i < samples; i++) { + sum += this->getBatteryVoltage(); + delay(1); + } + vbat = sum / samples; + LOGF("BATTERY: Measurement average: %f\r\n", vbat); + } if (vbat <= EFBOARD_BROWN_OUT_HARD || this->power_state == EFBoardPowerState::BAT_BROWN_OUT_HARD) { this->power_state = EFBoardPowerState::BAT_BROWN_OUT_HARD; diff --git a/lib/EFBoard/EFBoard.h b/lib/EFBoard/EFBoard.h index 899f80b..51d59d3 100644 --- a/lib/EFBoard/EFBoard.h +++ b/lib/EFBoard/EFBoard.h @@ -39,10 +39,10 @@ #define EFBOARD_ADC_CHANNEL ADC1_CHANNEL_9 //!< ESP32 ADC1 Channel #define EFBOARD_NUM_BATTERIES 3 //!< Number of battery cells used for V_BAT #define EFBOARD_VBAT_MAX (1.60 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered full -#define EFBOARD_VBAT_MIN (1.12 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered empty +#define EFBOARD_VBAT_MIN (1.13 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered empty #define EFBOARD_BROWN_OUT_SOFT EFBOARD_VBAT_MIN //!< V_BAT threshold after which a soft brown out is triggered -#define EFBOARD_BROWN_OUT_HARD 3.30 //!< V_BAT threshold after which a hard brown out is triggered +#define EFBOARD_BROWN_OUT_HARD (EFBOARD_BROWN_OUT_SOFT - 0.08) //!< V_BAT threshold after which a hard brown out is triggered /** diff --git a/src/main.cpp b/src/main.cpp index 52278fe..d241122 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,7 @@ // Global objects and states constexpr unsigned int INTERVAL_BATTERY_CHECK = 60000; -// Initalizing the board with a brightness above 49 can cause stability issues! +// Initializing the board with a brightness above 49 can cause stability issues! constexpr uint8_t ABSOLUTE_MAX_BRIGHTNESS = 45; FSM fsm(10); EFBoardPowerState pwrstate; @@ -86,7 +86,7 @@ void _hardBrownOutHandler() { ); EFBoard.disableWifi(); // Try getting the LEDs into some known state - EFLed.setBrightnessPercent(20); + EFLed.setBrightnessPercent(30); EFLed.clear(); EFLed.setDragonNose(CRGB::Red); @@ -95,10 +95,10 @@ void _hardBrownOutHandler() { // Low brightness blink every few seconds EFLed.enablePower(); EFLed.setDragonNose(CRGB::Red); - esp_sleep_enable_timer_wakeup(80 * 1000); // in ms + esp_sleep_enable_timer_wakeup(100 * 1000); // 100 ms EFLed.disablePower(); // sleep most of the time. - esp_sleep_enable_timer_wakeup(4 * 1000000); + esp_sleep_enable_timer_wakeup(2 * 1000 * 1000); // 2s esp_light_sleep_start(); // TODO: Go to deep sleep, but save the reason so when waking up, we can blink and deep sleep again } @@ -287,8 +287,11 @@ void loop() { // Task: Battery checks if (task_battery < millis()) { + EFBoardPowerState previousState = pwrstate; pwrstate = EFBoard.updatePowerState(); - LOGF_DEBUG("Updated power state: %s\r\n", toString(pwrstate)); + if (previousState != pwrstate) { + LOGF_DEBUG("Updated power state: %s\r\n", toString(pwrstate)); + } // Log battery level if battery powered if (EFBoard.isBatteryPowered()) { From c639583a52b598a322a007483dc353ce34ebc5e0 Mon Sep 17 00:00:00 2001 From: Token Date: Sat, 7 Sep 2024 12:48:46 +0200 Subject: [PATCH 4/9] Do battery checks in the boopup --- src/main.cpp | 58 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d241122..1c6c1d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ #include "util.h" // Global objects and states -constexpr unsigned int INTERVAL_BATTERY_CHECK = 60000; +constexpr unsigned int INTERVAL_BATTERY_CHECK = 10000; // Initializing the board with a brightness above 49 can cause stability issues! constexpr uint8_t ABSOLUTE_MAX_BRIGHTNESS = 45; FSM fsm(10); @@ -146,6 +146,30 @@ void _softBrownOutHandler() { } } +void batteryCheck() { + EFBoardPowerState previousState = pwrstate; + pwrstate = EFBoard.updatePowerState(); + if (previousState != pwrstate) { + LOGF_DEBUG("Updated power state: %s\r\n", toString(pwrstate)); + } + + // Log battery level if battery powered + if (EFBoard.isBatteryPowered()) { + LOGF_INFO( + "Battery voltage: %.2f V (%d %%)\r\n", + EFBoard.getBatteryVoltage(), + EFBoard.getBatteryCapacityPercent() + ); + } + + // Handle brown out + if (pwrstate == EFBoardPowerState::BAT_BROWN_OUT_HARD) { + _hardBrownOutHandler(); + } else if (pwrstate == EFBoardPowerState::BAT_BROWN_OUT_SOFT) { + _softBrownOutHandler(); + } +} + /** * @brief Calculates a wave animation. Used by bootupAnimation() */ @@ -160,7 +184,7 @@ float wave_function(float x, float start, float end, float amplitude) { /** * @brief Displays a fancy bootup animation */ -void bootupAnimation() { +void boopupAnimation() { CRGB data[EFLED_TOTAL_NUM]; fill_solid(data, EFLED_TOTAL_NUM, CRGB::Black); EFLed.setAll(data); @@ -173,6 +197,10 @@ void bootupAnimation() { for (uint16_t n = 0; n < 30; n++) { uint16_t n_scaled = n * 7; + if (n % 10) { + // Low batteries might crash the boopup animation + batteryCheck(); + } for (uint8_t i = 0; i < EFLED_TOTAL_NUM; i++) { int16_t dx = EFLedClass::getLEDPosition(i).x - pwrX; int16_t dy = EFLedClass::getLEDPosition(i).y - pwrY; @@ -191,6 +219,7 @@ void bootupAnimation() { EFLed.clear(); delay(400); + batteryCheck(); // dragon awakens ;-) EFLed.setDragonEye(CRGB(10,0, 0)); delay(60); @@ -217,7 +246,7 @@ void setup() { // Init board EFBoard.setup(); EFLed.init(ABSOLUTE_MAX_BRIGHTNESS); - bootupAnimation(); + boopupAnimation(); // Touchy stuff EFTouch.init(); @@ -287,28 +316,7 @@ void loop() { // Task: Battery checks if (task_battery < millis()) { - EFBoardPowerState previousState = pwrstate; - pwrstate = EFBoard.updatePowerState(); - if (previousState != pwrstate) { - LOGF_DEBUG("Updated power state: %s\r\n", toString(pwrstate)); - } - - // Log battery level if battery powered - if (EFBoard.isBatteryPowered()) { - LOGF_INFO( - "Battery voltage: %.2f V (%d %%)\r\n", - EFBoard.getBatteryVoltage(), - EFBoard.getBatteryCapacityPercent() - ); - } - - // Handle brown out - if (pwrstate == EFBoardPowerState::BAT_BROWN_OUT_HARD) { - _hardBrownOutHandler(); - } else if (pwrstate == EFBoardPowerState::BAT_BROWN_OUT_SOFT) { - _softBrownOutHandler(); - } - + batteryCheck(); task_battery = millis() + INTERVAL_BATTERY_CHECK; } } From dba13768d78eb02d0ebb34f64d00f3c1f2621157 Mon Sep 17 00:00:00 2001 From: Token Date: Sat, 7 Sep 2024 13:52:52 +0200 Subject: [PATCH 5/9] Fix --- lib/EFBoard/EFBoard.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/EFBoard/EFBoard.cpp b/lib/EFBoard/EFBoard.cpp index 55ff64d..c70d71d 100644 --- a/lib/EFBoard/EFBoard.cpp +++ b/lib/EFBoard/EFBoard.cpp @@ -140,11 +140,10 @@ const char *EFBoardClass::getWakeupReason() { const float EFBoardClass::getBatteryVoltage() { // R11 = 51.1k, R12 = 100k constexpr float factor = 1 / (100 / (51.1 + 100.0)); - // According to the datasheet, this should be more like 3.3. But this is off across all boards -> 3.41 seems more accurate! - constexpr float voltage_range = 3.41f; + // This is not correct over the whole range. But this is cursed anyways... + constexpr float voltage_input = 3.3f; uint16_t rawValue = analogRead(EFBOARD_PIN_VBAT); - float millivolts = rawValue * (voltage_range / 4095.0f) * factor; - LOGF_DEBUG("Battery voltage: %f\r\n", millivolts); + float millivolts = rawValue * (voltage_input / 4095.0f) * factor; return millivolts / 1000.0f; } From b2eb0fd74fbfc285533a8ee234e9fa318c8dc099 Mon Sep 17 00:00:00 2001 From: Token Date: Sat, 7 Sep 2024 14:18:30 +0200 Subject: [PATCH 6/9] Tweak power value --- lib/EFBoard/EFBoard.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/EFBoard/EFBoard.cpp b/lib/EFBoard/EFBoard.cpp index c70d71d..6b0c1c1 100644 --- a/lib/EFBoard/EFBoard.cpp +++ b/lib/EFBoard/EFBoard.cpp @@ -137,14 +137,21 @@ const char *EFBoardClass::getWakeupReason() { } } +// TODO: This version has some bug... +//const float EFBoardClass::getBatteryVoltage() { +// // R11 = 51.1k, R12 = 100k +// constexpr float factor = 1 / (100 / (51.1 + 100.0)); +// // This is not correct over the whole range. But this is cursed anyways... +// constexpr float voltage_input = 3.3f; +// uint16_t rawValue = analogRead(EFBOARD_PIN_VBAT); +// float millivolts = rawValue * (voltage_input / 4095.0f) * factor; +// return millivolts / 1000.0f; +//} + const float EFBoardClass::getBatteryVoltage() { - // R11 = 51.1k, R12 = 100k - constexpr float factor = 1 / (100 / (51.1 + 100.0)); - // This is not correct over the whole range. But this is cursed anyways... - constexpr float voltage_input = 3.3f; - uint16_t rawValue = analogRead(EFBOARD_PIN_VBAT); - float millivolts = rawValue * (voltage_input / 4095.0f) * factor; - return millivolts / 1000.0f; + // voltageBattery = adcValue * voltPerADCStep * voltageDividerRatio + // 3.5 should be 3.3. But then it measures wrong. With 3.5 it it measures brownout around 3.37V + return (analogRead(EFBOARD_PIN_VBAT) * (3.5 / 4095.0)) * ((51.1 + 100.0) / 100.0); } const bool EFBoardClass::isBatteryPowered() { From ccec145b310d94563909556813168d7a1f8d71e3 Mon Sep 17 00:00:00 2001 From: Token Date: Tue, 10 Sep 2024 15:54:43 +0200 Subject: [PATCH 7/9] Cleanup getBatteryVoltage --- lib/EFBoard/EFBoard.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/EFBoard/EFBoard.cpp b/lib/EFBoard/EFBoard.cpp index 6b0c1c1..0bceed4 100644 --- a/lib/EFBoard/EFBoard.cpp +++ b/lib/EFBoard/EFBoard.cpp @@ -137,21 +137,16 @@ const char *EFBoardClass::getWakeupReason() { } } -// TODO: This version has some bug... -//const float EFBoardClass::getBatteryVoltage() { -// // R11 = 51.1k, R12 = 100k -// constexpr float factor = 1 / (100 / (51.1 + 100.0)); -// // This is not correct over the whole range. But this is cursed anyways... -// constexpr float voltage_input = 3.3f; -// uint16_t rawValue = analogRead(EFBOARD_PIN_VBAT); -// float millivolts = rawValue * (voltage_input / 4095.0f) * factor; -// return millivolts / 1000.0f; -//} - const float EFBoardClass::getBatteryVoltage() { - // voltageBattery = adcValue * voltPerADCStep * voltageDividerRatio - // 3.5 should be 3.3. But then it measures wrong. With 3.5 it it measures brownout around 3.37V - return (analogRead(EFBOARD_PIN_VBAT) * (3.5 / 4095.0)) * ((51.1 + 100.0) / 100.0); + // Voltage divider resistors: R11 = 51.1k, R12 = 100k + constexpr float R1 = 51.1f; + constexpr float R2 = 100.0f; + constexpr float ADC_MAX_VALUE = 4095.0f; + constexpr float ADC_REF_VOLTAGE = 3.5f; // Reference voltage for ADC. Should be 3.3V, but the results are wonky. 3.5 works better + + constexpr float voltage_divider_factor = (R1 + R2) / R2; + float battery_voltage = (analogRead(EFBOARD_PIN_VBAT) * (ADC_REF_VOLTAGE / ADC_MAX_VALUE)) * voltage_divider_factor; + return battery_voltage; } const bool EFBoardClass::isBatteryPowered() { From 437ed697900fbec49349a2107d65b86833491886 Mon Sep 17 00:00:00 2001 From: Token Date: Tue, 10 Sep 2024 15:54:56 +0200 Subject: [PATCH 8/9] Make out-of-power state a bit more visible --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7469c43..d7523e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,7 +99,7 @@ void _hardBrownOutHandler() { // Low brightness blink every few seconds EFLed.enablePower(); EFLed.setDragonNose(CRGB::Red); - esp_sleep_enable_timer_wakeup(100 * 1000); // 100 ms + esp_sleep_enable_timer_wakeup(200 * 1000); // 200 ms EFLed.disablePower(); // sleep most of the time. esp_sleep_enable_timer_wakeup(2 * 1000 * 1000); // 2s @@ -134,10 +134,10 @@ void _softBrownOutHandler() { for (uint8_t n = 0; n < 30; n++) { EFLed.enablePower(); EFLed.setDragonNose(CRGB::Red); - esp_sleep_enable_timer_wakeup(200 * 1000); + esp_sleep_enable_timer_wakeup(300 * 1000); esp_light_sleep_start(); EFLed.disablePower(); - esp_sleep_enable_timer_wakeup(800 * 1000); + esp_sleep_enable_timer_wakeup(700 * 1000); esp_light_sleep_start(); } From 95afe29ae244fcb35abc7f59a0766a13782bfe17 Mon Sep 17 00:00:00 2001 From: Token Date: Tue, 10 Sep 2024 15:57:13 +0200 Subject: [PATCH 9/9] Remove cruft --- lib/EFBoard/EFBoard.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/EFBoard/EFBoard.h b/lib/EFBoard/EFBoard.h index 51d59d3..21251d3 100644 --- a/lib/EFBoard/EFBoard.h +++ b/lib/EFBoard/EFBoard.h @@ -28,7 +28,6 @@ */ #include "EFBoardPowerState.h" -#include "driver/adc.h" #define EFBOARD_FIRMWARE_VERSION "v1.1.0" #define EFBOARD_SERIAL_DEVICE USBSerial //!< Serial device to use for logging @@ -36,7 +35,6 @@ // The Step-Down converter still manages to hold 3.00V with 3,32V input. The ESP needs 3.0V at least #define EFBOARD_PIN_VBAT 10 //!< Pin the analog voltage divider for V_BAT is connected to (ADC1_CH9) -#define EFBOARD_ADC_CHANNEL ADC1_CHANNEL_9 //!< ESP32 ADC1 Channel #define EFBOARD_NUM_BATTERIES 3 //!< Number of battery cells used for V_BAT #define EFBOARD_VBAT_MAX (1.60 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered full #define EFBOARD_VBAT_MIN (1.13 * EFBOARD_NUM_BATTERIES) //!< Voltage at which battery cells are considered empty