sforkowany z mirror/meshtastic-firmware
Low battery level counter for NRF52
Added a counter that counts low battery level detections. If there are 4 in a row we go to deep sleep. The battery sense on the RAK4631 seems to be a bit unstable and may generate 'false' low voltage readings. My RAK4631 has been running for 7 days now with this fix. It did 3 days without it. I still do not have a T-Echo so on that board IT IS NOT TESTED. (But I hope it will improve things there too)1.2-legacy
rodzic
b182819aff
commit
28e851c3fd
|
@ -192,6 +192,7 @@ bool Power::setup()
|
||||||
found = analogInit();
|
found = analogInit();
|
||||||
}
|
}
|
||||||
enabled = found;
|
enabled = found;
|
||||||
|
low_voltage_counter = 0;
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
@ -238,9 +239,24 @@ void Power::readPowerStatus()
|
||||||
powerStatus.getIsCharging(), powerStatus.getBatteryVoltageMv(), powerStatus.getBatteryChargePercent());
|
powerStatus.getIsCharging(), powerStatus.getBatteryVoltageMv(), powerStatus.getBatteryChargePercent());
|
||||||
newStatus.notifyObservers(&powerStatus);
|
newStatus.notifyObservers(&powerStatus);
|
||||||
|
|
||||||
|
|
||||||
|
// If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row
|
||||||
|
// Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days
|
||||||
|
#ifdef NRF52_SERIES
|
||||||
|
if (powerStatus.getHasBattery() && !powerStatus.getHasUSB()){
|
||||||
|
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS){
|
||||||
|
low_voltage_counter++;
|
||||||
|
if (low_voltage_counter>3)
|
||||||
|
powerFSM.trigger(EVENT_LOW_BATTERY);
|
||||||
|
} else {
|
||||||
|
low_voltage_counter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
// If we have a battery at all and it is less than 10% full, force deep sleep
|
// If we have a battery at all and it is less than 10% full, force deep sleep
|
||||||
if (powerStatus.getHasBattery() && !powerStatus.getHasUSB() && batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS)
|
if (powerStatus.getHasBattery() && !powerStatus.getHasUSB() && batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS)
|
||||||
powerFSM.trigger(EVENT_LOW_BATTERY);
|
powerFSM.trigger(EVENT_LOW_BATTERY);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// No power sensing on this board - tell everyone else we have no idea what is happening
|
// No power sensing on this board - tell everyone else we have no idea what is happening
|
||||||
const PowerStatus powerStatus = PowerStatus(OptUnknown, OptUnknown, OptUnknown, -1, -1);
|
const PowerStatus powerStatus = PowerStatus(OptUnknown, OptUnknown, OptUnknown, -1, -1);
|
||||||
|
|
|
@ -37,6 +37,9 @@ class Power : private concurrency::OSThread
|
||||||
|
|
||||||
/// Setup a simple ADC input based battery sensor
|
/// Setup a simple ADC input based battery sensor
|
||||||
bool analogInit();
|
bool analogInit();
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t low_voltage_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Power *power;
|
extern Power *power;
|
Ładowanie…
Reference in New Issue