meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.61k stars 899 forks source link

[Bug]: ESP32 - EVENT_LOW_BATTERY can cause devices with external (intelligent) charging controllers to sleep forever #4828

Open dm5tt opened 1 month ago

dm5tt commented 1 month ago

Category

Other

Hardware

Other

Firmware Version

2.5.x

Description

I'm seeing increased reports of "Solar station doesn't wake up after getting power". Guess we have a problem in the algorithm as we are always assuming that the device is getting charged by 5V.

Assume following scenario

  1. We applying power to an entirely discharged battery through an intelligent charge controller (BQ25185, CP*, etc.) with dedicated LOAD pins

  2. ADC Battery Voltage slowly rises (2.8V->2.9V->3.0V->3.1V->3.1V->V3.15->etc.)

  3. Device is waking up around 2.8V-3.0V

We will never see USB 5.0V voltage during the slow charge process! These chips are using voltage-tracking-algorithm!

Power.cpp, 683
    if (batteryLevel && powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
        if (batteryLevel->getBattVoltage() < OCV[NUM_OCV_POINTS - 1]) {
            low_voltage_counter++;
            LOG_DEBUG("Low voltage counter: %d/10\n", low_voltage_counter);
            if (low_voltage_counter > 10) {
#ifdef ARCH_NRF52
                // We can't trigger deep sleep on NRF52, it's freezing the board
                LOG_DEBUG("Low voltage detected, but not triggering deep sleep\n");
#else
                LOG_INFO("Low voltage detected, triggering deep sleep\n");
                powerFSM.trigger(EVENT_LOW_BATTERY);
#endif
            }
        } else {
            low_voltage_counter = 0;
        }
  1. We get the 10 hits of "Low Battery"

  2. Boom. Deep Sleep for a day (if ROUTER) or forever. But in the background we are still in a happy state as the battery is charging.

Am I seeing this right?

Solution Ideas

  1. Reduce Deep Sleep duration

or

  1. Add a define (#define EXTERNAL_BAT_VOLTAGE_CONTROL) that disables the EVENT_LOW_BATTERY transition if we are having an external charge controller and enabled the hardware watchdog

or

  1. Battery voltage trend monitoring

Relevant log output

No response

meshtastic-bot commented 1 month ago

This issue has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/device-brown-out-and-characterizing-chargers/14807/3

popiciulo commented 1 month ago

Same problem here. I have disabled power saving mode and still the same issue, device is not booting up even though the battery is fully charged.

mverch67 commented 1 month ago

You can (still) configure how long the deep sleep lasts (power.sds_secs) . If you set it e.g. to 30 minutes, it will wake up from deep sleep after 30 minutes and if battery is still low fall asleep again otherwise continue to work as normal.