Wrong state of charge calculation by android - Galaxy S 4 Mini Q&A, Help & Troubleshooting

I've i9195 with stock battery and rom, all was normal. Then I replaced it with double sized battery+new back cover. Not a microUSB batterycase. After many cycles and weeks of use it still didn't calibrated to new capacity. Fully charged battery lasts about a day and phone shuts down. If I switch it back ON after couple of minutes - I see 50% charged and can use phone another day.After second 'full discharge' I'll have about 15% more. All techniques for 'calibrating' battery with deleting batterystats doesn't work. Charge, off, remove bat, wait, place it back - either. /sys/class/power_supply/battery/uevent have string POWER_SUPPLY_ENERGY_FULL=1940000000 and it is always the same. So phone simply downcount from this level and tells that charge is 0% while voltage is about 3.7v. Interesting that "energy_full" file has number of 3880000000 but it seems that it's not used in calculations.
After all I installed CWM, root, cyanogenmod 11 and used it for about a week. SAME problems, except that "energy_full" is 1940000000.
I want to solve this very much, I can program or recompile kernel, if needed. It's pm8921 charger ic there. Maybe this number was programmed in it in factory mode or smth. Maybe threis a way to correct it. Thanks in advance.

Same here with stock-rom, CyanogenMod and MoKee's rom.
I think the only way will be to recompile the used kernel with the correct value of 3880000000 instead of 1940000000 in file "drivers/power/pm8921-bms.c" in kernel sources (function "calculate_fcc_uah", part "scalefactor". Scalefactor has to be change into scalefactor *= 2.
Huge work for a little problem...

Instead of making any advanced config, have you tried this little app (needs root privileges)?
https://play.google.com/store/apps/details?id=com.nema.batterycalibration
After migrating to CM11 my battery was draining very fast. I used this app and it apparently fixed a part of the issue (battery still drains fast, but not as fast as before).

Related

Kaiser Battery Status [kernel mod]

NOTE: I don't post kernels here anymore: look for my changes in the standard kernel now.
This thread is still useful for battery discussion, if you like.
I have gotten tired of seeing my battery go from 90% to 15%.
Why can't it go smoothly from 100% down to 5% or less, and back up again?
Why does nbheditor have to apply a 1.6 multiplier for battery capacity?
Can we get the temperature sensor working?
I'd like to get this fixed, and would welcome discussion.
First, in the new or old kernel, the battery status is managed by the file:
kernel/arch/arm/mach-msm/board-kaiser-battery.c.
I have several proposals:
a) Change the default KAISER_BATTERY_RATING to 1350, since the equations really do work out correctly, that the rating should match in mAh. Note: in the kernel, that's 2160 = 1350 * 1.6.
b) Add a thirty second maximum for voltage and current, before using them to guess the battery level. At first I used averaging, but maximum works better for old batteries.
c) When booting from HaRET, scale the battery level because Windows does it different. I don't understand how Windows does it, but I have figured out a scale factor that works.
d) When the ds2746 reports that it has lost power, assume that the battery may have been changed, and do a coarse recalibration based on voltage and charge current.
e) Eliminate the minimum of 15%: let the meter go all the way to zero.
f) Allow battery level to be set to any value at any time.
g) Report what the kernel thinks the capacity should really be.
h) Use ds2746 units directly since nbh-editor already scales mAh to units.
Also, questions:
1) How to convert the thermistor resistance (I think it is aux0r) to temperature?
2) Would be nice if the dynamically-adjusted capacity could be stored in flash. I don't know how to do that, but I know how to report it.
3) Should we have an option on the boot menu to manually set the battery level?
I have edited the new 2.6.34 kernel to act as I propose.
Since the modules must match the kernel version you are using, I have included modules separately.
Warning though that, although it seems to work properly for me, it might do bad things for you, especially to your phone's battery. In particular, the Polaris needs to be tested since I don't have one.
NBH file: for NAND install. Use nbheditor to edit, but put your battery's capacity under "advanced settings". For attempt #6, you can use the standard setting.
ZIMAGE: for HaRET install. Edit your default.txt to contain:
board-kaiser-battery.battery_capacity=2160 (your true battery capacity in mAh * 1.6)
board-kaiser-battery.haret_divisor=2200 (use a WinMo -> android scale factor of 1000/2200)
CAUTION: The 2.6.25 NBH images probably don't work. I'll have to learn how to make them!
NOTE: Attempt #7 and later are in the standard kernel, so are no longer posted here.
just setting this up on Incubus26Jc's Super FroYo 2.2 [Deodexed] [RLS15] [9/3/10]. I will let you know how it goes.
WOW, I´m glad somebody finally took this matter as serious as it is I´m not saying that others guy in here haven´t provided advice on this, it is just that nobody, afaIk hadn´t come with a "downloadable" solution, the only thing close to a real fix to me was to use the nbh editor and put the recommended capacity for my battery, it helped a lot to be honest cuz I used to get no more than 15 minutes of battery life, and after that I can use it for a few hours, unless I turn wifi and bluetooth of course, then it gets down to 15%, well I hope this really works cuz I´v been strugling with this for more than a month and I love android so much that I flashed on nand even though I knew about this problem, and I was about to give up on this, (was I?), thanks for this, I hope we get good results!!!
Isn't it that the latest kernel for froyo is 2.6.32? Is that your own build?
I wanna try your version. So far, how does all features? How is it compared to DZO's kernel?
More power!
Ok so I had lockups with Incubus26Jc's Super FroYo 2.2 [Deodexed] [RLS15] [9/3/10], I am loading up dzo's current Froyo and his 9-9-10 kernel for some base testing then I will install your kernel and updates and test again.
So, how do I install this? i mean, do I:
1- flash the new nbh.
2- install theandroidupdate.tar
done? I mean, do I have to do the whole "calibration dance" with it again or something? Or after i do this it will (in theory) perform as normal as it should? btw my battery is about a month old, so I guess if i put 2000 in advance mode, (not mah) it would be ok, right?
ps: I have donut installed, so I guess it might not work, but heck I´ve got to try this anyways, so I´ll go ahead and install it, in case it works, would you be able to tweak a donut kernel for us?. thanks in advance.
zack, how is it?
so far with dzo's latest froyo build and the attached kernel and update things have been very stable, however the battery is at 100% constantly. hopefully this will change as the battery is drained and recharged.
The kernel is dzo's with the experimental battery file.
Not ready for prime time. If your configured capacity is wrong, it gets calibrated as you run, but the calibration is not remembered when you reboot.
Sent from my Full Android on Vogue using XDA App
I'm looking for opinions on the individual questions in the first post. Especially, does anyone know how the kernel can store battery_capacity s it remains persistent after reboot?
If you search dmesg output for ds2746 you can see what the current capacity is.
Sent from my Full Android on Vogue using XDA App
I´ve installed it and after a while of letting both wifi and bluetooth on, it finally died and showed me 1% left and powered down all by itself, I had never seen 1% left on android, so that´s a good thing I guess, but after I connected the charger it started charging just fine, but in the console after typing dmesg it tells me that the battery has 4079mv and 54/3200 units, but I think that if the battery has 4079mv, it means it is fully charged, am I wrong? if anybody reads this please confirm this because I put it is still charging I don´t want my kaiser to blow up on me, lol. thanks.
ps: while charging it isn´t showing the amber led, but it has a red blinking led as when the battery is completely empty and not charger is connected (but in android the battery icon has the charging animation).
elander said:
I´ve installed it and after a while of letting both wifi and bluetooth on, it finally died and showed me 1% left and powered down all by itself, I had never seen 1% left on android, so that´s a good thing I guess, but after I connected the charger it started charging just fine, but in the console after typing dmesg it tells me that the battery has 4079mv and 54/3200 units, but I think that if the battery has 4079mv, it means it is fully charged, am I wrong? if anybody reads this please confirm this because I put it is still charging I don´t want my kaiser to blow up on me, lol. thanks.
ps: while charging it isn´t showing the amber led, but it has a red blinking led as when the battery is completely empty and not charger is connected (but in android the battery icon has the charging animation).
Click to expand...
Click to collapse
Do not worry. Nothing will happen to your phone. Electronic circuits inside the battery takes care of it. You have to repent attention to the current charge (mAh). When the value falls below 200mA, then the battery is full.
I've had two crashes (phone totally frozen, unresponsive) when on charger and full battery. Probably a coding error somewhere in this experimental file.
I'm also wondering which phone models use this source file?
Do some of them perhaps have different resistor values?
Do we have any historical information about why 10M Ohm was chosen as a resistor value, rather than 15 or some other value?
Millence said:
Do not worry. Nothing will happen to your phone. Electronic circuits inside the battery takes care of it. You have to repent attention to the current charge (mAh). When the value falls below 200mA, then the battery is full.
Click to expand...
Click to collapse
Thanks for replying, I know that the battery has some sort of sensor built in that tells the OS when it is full, but since we are dealing with calibration here (a.k.a I don't know when it is full or empty) I kinda freaked out a bit there, but thanks to your answer I feel (a little) relieve, the thing is that it's been plugged for more than two hours (I had to unplugged it cuz I had to return home from work) and dmesg still says something like: 4180 mv 145mah 50/100 (1604/3200 units) so when you told me about the current charge below 200mah you meant the number that appears on dmesg right after the (4180)mv? in this case it is 145mah, if so, does that means that the battery is already fully charged? cuz according to android it is only like 52% full. should I leave connected or should I unplug it (it is already unplugged just in case,lol). thanks.
It depends. It looks like your battery currently has 1002 mAh of charge, out of 2000 mAh. I doubt that you have a 2000 mAh battery. If you really have a 1350 mAh battery, you are more like 75% full.
I chose a lower limit than 200 mA for when the kernel thinks you are 100% full based on charge, since my phone charges at under 200 mA when connected to a computer, regardless of how full it is.
Please include what kind of phone you have. Otherwise I will assume you have a Kaiser.
n2rjt said:
It depends. It looks like your battery currently has 1002 mAh of charge, out of 2000 mAh. I doubt that you have a 2000 mAh battery. If you really have a 1350 mAh battery, you are more like 75% full.
I chose a lower limit than 200 mA for when the kernel thinks you are 100% full based on charge, since my phone charges at under 200 mA when connected to a computer, regardless of how full it is.
Please include what kind of phone you have. Otherwise I will assume you have a Kaiser.
Click to expand...
Click to collapse
I do have a Kaiser, and I do have a 1350mah battery, and as you said on the first post I edited the nbh to 2000 capacity using the nbh editor, so did I misunderstand first post and instead of 2000 capacity in advance mode I should have put 1350mah in simple mode, or should I have put 1350mah in advance mode in order to make android recognize the capacity of my battery? cuz as I see it now it seems it is the other way around now, cuz before android used to think that the battery was full when in fact it wasn't and now even when full android thinks it is not.
Put the battery rated capacity (1350) in the advanced setting, so it won't be multiplied by 1.6.
The conversion from dmesg units to mAh is: 625 x units / 1000 = mAh. Probably dmesg should show mAh so we don't have to calculate.
Sent from my Full Android on Vogue using XDA App
I am trying to use this kernel with cyanogen build, but it does not boot.
When I start haret it hangs. It moves the staus bar to the bottom of the screen and then freezes. (I can only reset via stylus os sim card cover)
The files I have in andboot are:
zImage-2.6.32-froyo-06-09-10_22 - the original zImage
initrd.lzma
zImage - the zimage with the battery fix
androidinstall.tgz - cyanogen install pack
androidupdate.tgz - update for the battery fix
startup.txt - modified for the battery test (zImage name and battery capacity)
haret-for-kernel-2-6-32.exe - haret
my startup.txt file is:
Code:
#alloctest 0x2000
set RAMSIZE 0x08000000
set RAMADDR 0x10000000
set FBDURINGBOOT 0
set MTYPE 1553
set KERNEL zImage
set initrd initrd.lzma
#
# The following kernel parameters are useful
# ppp.nostart - Set ppp.nostart=1 to disable starting the ppp connection on boot
# msm_sdcc.msmsdcc_fmax - The maximum frequency (in Hz) used by the SD controller
# pm.sleep_mode - The mode used when the phone is off
# 0=Power Collapse Suspend, 1=Power Collapse, 2=Apps Sleep,
# 3=Slow Clock and Wait for Interrupt 4=Wait for Interrupt
# Default is 1, use 1 for best power savings
# board-htckaiser.panel_type - Panel type used to power the panel off and on
# 0=Don't power off the panel (Default)
# 1=Sony 2=Topoly 3=Topoly (probably just the same as 2)
# lcd.density - Defaults to 160, 128 shows more on screen
#
set cmdline "ppp.nostart=0 pm.sleep_mode=1 mddi.width=240 mddi.height=320 no_console_suspend board-kaiser-keypad.atttilt=2 board-htckaiser.panel_type=1 hw3d.version=1 board-kaiser-battery.battery_capacity=1350 board_htckaiser.pmem_size=4 board_htckaiser.pmem_adsp_size=1 clock-7x00.a11=500"
boot
do I need to use another haret or initrd?
yesterday I left the phone connected to the charger all night and when I woke up (about 5hours and 30 minutes later) it had the green light turned on so it means that it got charged full, and dmesg gave something like this: 4180mv 28mAh and 100/100 (2076/2076 units) I gotta tell you, I had never seen such "low" values on units, its kinda strange, anyways I unpluggued it and went to work, so here I am, I´ll report back in a few hours after I stress this thing a bit to see if it really got all the "juice" the battery can take.
ps: I haven´t tried putting the 1350 (MAh) in advance setting, because since it says that it is charged (I know it may still be wrong) I decided to give it a go to see how it works with the current settings, after finishing testing this, I´ll try with 1350.
I don't know the HARET problem, sorry. Everything you are doing looks right to me. Perhaps you need to wait until this experiment is mature enough to be in a dzo kernel. Sorry!
Sent from my Full Android on Vogue using XDA App

[Q] Do I really need to calibrate battery after ROM change?

If when fully 100% charged my phone battery voltage shows 4199mV(same as when it was with stock unrooted rom), do I need to calibrate still?
Second: To do calibration on my desire hd is it enough just to delete batterystats.bin file when my phone is on 100%/max voltage charge? Then use it as normally? Because I read like few methods to do that(like delete the file--->full discharge-->full charge or delete the file--->that's all, use it normally).
Sorry to bother you with, I am sure, such a easy noobish questions answered 300 times in 1000 threads, but I read so many opinions... some even say after calibration their actual battery life degrade? Thanks for your answers!
If its working fine for you there is no need to calibrate.
The proper method to calibrate is to charge until the battery takes no more current (ie Current Widget shows 0 milliamps) then delete batterystats.bin, unplug the charger, fully discharge until it turns off, then fully charge.
Its impossible to degrade the battery life by calibrating. Calibrating shows a more accurate reading of the actual charge. That only means that these people who have experienced a "degrade" were used to values that were higher than they were meant to be before and calibration corrected it.
on the market, you have very nice app, is called: "Battery Calibration", easy to use, recommended.
I used "Root Battery Calibrator" myself. It has a little red robot as an icon. But all these apps do is delete BatteryStats.bin so they are kind of useless if you know what you're doing with the system files and directories.
clockwork mod also deletes BatteryStats.bin, so i think it's an easy with this app, because i dont need to go to clockwork just to delete batt stat.
Personally I believe it's good to do a calibration after flashing a new ROM.
I do calibrate the battery every time after I update or flash a new ROM.

[Q] Battery History

Hi,
I'm running stock JB 4.1.1 (flashed the GSM version when it came out) on my gnex and as of recently, my phone doesn't charge over 72%. My battery history doesn't make any sense, it gives me the history of the last 20+ days, which is a bit useless. My battery life isn't bad, I get a full day of normal use. Just the stats are messed up.
Anybody ever experienced something similar or has a hint the problem is?
thx
rabelanger said:
Hi,
I'm running stock JB 4.1.1 (flashed the GSM version when it came out) on my gnex and as of recently, my phone doesn't charge over 72%. My battery history doesn't make any sense, it gives me the history of the last 20+ days, which is a bit useless. My battery life isn't bad, I get a full day of normal use. Just the stats are messed up.
Anybody ever experienced something similar or has a hint the problem is?
thx
Click to expand...
Click to collapse
If your phone is rooted you can do the battery recalibration from Cyanogenmods wiki (you don't need CM to do this):
1) Charge the device to full battery; let it keep charging until the battery says it is fully charged. Do not just wait until the light is green, it isn't always fully charged, causing a lot of inaccuracies. (You can check by going to: Settings » About device » Status » Battery Level = Full.)
2) Boot to recovery mode and delete the battery stats (in the advanced menu of clockworkmod's custom recovery). Keep charger plugged in.
3) Reboot the device immediately after wiping the battery stats and wait for [your system] to boot completely to the desktop. Once your entire boot is done and you have full access to the device, go ahead and pull the charger and continue with this troubleshooter.
4) Do not charge the device until after draining the battery completely, resulting in it automatically shutting off. Recharge the device completely and then use as you normally would.
Does this sound like what you are looking for or are you after something else?

