yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] dvgrhl:
OK, I cleaned up a lot of the code for the app today, and I think I resolved the bug where the alert dialog would constantly pop up once the learn flag was set on.

Here's the latest version to test out: http://jonrichards.net/xda/BatteryApp20101127.zip

I'm going to work on adding a sound alert to accompany the on screen alert. I'll also work on having the screen stay on if detect learn mode is set.
[Nexus One Android Development] j3di:
Thanks, I think I'll try it in airplane mode next time so that it can charge undisturbed.
[Nexus One Android Development] dvgrhl:
OK, there is now a sound played when the alert is displayed for when learn mode is reached. Also, if you have detect learn mode on then the screen will stay on. It will still dim after a certain time frame, but it won't turn off.

http://jonrichards.net/xda/BatteryApp20101127.zip
[Nexus One Android Development] chowlala:
Nice work. Downloading it now. Will report and feedback my findings.
[Nexus One Android Development] mtw4991:
Nice job dvgrhl, must test in the morning as my batt is around 50% now.tomorrow should be a good day
[Nexus One Android Development] temasek:
Your work is very much appreciated.

Your first battery app I actually did a successful learn mode. I was pleasantly surprised when the dialog box prompting plugin now.

Nice job!
[Nexus One Android Development] mtw4991:
Ok, I'm confused. Did a full on-charge from auto-shutdown. Jumped from 82% at 1260mAh and 4187mV to 100% at 1542mAh and 4187mV. I have full40 set to 1558, aEv set to 3201.

Does this mean my battery's age is 82%?

Does this mean battery age is 90% (1260/1400mAh)?

Does this mean battery age is 86.7% (1260/1452mAh)

I'm not sure what to reset my age to here???? 0x14 ??
[Nexus One Android Development] chowlala:
I would assume, your battery age is 82. What's your full40 set at?
[Nexus One Android Development] mtw4991:
Chow, it's set to 1558.
[Nexus One Android Development] chowlala:
Then your true battery age is 82 not any of the other higher values because our batteries are 1400 mAh. Unless you're using a 1600 one?
[Nexus One Android Development] zdiamant:
Ok.. First of all, thank you for all your hard work in figuring out all of this info.. I have spent the last 3 days reading every post in this thread and the brainstorm thread. I have an issue that was briefly talked about but not solved to my satisfaction. My N1 dies while still having plenty of battery voltage left (avg 3.5 to 3.6 mV), while my mAh drops to zero. How can I properly calibrate this battery?

For now, I changed the 0x10 register so I have more mAh to try to get my mV down so I can enter learn mode. My question becomes, after entering learn mode and charging, should this phenomenon be resolved?

Thanks
[Nexus One Android Development] temasek:
For a proper calibration, set your age to 100 and drain your battery. Use the battery app and monitor your mV and mAH balance. Your mAh must not die before your mV to get a proper learning.

Use the battery app and set the detect learn mode on. Plug-in your charger but do not turn on yet.Closer to your empty voltage (I suggest 3.201mV) read your LEARNF (learn flag). When your mV hit close to your empty voltage, by right your LEARNF will light up and a dialog will prompt you to plug-in to start charging. If you reach this step you just hit learn mode and don't be happy yet cuz you may time out before full charge.

Let it charge till full. After several hrs when you hit full charge, reboot (if during learn mode your phone did not auto shutdown). Upon reboot (if necessary) your battery should read correct age and you are considered calibrated. Your phone can now drain from 100% to 0-1%.

Good luck.
[Nexus One Android Development] temasek:
Your max capacity now is 1260mAh due to wear and tear. If u set your full40 higher, your age will be lower. If full40 is lower, age is higher. So it makes no different.

N1 comes with battery of capacity 1452mAh.
[Nexus One Android Development] RogerPodacter:
Hey guys glad to see a lot of you are now understanding the relationship between full40 and age and how learn mode works. Good to see the app worked for some. I'm baffled why some people do not see learn flag turn on yet do see the other 2 flags turn on. Only thing I know of is running out of mAh, maybe from a wrong full40 value or not having age set to 100.

