EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: TimNJ on June 10, 2020, 04:26:59 am

Title: iOS Device: Checking battery state of charge via Lightning/USB Type-C
Post by: TimNJ on June 10, 2020, 04:26:59 am
Hi all,

Firstly, I'm typically pretty far away from software/firmware, so please excuse the ignorance of this question. I'm also pretty sure no one will have experience with this, but here goes:

Is it possible to check/request the battery's state of charge from an iOS device via a wired connection (i.e. Lightning or USB Type-C)? Seems like it's possible via Bluetooth. I've looked through Apple's accessory design guidelines, but don't really see anything about it. https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf

I've been kicking around an idea for an external charge cut-off device that prevents the device's battery from being charged above some level. The life of lithium based batteries can be greatly improved if you just charge to 80-90% instead of 100%. Apple has implemented a software feature which  sort of does this, but still winds up charging up to 100% anyway. The software feature avoids float charging at 100% for prolonged periods.

Thanks,
Tim
Title: Re: iOS Device: Checking battery state of charge via Lightning/USB Type-C
Post by: NiHaoMike on June 10, 2020, 04:50:41 am
If it can be assumed the device will be idle, check the current draw and look for it going below a certain point.
Title: Re: iOS Device: Checking battery state of charge via Lightning/USB Type-C
Post by: TimNJ on June 10, 2020, 02:50:51 pm
Thanks. I suppose that could "work" but think it would be quite crude. Of course, does not work (well) if you're using the phone while on the charger. Plus, different batteries, chemistries, and varying degrees of battery health probably means that "cut-off charge current"varies all over the place.

The convenient thing about battery management systems, is that, most good ones, actively monitor the charge/discharge characteristics (impedance) to analyze the health of the battery pack. So, the reported state of charge is relatively accurate, and there's no need for "calibration". By calibration I mean: If I was just measuring input current, then the current at which 80 or 90% SoC is reached will likely be different depending on factors I mentioned above. But, when a BMS reports 80% SoC, you can believe that the battery really is charged to 80% +/- 5%, or so. No need to do any analog measurements.

Thanks for the idea though. Maybe there's still a way.
Title: Re: iOS Device: Checking battery state of charge via Lightning/USB Type-C
Post by: PlasmaArcEng on June 11, 2020, 02:29:07 am
If you make an app for your phone it could report back to the smart charger the status of the charge level. I cant find anything about an API for this natively.
Title: Re: iOS Device: Checking battery state of charge via Lightning/USB Type-C
Post by: NiHaoMike on June 11, 2020, 02:52:39 am
If you make an app for your phone it could report back to the smart charger the status of the charge level. I cant find anything about an API for this natively.
So the app checks the charge level and tells the charger to turn off when it is just right. The hardware for it already exists if you want to do it over Wifi or Bluetooth.
https://hackaday.com/2019/12/26/new-part-day-sonoff-usb-smart-adaptor-taps-a-new-wifi-chip/

If you want to do it over USB, it's possible but would probably involve more complexity than you want. Back when I worked at Intel, they had those really neat stationary bicycles in the gym that can charge a connected phone or tablet and there's an optional app for recording data, but the app still needs to be paired using Bluetooth - the USB is for power only.
Title: Re: iOS Device: Checking battery state of charge via Lightning/USB Type-C
Post by: Jeroen3 on June 11, 2020, 08:16:32 am
Yes™
Apps can use ExternalAccessory api to talk to devices. Those devices can still charge the phone.
Drawback: app must be in foreground.

To not be in foreground (eg: carplay) you must be MFi, an no way they're going to sign off on a feature like this.

You could start here: https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf