diff --git a/src/Power.cpp b/src/Power.cpp index af10acb5e..dd3ac1497 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -102,6 +102,10 @@ class AnalogBatteryLevel : public HasBatteryLevel #define ADC_MULTIPLIER 2.0 #endif +#ifndef BATTERY_SENSE_SAMPLES +#define BATTERY_SENSE_SAMPLES 30 +#endif + #ifdef BATTERY_PIN // Override variant or default ADC_MULTIPLIER if we have the override pref float operativeAdcMultiplier = config.power.adc_multiplier_override > 0 @@ -112,16 +116,12 @@ class AnalogBatteryLevel : public HasBatteryLevel if (millis() - last_read_time_ms > min_read_interval) { last_read_time_ms = millis(); -#ifdef BATTERY_SENSE_SAMPLES //Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic environment. uint32_t raw = 0; - for(uint32_t i=0; igetBattVoltage() < MIN_BAT_MILLIVOLTS) { low_voltage_counter++; - if (low_voltage_counter > 3) + DEBUG_MSG("Warning RAK4631 Low voltage counter: %d/10\n", low_voltage_counter); + if (low_voltage_counter > 10) powerFSM.trigger(EVENT_LOW_BATTERY); } else { low_voltage_counter = 0;