Now that I'm back I'll take a look at the revised app and we'll try to get another version out. If you have any specific questions I'll try to answer them. Later.
[Nexus One Android Development] samarium:
Recently if voltage was more than 1V above AEV and capacity was < 100 mAh, I've been doing echo 10 1 > setreg. If after that voltage was still above AEV and capacity was < 1/2 what was delived by echo 10 1, I've been doing the echo 10 1 again. Sometimes it didn't appear to be working and I've been repeating it, however it may also be related to the bit in the data sheet saying values are only calculated every 3.5 sec.

Anyway, this seems to be working for me, although sometimes I still just get the phone shutting down and capacity going from 100 mAh to 0 in one step even though > 3.5V.
[Nexus One Android Development] triciopa:
Maybe in the about option on the app you can include the meaning of each of the flags? Just a suggestion . Great work!
[Nexus One Android Development] j3di:
#noob question coming# #WARNING!#

Disclaimer# I'm running the WildMonks kernel with the latest commits in. I've also been through both Battery Threads, even looked at the Precentral links.

I'm not understanding the echo commands, if i'm doing it correctly I'm entering the commands in terminal on the phone but I get an error each time saying cannot create setreg: read-only file system.

echo 0x14 80 > setreg

I just need to set age to 100 so I can try and hit the LEARNF before running out of mAh...
[Nexus One Android Development] theloginwithnoname:
Are you root at the time?

(use whoami command to find out!)
[Nexus One Android Development] xp24002000:
not working for me

tried over and over, i reached 3201mV, popup flag appear, plug in charger cord quickly, red led confirm charging, and then after 10-15 sec of charging, phone shutdown each time, tried even turning lcd off, the same after 10-15 sec of charging with lcd off screen popup with airplane mode and sense lock screen, shutdown dialog box appear and phone automaticaly power off.
[Nexus One Android Development] klaydze:
Where can i actually set the "aEvolts" and "Stop Charging Current" under LearnPrep tab?

The only input field that i can see is the "Register: 0x" and "Value:"

"Advance Options" in the Settings is already ticked but then, there still no "aEvolts" and "Stop Charging Current" input field.

Thanks

----------------------

Darn! My phone dies before reaching 3201mV (3250mV to be exact). How do i calibrate that if that's the behaviour of my battery.
[Nexus One Android Development] St4hli:
You just have to do what's described in the brackets ;)
[Nexus One Android Development] :
Hi guys, just wondering if you could make this work on the Motorola Atrix 4G. We are having problems with the battery percentage not reaching 100%. A lot of people would appreciate it.

Sent from my MB860 CM7 RC1 37p Radio
[Nexus One Android Development] RogerPodacter:
I already tried to edit the atrix driver last year when I owned that phone, its just not possible unfortunately. Motorola is using some generic fuel gauge we don't know which, and they hide some of the kernel code for battery. Sorry.
[Nexus One Android Development] :
N00b question : how can I edit a /sys text file and make the change stick?

Sent from my MB860 CM7 RC1 37p Radio
[Nexus One Android Development] RogerPodacter:
Two ways I can think of. Either change in the kernel code whatever value is making it default to that value. But sometimes that value comes from the hardware that defaults upon boot, so you can't change it.

Or write a boot script or init d type script to set it manually each boot up.

It really depends on which hardware or sysfs file you're looking at.
[Nexus One Android Development] temasek:
Nice to see that father of N1 battery calibration is still active here. :)
[Nexus One Android Development] ahac85:
hi just want to know im understanding this write, after battery age is dedicted we just update our FULL40 value thats it?

we leave aged capacity as 1393, or do we have to update that aswell?
[Nexus One Android Development] hgmichna:
Simplest method

What is the simplest method to recalibrate the phone/battery combo? Since the phones are usually already designed to recalibrate themselves, what do you have to do to trigger that procedure and let it run its course?

