2

Why do you think the OS estimates a battery percentage a little above the actual value? I noticed it is always between 0% and 5% more. In particular the two percentage gets closer when the remaining battery gets lower. Maybe this way the device seems to get faster to 100%, since the 95%-100% takes a lot of time...?

Some details. I can find the percentage two ways:

  • From the battery menu bar icon or with pmset -g batt (eg. now they say 96%)
  • By calculating it manually from System Information.app or with information from ioreg -l -n AppleSmartBattery -r (eg. now I get: MaxCapacity: 4181, CurrentCapacity: 3813; meaning 91.2%)
  • It's not so simple. See this video: youtube.com/watch?v=R8hTQXqURB4 – Allan Mar 31 '18 at 12:51
  • Is this pirely a how does the battery chemistry map to measured values or is there something practical/specific you wish to do here once this is explained? – bmike Mar 31 '18 at 13:45
  • Thank you @Allan, I'll surely watch it as soon as I have some spare time. – Diego Apr 1 '18 at 13:22
  • 1
    @bmike, the question is also a curiosity, but I'm mainly making an Alfred script to get the remaining battery and I wasn't sure which one was the "right" one – Diego Apr 1 '18 at 13:23
1

If you were to script this - keep in mind. One lithium cell charges very non-linearly. And a battery of individual cells will charge like a mess of non-linear units - none of them in phase.

Your data from ioreg is far superior to the processed guess of percentage from pmset and I would only use the power manager tool to log and process changes - not to do the calculations you seek.

From the registry - you can focus on these three items in my opinion:

  • "DesignCapacity" = 5297
  • "CurrentCapacity" = 2331
  • "MaxCapacity" = 5059

So in my case, the theoretical design maximum milli amp hours is 5297 and I can expect from the readings to only store 5059 mAh of which I have a measured 2331 left to use before I'm flat. You may or may not want to try and incorporate the amperage draw or temperature depending on how sophisticated your app will be or if it just will report the calculated time to empty listed as "InstantTimeToEmpty"

  • Thank you. I've also seen the video in one of the comments and I understand the matter is complicated... I wouldn't know how to incorporate other informations like amperage or temperarure, so I think I'll just compute the percentage with those three values and a remaining time with "InstantTimeToEmpty". – Diego Apr 2 '18 at 8:07
1

My guess is that with AppleSmartBattery, you are calculating the percentage based on the batteries brand new, fully charged state. Whereas the OS is basing the percentage on what the battery is currently capable of at full charge, which will slowly degrade over time.

  • mmmh but actually with ioreg there's also DesignCapacity = 4315, so I think MaxCapacity: 4181 takes into account battery ageing... (sorry I haven't mentioned that) – Diego Mar 31 '18 at 11:26
  • Well perhaps the rate at which the battery drains isn't quite constant and changes based on its charge, so the raw mah value might need to be adjusted slightly to get a percentage that is more linear based on time. – l008com Mar 31 '18 at 11:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .