Can code tell when the Thing Plus C is charging its LiPo battery?

My current project sends me an email when it sees the percentage of battery left has fallen below a certain level. If I have the Thing Plus C connected to my computer via USB and it is charging the LiPo battery, I don’t need it to do this. Is there a way in software that I can detect any of the following:

  • Thing is currently connected to a computer via USB.

  • Thing is currently charging a connected LiPo.

  • Thing does not have a LiPo connected at all.

Thanks.

We normally have this https://www.sparkfun.com/products/13777 but it’s out-of-stock right now…sign up to be notified, then go through this https://learn.sparkfun.com/tutorials/ba … 1643964608 if/when you get one :smiley:

Hi Matt,

The Thing Plus C has a MAX17048 Fuel Gauge on-board. You can use the Arduino library functions to read the change rate and State Of Charge:

https://github.com/sparkfunX/SparkFun_E … lGauge.ino

Best wishes,

Paul

I had somehow missed the change rate method. That will tell me if its charging or not. Thanks!

I also see that there is a function for putting the fuel gauge IC to sleep. Does this need to be done if I’m putting the Thing Plus C to sleep, or does that effectively cut power to that IC as well?

Hi Matt,

The Fuel Gauge is powered directly by the battery. It draws very little current: 23 micro-Amps when active; 3 micro-Amps in hibernate. Putting it into hibernation may help extend your battery life, but the ESP32 current draw will dominate.

Best wishes,

Paul