I see different recommendations, charge from totally empty to full with phone on, phone in airplane mode, phone off. Discharge first with phone on, restart after discharging and wait for shutdown two times, three times, hold the power button for 10 seconds, plug in the charger while the phone is shutting down, etc. Not everybody seems to know what he's talking about. Most of it is bound to be nonsense, but where is the truth?
[Nexus One Android Development] RogerPodacter:
This thread answered that question precisely, but only for the nexus one with its fuel gauge and battery. It all depends on the phone. Each uses a different fuel gauge chip, so you have to learn that info first. But after I studied for this project and read up on all the fuel gauges in use out there I'll give you my insight.

Basically there is nothing you can do typically. Charge then discharge, charge phone off, plug in for 8 hours, it all has zero effect. The voltage points are hard coded and nothing you do will change it or re learn or calibrate it. Its like a dumb chip, it doesn't know or care.

However this isn't always true. In the case of this thread we discovered this battery chip has a learn mode, and we had to root to enable it.

Many htc phones use similar chips so its possible you could do something similar. Depends on the model.

Most Samsung phones use the "dumber" chips and are unchangeable, nothing you do during charge will have any impact. Day 1 will act like day 300 from the battery perspective.

However the new sgs3 looks like it may use a more smart fuel gauge and could possibly have calibration functions. Root needed first of course.

That's basically it. Nothing you can do. The battery doesn't know if its day 1 brand new or a year old. That's how I use it anyway, I just plug and go. No top off charge, no full cycle first, no drain to empty, etc. None of it, cause we learned that it really makes no difference.
[Nexus One Android Development] hgmichna:
Thanks for the good information! Let me try to put things in perspective.

The Nexus One has a learn mode and can be calibrated, but the calibration becomes necessary only because it is already misdesigned and does not learn automatically.

Learning automatically should be almost trivial with the simple assumption that a Li-Ion battery is full around 4.1 to 4.2 V and empty around 3.2 to 3.4 V. If the phone can measure the battery current, determining the battery's capacity during a continuous empty-to-full load cycle is, indeed, trivial.

Let me ask a slightly different question: How can a normal user recalibrate his unrooted Nexus One?

Additional questions:

Does the unrooted N1 also go into learn mode as the battery goes empty? What is the best way to make sure it is in learn mode?

Why are people recommending to attach the charger quickly after the battery has gone empty? This does not seem to make sense. Is it the consequence of yet another misdesign?
[Nexus One Android Development] theloginwithnoname:
As Rog says, it has been answered already (here).

Couldn't tell you, only that it works but is temporary.

Good luck.
[Nexus One Android Development] hgmichna:
That posting did not say whether the N1 would have to be rooted or not. I take it that the procedure works on unrooted Nexus One phones as well.

As to the requirement of plugging in the charger during the few seconds while the phone shuts down on its own, this does not only sound strange, it also conjures the image of thousands of N1 users worldwide, staring at their phones while holding the phone in one hand and the already connected charge cable in the other, waiting subserviently for the phone to shut down. Perhaps the person who invented this rule now has his fun while thinking about all those stupid users following his new cargo cult.

More seriously, if anybody finds that beginning to charge the phone much later, long after it has shut itself down, also leads to learn mode and works just as well, please let us all know. Or perhaps one can restart the phone much later and then wait only one minute for it to shut down again. Would that work? Or you could recharge it for just a minute, then let it go down again, which also would not take very long. I think, if any of these procedures worked, it would be a big improvement over having to put matches between your eyelids while waiting an eternity for the shutdown. :)
[Nexus One Android Development] theGanymedes:
Let me try to add up what I know here too, as a guy who fiddled with the battery driver as well :)

As @hgmichna told, normally the chip is supposed to calibrate the battery accordingly with the usage. However, I've seen that due to a driver bug (or actually it's not a bug but rather a "wrong assumption") the Sense battery drivers overwrite the calibration data after each charging to full level; thus making the chip useless about the calibration.

