Hi,
I am using the following code to read the battery charge and the time left (pC equals pBatteryChargePercent when I want to read the battery charge, otherwise I want to read the time left. I know this temporary code is not fully clean, but I think it's not the point here).

This code is invoked when a BlueTooth characteristic is read, so when the ESP32 is in a woken-up mode (and not in sleep mode, neither in the wake stub). Board.init(1800) has been called prior to this, as the first line in app_main.

I face 2 issues:
1) while the battery is being charged (USB plugged), the battery charge is constantly 42 (for instance), for several minutes (say, at least 10 minutes), and then it suddenly changes to 92 (for instance). I would expect a more continuous progression instead of this 50% jump.
2) the getBatteryTimeLeft always returns -4 (NotReady), even when waiting some significant time, i.e. several minutes.

Most of the time, the application is in deep sleep. It wakes about every minute to do some code for a few milliseconds in the wake stub.
When the user triggers a touchpad, then the app wakes up, starts BlueTooth, and returns to deep sleep after 30 seconds. the code above is thus code during these 30 seconds.

Is there anything specific to do:
1) in order for getBatteryCharge to update more regularly (I would expect to read something more continuous like 42, 50, 60, 70, 80, 92, rather than 42, 42, 42, 42, 42, 42, 92)
2) in order for getBatteryTimeLeft to be successful instead of returning NotReady
?

Many thanks!

        PowerFeather::Result res;
        int value;
        res = PowerFeather::Board.enableVSQT(true);
        if (res != PowerFeather::Result::Ok) {
            value = -1;
        }
        else {     
            res = PowerFeather::Board.enableBatteryFuelGauge(true);
            if (res != PowerFeather::Result::Ok) {
                value = -2;
            }
            else {
                if (pC == pBatteryChargePercent) {
                    uint8_t batteryCharge;
                    res = PowerFeather::Board.getBatteryCharge(batteryCharge);
                    if (res != PowerFeather::Result::Ok) {
                        value = -3;
                    }
                    else {
                        value = batteryCharge;
                    }
                }
                else {
                    res = PowerFeather::Board.getBatteryTimeLeft(value);
                    if (res != PowerFeather::Result::Ok) {
                        if (res == PowerFeather::Result::NotReady) {
                            value = -4;
                        }
                        else {
                            value = -3;
                        }
                    }
                }
                PowerFeather::Board.enableBatteryFuelGauge(false);
            }
            res = PowerFeather::Board.enableVSQT(false);
        }

Hi, I noticed you turn the fuel guage on and off.

It's meant to be enabled as much as possible, even when the ESP32 is sleeping, since it continually monitors the status of the battery. Disabling/enabling the fuel gauge resets the parameters learned by the fuel gauge so far. It also means it can't estimate the time left.

Disabling the fuel gauge is only meant in the worst case, where you have to save every uA as much as possible - ideally paired with shutdown/ship mode.

Hi, thank you!
Indeed I shut the gauge down to save power, but I have also seen in the doc that it was "eating" 0.5uA while "settled". But I wanted to avoid the 26uA from the "initial" state of the gauge.

I am totally fine with the 0.5uA.

What is the safe way to keep the gauge on, but in the "settled" mode? (could not find examples for this, maybe I looked at the wrong place)

    bfredo123 Unfortunately not much can be done about this. It's the behavior of the fuel gauge itself - when enabled, it does its measurements at more frequent intervals at certain times (at startup, heavy loads) and slower at certain times (during light loads). The fuel gauge does this detection (whether the battery is under heavy/light load) by itself.

    Thank you, I see, I we have a closer look at the gauge chip datasheet.

    I have modified the code so that the fuel gauge is always enabled. During several hours, the battery charge percent has ranged from 80% to 100% (in various ways, depending on whether the USB cable was plugged or not). The charge percent is properly displayed, but during all this time, the time left method always returns NotReady.

    Is it normal? (the doc says that the charge has to vary before the time left can be estimated, but I don't by how much, and for how long. I would rather say the several hours and a 20% should be enough, but no clue, actually)