Abnormal Battery Levels

Hi, i'm running Paranoid Android 2.52 and since the last 5 days or so I've me experiencing the two following situations: the battery is fully charged, i start using the phone and it discharges normally, but when I load a heavier app it just shuts down suddenly with a low battery warning. the other situation is when i connect the phone to the wall charger after this issue, it starts charging normally but then it just jumps right to 100% with the same speed that it went down. Already checked the usage statistics but cant seem to find whats causing this, the battery just goes down abruptly.
Thoughts, anyone?
Try a different rom.. I recommend a Gingerbread rom with a kernel that supports battery calibration like Oxygen Rom. If there is no improvement after using the rom, calibrate the battery with this guide. http://forum.oxygen.im/viewtopic.php?id=723
If there is no difference, your battery is probably shot.
I've tried wiping the battery stats several times, re-flashing the rom, scripts and gapps, calibrating the battery and flashing rooted stock desire rom.
Is this method any diferent? I want to avoid moving to another rom if I can, i have tried several and i really like my current one.
EDIT: okey, I did as you suggested, flashed oxygen and followed the calibration steps. I was quite hard as the phone shut down as soon as the voltage level drop bellow 3201, but i managed. I experimented for a while on oxygen and the battery acted just the same as before. i have now reverted to jb, this time on AOKP v2.1. Is my battery ready for a replacement?