Another issue is about the phones: even though the bug is "fixed", the chip still (I really don't know why) runs on "offline" mode when the device is on but not charging. This makes the chip run on bare minimum configuration; thus not running some algorithms like "calibration algorithm". Even though it's possible with a hack to make chip run on "online mode", the effects (side or desired) are unknown yet - someone should test the effect in a long time usage and it's not me :).

Thus, making the calibration yourself seems to be most "feasible" solution that yields the results in shorter time span. After all, calibration is not that frequently needed: one calibration per year is fairly enough most of the time.
[Nexus One Android Development] theloginwithnoname:
every 100 battery cycles ("charge to full battery") is best ;) remember, to keep it you need to charge the device ON - i reverted to airplane and silent modes instead of turning the device off, such was my need/wish to know my battery remaining was accurate to 0%
[Nexus One Android Development] hgmichna:
I have also successfully recalibrated my Nexus One, charging in Airplane mode, but this contradicts the very explicit advice given in the very first message of this long thread.

Has anybody successfully calibrated, while charging it powered down? I mean, run it until it shuts down on its own, plug in the charger and let it charge without restarting it?

I am also getting curious about other phones. Any knowledge there? How do they usually calibrate their battery meters?
[Nexus One Android Development] theGanymedes:
I already described the steps needed in order to be able to charge off... It's a few pages behind ;)
[Nexus One Android Development] hgmichna:
But wasn't it refuted a few pages later? :D
[Nexus One Android Development] RogerPodacter:
The reason you have to plug in quickly right before empty is because that's the only time the learn flag is activated, but this is also what shuts down the OS. So you only have a few second window.

And yes non rooted could still activate this learn mode, I did it once only. Its extremely difficult. You won't know when the learn flag flips until the phone already begins shutting down. That's why I had to modify the driver. But yes you could also just leave the phone off and charge, but you won't be seeing if the learn flag is actually on. And subsequent boot up sometimes clears the status register thus wiping your learn and new age value since this chip is so fussy.
[Nexus One Android Development] hgmichna:
Thanks for this crucial bit of information.

A way out of the nearly impossible situation of sitting in front of the phone waiting for it to shut down could be to just let it shut down and then reboot it once more. Usually, after a little waiting time, the battery still has enough power to start the phone, or you could recharge it for a minute. Then wait again. This time the wait will be short. I would hope that such a second shutdown would also activate the learn flag.

One could do it once a month or just occasionally. If it worked every second time on average, fair enough.
[Nexus One Android Development] ForMartha:
did every thing but the phone stucks on 85% while charging in learn mode..

what should i do?

unplug the cable or wait?

BTW the charge light is orange.. if thats helps..
[Nexus One Android Development] hgmichna:
Bad charger? Bad cable? Bad phone? Are they all parts that came originally with the phone?

It makes no sense to wait longer than one hour if the charge percentage does not get higher. Unplug and retry, ideally with another charger.
[Nexus One Android Development] ForMartha:
mm.. its a nokia charger (not the original one), you think that's affect the battery mischarge?

if it starts charging then i think its not the charger problem.. :/
[Nexus One Android Development] hgmichna:
You charge a Google Nexus One phone with a Nokia charger?

Could it be that you don't know where you are? Read the brown-on-white breadcrumbs line at the top.
[Nexus One Android Development] ahmgsk:
please help

guys please make this app work for the following kernel

HTC Official Gingerbread 2.3.3 v3.14.405.1 (Stock Sense 1.9)

- Kernel: 2.6.35.10-gb-sense v8 - by dbasabe

my kernel does not seem to have the support. when i install it, i dont get any values on the first page so the other modes are of no use :mad::mad:

it would be great help...

my phone is dying at 20 percent without any low battery warning or anything...

i am using hyper sense nova and its giving 10-12 hours battery on light to moderate use from 100 to 20 and then it abruptly shuts down....

at this point of time if i restart the phone shows zero battery and shuts down again :confused::confused::confused::confused:

however if i charge for even 2 to 3 minutes or so and the battery reaches say 7 percent or a little more to say 17 percent in a little more time the pecentage battery gradually reduces with usage giving low battery on 20/15/10/5 percent respectively and then finally shuts down at 1 percent or so....

i really love this sense rom and do not want to switch to other roms... plz help :crying::crying::crying::crying::crying:....
[Nexus One Android Development] theGanymedes:
Did you ever charged your phone off after the calibration? This might be the reason it shut down at 15% again... Unless you "tweak" the full40 value manually; you should never charge your phone off after the calibration.
[Nexus One Android Development] hgmichna:
What do you mean by "charge your phone off"?

