Charging indicator for Thing Plus - ESP32 WROOM (USB-C)

Hello!

I currently use the following method to determine if my battery is charged:

// SparkFun Fuel Gauge LiPo battery
#include <Wire.h>
#include <SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h>

const int SDA_PIN = 21;
const int SCL_PIN = 22;
SFE_MAX1704X lipo(MAX1704X_MAX17048);
bool usbCharging = false;

//…

void setup() {

  Wire.begin(SDA_PIN, SCL_PIN);

  lipo.begin(Wire);

}

//…

usbCharging = (lipo.getChangeRate() > 0);

While it works, there is a significant lag between the time I plug a wire and get usbCharging to toggle. Same goes when unplugging. My charging animation/UX charge indicator can lag up to 60 seconds at times.

How are your handling displaying the charging status with this board ?

I’ve considered adding: VUSB - 100k resistor - GPIO - 100k resistor - ground, but it seems ludicrous, and then I would need to address the edge case of when the battery is full, it is no longer charging.

Am I missing something here ?

Thank you :slight_smile:

I think it may be because that function is for the hourly charge rate

If you run the default ex1 sketch, how quickly does it perform updates on the serial monitor?

Unless I missunderstand what you meant, that default ex sketch you linked does not tell if the battery is charging, it only display the state of charge (which is also suceptible to the battery calibration). I could monitor if the SOC changes with time, but that will lag just as much. I would expect the loop to print to the serial monitor every 500ms, but where I’m confused is that it’s not printing useful data to know, promptly, if the device is charging.

What I’m looking for is a way to access the stat pin from the charger. But short of soldering a wire to the charging LED’s pad, it seems that data is not available.

So I was curious to see how people are implementing their “charging state” UX in a way that’s an acceptable user experience in term of responsive feedback.