BATTERY NOT CHARGING - S4 MINI i9190

Hi
I flashed lineage 14.1 OS over the manufacturers stock ROM about 3 weeks ago. The Lineage ROM had issues BUT the battery was still charging normally. (Worth noting that the battery was also charging perfectly fine on when the manufacturers Rom was still installed). Seeing as Lineage 14.1 had a host of other issues, I then flashed AOKP's version of Pie with GAPPS Micro. At first, the battery would charge until 53%. However after it drained to 0%, it has not charged properly since. (6 days or so).
A) Battery is about 6 months old, so relatively new
B) non-charge problem started with installation of AOKP version of Pie
C) I have used a couple of battery health apps,which reveal the following:-
c.1) Battery health is fine
c2) Voltage 3.5V (essentially 0% charge)
c3) amperage averaging around 30mA
c4) Battery Manager and other apps state that the battery is "connected but not able to charge"
D) I have tried deleting the batterystats.bin file, which had no affect
E) I have tried using recalibration apps off Google Play Store with no affect.
F) I have cleaned the USB port and tried different cables, also with no affect.
I'm going to try flash another OS shortly. Other than that my last idea is to purchase a new battery. HOWEVER just thought I'd ask if anyone has any other bright ideas as to what might have happened to a perfectly functional battery? Another thing worth mentioning is that the power button on this device doesn't 'click' anymore. So one cannot feel that the button has been pressed, you have to press harder to ensure that the device powers on. It was like that for a long time before this battery problem started but thought I'd mention it. Can a faulty power button be causing a massive power drain on the battery OR be stopping it from charging?
EDIT - when the phone is off and plugged in to the charger, the battery icon shows it as "charging". However if I leave it for a few hours and switch the phone on again, it still reflects as 0% charged and only switches on with the power cable attached. Also I cannot get into recovery mode, after shutting down, unless I leave the phone plugged in and "charging" for a while. It's like recovery mode needs at least some power from the battery.
Debcal said:
Hi
I flashed lineage 14.1 OS over the manufacturers stock ROM about 3 weeks ago. The Lineage ROM had issues BUT the battery was still charging normally. (Worth noting that the battery was also charging perfectly fine on when the manufacturers Rom was still installed). Seeing as Lineage 14.1 had a host of other issues, I then flashed AOKP's version of Pie with GAPPS Micro. At first, the battery would charge until 53%. However after it drained to 0%, it has not charged properly since. (6 days or so).
A) Battery is about 6 months old, so relatively new
B) non-charge problem started with installation of AOKP version of Pie
C) I have used a couple of battery health apps,which reveal the following:-
c.1) Battery health is fine
c2) Voltage 3.5V (essentially 0% charge)
c3) amperage averaging around 30mA
c4) Battery Manager and other apps state that the battery is "connected but not able to charge"
D) I have tried deleting the batterystats.bin file, which had no affect
E) I have tried using recalibration apps off Google Play Store with no affect.
F) I have cleaned the USB port and tried different cables, also with no affect.
I'm going to try flash another OS shortly. Other than that my last idea is to purchase a new battery. HOWEVER just thought I'd ask if anyone has any other bright ideas as to what might have happened to a perfectly functional battery? Another thing worth mentioning is that the power button on this device doesn't 'click' anymore. So one cannot feel that the button has been pressed, you have to press harder to ensure that the device powers on. It was like that for a long time before this battery problem started but thought I'd mention it. Can a faulty power button be causing a massive power drain on the battery OR be stopping it from charging?
EDIT - when the phone is off and plugged in to the charger, the battery icon shows it as "charging". However if I leave it for a few hours and switch the phone on again, it still reflects as 0% charged and only switches on with the power cable attached. Also I cannot get into recovery mode, after shutting down, unless I leave the phone plugged in and "charging" for a while. It's like recovery mode needs at least some power from the battery.
Click to expand...
Click to collapse
Does anyone know of a battery app/ software that one can run in recovery mode OR prior to booting? I'm wondering if this battery problem is software related or hardware related.
Debcal said:
Does anyone know of a battery app/ software that one can run in recovery mode OR prior to booting? I'm wondering if this battery problem is software related or hardware related.
Click to expand...
Click to collapse
Now, it appears, I cannot even boot into TWRP recovery. I suspect the non-charging battery is the problem.
Debcal said:
Now, it appears, I cannot even boot into TWRP recovery. I suspect the non-charging battery is the problem.
Click to expand...
Click to collapse
You won't believe it!!! After trying every solution known to man, turns out that the battery just doesn't sit snugly in the phone, so it doesn't make good contact. ???*♂??
Charging now that I manually pushed it up against the contacts.

Categories

Resources