As I had already described, I discharged the phone until it shut down on its own. During this auto-shutdown process, before the phone was completely powered down, I connected the charger.

I let the phone connected to the charger until I was sure that the battery was completely full, i.e. light changes from orange to green, then charge at least another hour.

Then I powered up the phone, while the charger was still connected. I waited until the phone was fully operational, then I disconnected the charger.

I kept using the phone, observing the charge indicator, only to find that the phone still auto-powered down around 15%. In other words, following the instructions to use the built-in learn procedure had no effect at all.

In my last test I altered the procedure and powered up the phone immediately after connecting the charger, then went into airplane mode. The ultimate effect was the same, none.

In an earlier test, when I used the Battery Calibrator app to detect learn mode, I did get one complete discharge cycle, down to 1% or 0%, but after the next complete charge the phone was back to auto-shutdown around 15%. Here the learn procedure was successful at first, but the success did not last.

While I'm at it, yesterday I did another test. I used Battery Calibrator to set my battery age to 79% (calculated from the auto-shutdown point). The first result was a new defect. The phone showed 100% after being powered for one night. That is obviously wrong and has never happened, before I used the program.

All in all my experience is devastating. Nothing works nearly as described or nearly correctly. I am about to give up and consider the procedures described here and Battery Monitor defective. Perhaps they are just highly unreliable, but that would be bad enough. And they seem to require an unreasonably high effort for very little effect.
[Nexus One Android Development] theGanymedes:
I meant whether you charged your phone when it was off; but as you've written, you did it. there is your mistake here: You must not charge your phone while it's off; unless you apply the tweak I mentioned earlier (full40 hack - search the topic and you'll find it)

Next time, before you mark as the topic "defective", try reading the topic.. I've even made a kernel distribution with the information in this topic, and I'm also a living proof of these topic that it works. You just simply missed the very warning available in the first couple of pages.

If you had made a research about charging while your phone off, you'd already see that you shouldn't do it unless you hack full40 value.

And, to answer your question, the fault that requires us to do calibration is within the battery driver, not in the chip. There are a few kernels now, both for sense and aosp, that solves this problem now.
[Nexus One Android Development] hgmichna:
Not quite, my last attempt was to switch it on again and charge it while it was running. Of course I had to connect the charger first, then switch on the phone, because the battery was empty.

Thanks for the info! My original question was whether there is a simple method that anybody could use without having to apply elaborate fixes. Changing the kernel is certainly out of the question for the ordinary user.
[Nexus One Android Development] aledex:
I have a problem with my HTC Desire with ICS. I put "detect learn mode ON" but as soon as I exit the app, it completely shuts down and doesn't remain in the background.

I think it could give me problems during the learning mode... How to fix this?
[Nexus One Android Development] DarsVaeda:
Hi,

I have a Nexus One with an aftermarket battery (andida 1800mAh).

I try to calibrate it but when I enter the 1800 into the field "full40" it always states "Current Full 40: 27306 mAh".

Is this correct?
[Nexus One Android Development] agrajaghh:
Hi guys,

I have some troubles calibrating the original battery of my htc desire. I followed the instructions from: http://xdaforums.com/showpost.php?p=24599586&postcount=284 but it's still not working. And I tried it already 3 times..

I did the charging yesterday in airplane mode and with screen switched off for ~8h (over night) but the battery age was still 100% after unglugging and switch off and on again. The aged capacity was displayed at 1393mAh.

But now after using the phone it died again at 18% :( After pluging the charger and booting again, the age is of course 94% again...

What can I do? Whats the Problem?

P.S. I'm using MildWild CM-5.0 (http://xdaforums.com/showthread.php?t=1453287) based on CM7.2
[Nexus One Android Development] agrajaghh:
anybody an idea? the battery is driving me crazy...
[Nexus One Android Development] Drapsthomas:
interpreting the results

after my learn mode test.. my new battery age is 82% and aged capa is 1393.. is this what i should be expecting?