≡ Menu

Android Smartphone Battery Analysis

Please follow these instructions in order to use my battery analysis script.

 Current Widget Instructions

  1. Charge your phone to 100%.  While still charging, complete the following steps.
  2. Download Current Widget by RmDroider from the Google Play Store.
    • Please read the description for Current Widget.  As RmDroider says in the description, Current Widget will not work for certain phones (mainly Samsung) because the hardware or drivers for current widget to measure current are not included in the phone.  There is no fix for this.
  3. Add the widget to your home screen.  In doing this, a screen to select your widget options will pop up

    The settings page.

    The CurrentWidget settings page

  4. Under the General heading, set your update interval.  Faster interval equates to more accuracy and also drains battery a bit faster.  If you just want to do your test, make this 1 second.
  5. Under Log Options (which is under the Log heading) , make sure that Log Applications is not checked.  If you want to check Force Log In Sleep Mode you may.  In theory more data points leads to more accuracy, but I have not done the tests to see if the resulting change in output is appreciable or not.  If you want to make two runs and compare the output (obviously this is not a scientific/statistically significant comparison), please be my guest.  Post your results below if you wish.
  6. You should be set to go as far as setting the widget up.

Cycling Your Battery

For current widget to log the appropriate values, you need to have it log a full charge/discharge cycle.  If you do not log a full cycle, i.e. you submit your log without having fully discharged your phone, then the reading will not be accurate.

  1. Once current widget is installed, configured, and logging values you may unplug your phone.
  2. Use your phone until it is down to a low percent (the lower the better–I would do around 2 or 3.  Battery Indicator by Darshan Computing, LLC is great for this).  At this point, email your log to yourself or upload it to Dropbox or do whatever you can to get it off of your phone.  Not doing a full discharge does cause some small errors; I am trying to code a workaround that allows you to upload something like a full discharge and then charge and then the script sorts out everything but the full discharge.
  3. Make sure the script is of the format Date Time, current, battery percent.

    An example of the format for the CurrentWidget output log

    Your CurrentWidget output log should look something like this.

  4. Upload your output to the script to be analyzed.
  5. Comment on this post with your phone model and battery capacity  (and battery if you are not using the stock battery).  That way people can compare their phone against yours and others.  Also, if you do not mind, put your country.  I am interested in who is actually using my script (Google Analytics only tells me who hits the page, not who cares enough to go through the test and read the results).

The Code

If you are interested, the code is open source and can be found at https://github.com/nkhosla/battery_capacity.


Please understand that my script is not completely accurate.  There are inherent errors with trying to measure battery capacity like this, and although I am working toward minimizing them they do exist.  Additionally, I am not responsible for anything that happens to your phone as a result of installing the apps recommended above.  All recommendations are done so because I think the app mentioned does its job well, and for no other reason. By clicking the link below, you agree that I am not responsible for your actions and that you understand this analysis is not exact.

Continue to the analysis >>>

{ 43 comments… add one }
  • Gameberry_Wootae Wednesday, 1 February 2017, 12:34 AM

    I’m Wootae from Gameberry

    We are a mobile marketing company that has been working for leading advertisers such as LG, SK, Nexon and Konami since 2011.

    We would like to ask you if you want to monetize your traffic by our top leading offers.

    Looking forward to hearing from you.


  • Naveed Thursday, 29 December 2016, 10:47 AM

    The widget is not indicating ‘mA’. I’m using Samsung A7.
    Please solve the problem.

    • Nathan Khosla Tuesday, 3 January 2017, 12:20 AM


      I do not make the android app, so I cannot help support it. It could be that your phone doesn’t have the drivers for the app to use to read mA out of the battery. Some phones do not support this feature.


  • Giustina Thursday, 13 August 2015, 4:49 PM

    go away spammer.

  • Anonymous Thursday, 11 December 2014, 10:18 PM

    tried to upload and here’s the result..
    BTW, my phone is htc one x+ but using htc one x battery for the reason there is no battery for sale here in the country.. im in libya anyways

    A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
    /home/nkhosla/nkhosla.com/phone/battery_capacity_estimator.py in ()
    72 #instead of the UET value
    => 74 baseTimeHolder = dataArray[0][0]
    75 baseTime=getBaseSeconds(baseTimeHolder)
    baseTimeHolder undefined, dataArray = []

    : list index out of range
    args = (‘list index out of range’,)
    message = ‘list index out of range’

  • g0tn0name Thursday, 11 December 2014, 10:13 PM

    hi nathan.. got a problem with my log. it really logs too high and it also consumes too much of my battery. i want to send the full log but i dont know where.. ill just post log until 90%

    2014/12/11 10:18:26,-372000mA,100%,4.071V,18.9°C
    2014/12/11 10:22:48,-369000mA,100%,4.073V,18.7°C
    2014/12/11 10:28:26,-429000mA,100%,4.05V,18.9°C
    2014/12/11 10:38:26,-369000mA,99%,4.068V,18.7°C
    2014/12/11 10:43:26,-369000mA,99%,4.068V,18.7°C
    2014/12/11 10:48:26,-318000mA,99%,4.073V,18.7°C
    2014/12/11 13:22:48,-370000mA,99%,4.058V,18.3°C
    2014/12/11 13:28:27,-367000mA,99%,4.052V,18.3°C
    2014/12/11 13:31:06,-367000mA,99%,4.052V,18.3°C
    2014/12/11 13:32:06,-204000mA,98%,4.052V,19.6°C
    2014/12/11 13:33:07,-204000mA,98%,4.052V,19.6°C
    2014/12/11 13:34:07,-204000mA,98%,4.052V,19.6°C
    2014/12/11 13:35:07,-204000mA,98%,4.052V,19.6°C
    2014/12/11 13:36:07,-190000mA,97%,4.058V,24.2°C
    2014/12/11 13:37:36,-190000mA,97%,4.058V,24.2°C
    2014/12/11 13:38:36,-190000mA,97%,4.058V,24.2°C
    2014/12/11 13:39:36,-190000mA,97%,4.058V,24.2°C
    2014/12/11 13:40:36,-500000mA,97%,3.966V,26.5°C
    2014/12/11 13:41:36,-292000mA,96%,4.022V,26.4°C
    2014/12/11 13:42:39,-292000mA,96%,4.022V,26.4°C
    2014/12/11 13:43:41,-292000mA,96%,4.022V,26.4°C
    2014/12/11 13:44:46,-292000mA,96%,4.022V,26.4°C
    2014/12/11 13:45:46,-195000mA,95%,4.028V,25.6°C
    2014/12/11 13:46:46,-195000mA,95%,4.028V,25.6°C
    2014/12/11 13:47:46,-336000mA,95%,3.993V,25.9°C
    2014/12/11 13:48:46,-302000mA,95%,4.003V,25.8°C
    2014/12/11 13:49:46,-441000mA,94%,3.92V,26.0°C
    2014/12/11 13:50:46,-215000mA,94%,4.016V,26.0°C
    2014/12/11 13:51:46,-228000mA,94%,4.025V,26.2°C
    2014/12/11 13:52:46,-192000mA,94%,4.028V,25.9°C
    2014/12/11 13:53:46,-217000mA,93%,4.022V,25.8°C
    2014/12/11 13:54:46,-211000mA,93%,4.028V,25.6°C
    2014/12/11 13:55:46,-201000mA,93%,4.028V,25.6°C
    2014/12/11 13:56:46,-278000mA,93%,3.976V,25.8°C
    2014/12/11 13:57:46,-247000mA,92%,3.976V,26.6°C
    2014/12/11 13:58:46,-343000mA,92%,3.951V,26.4°C
    2014/12/11 13:59:46,-383000mA,92%,3.957V,26.6°C
    2014/12/11 14:00:46,-229000mA,91%,3.985V,26.8°C
    2014/12/11 14:01:46,-203000mA,91%,3.972V,27.0°C
    2014/12/11 14:02:46,-314000mA,90%,3.948V,26.8°C
    2014/12/11 14:03:46,-286000mA,90%,3.963V,27.0°C
    2014/12/11 14:04:47,-326000mA,90%,3.942V,27.0°C

  • Jus Thursday, 13 November 2014, 8:57 AM

    Hi Nathan, I tried analysing my log file and get an exception:
    /home/nkhosla/nkhosla.com/phone/battery_capacity_estimator.py in ()
    72 #instead of the UET value
    => 74 baseTimeHolder = dataArray[0][0]
    75 baseTime=getBaseSeconds(baseTimeHolder)
    baseTimeHolder undefined, dataArray = []
    : list index out of range
    args = (‘list index out of range’,)
    message = ‘list index out of range’

    My log looks like this:
    2014/11/11 08:06:50,-21mA,30%,3.74V,28.1°C

    And also I see that the gitbhub code has disappeared, so haven’t been able to try running this locally.

  • Pete Tuesday, 23 September 2014, 9:03 PM

    Hi. I have MI 3 and Redmi 1S phones. Current Widget works fine with MI3 but not with Redmi 1S. Can you help me?

    • Nathan Khosla Tuesday, 23 September 2014, 11:56 PM

      I wish I could, but I have no role in the development of Current Widget. My best guess would just be that the Redmi 1S does not have the necessary battery drivers in the kernel or possibly even in hardware support. Sorry!

  • doesntmatter Wednesday, 25 June 2014, 10:47 AM

    Wow, something is off by a long shot, I’ve just got this for a Nexus 5 (non-removable Li-Po 2300 mAh battery):

    Your battery capacity is approximately: 11589.3173611 mAh
    The data in your file spanned 146630 seconds = 2443 minutes

    • Nathan Khosla Tuesday, 23 September 2014, 11:57 PM

      So I have taken quite some time to reply, but if you do ever get this (if you put your email in on the comment field you should get an update), I would love to debug some. Just reply here. Thanks.

  • josef Sunday, 16 February 2014, 10:31 PM

    I installed the app on a droid razr m and nothing happens ie I don’t get any information. does this mean the app is not compatible with my phone?

  • Fabio Wednesday, 5 February 2014, 12:41 PM

    Hi Nathan, I have a white-label chinese tablet, but all the battery sysfs info is there:

    root@android:/ # cat /sys/class/power_supply/battery/batt_current
    root@android:/ # ls -l /sys/class/power_supply/battery/
    -rw-rw-rw- root root 4096 2014-02-05 18:39 batt_charging_cur
    -rw-rw-rw- root root 4096 2014-02-05 18:38 batt_current
    -rw-rw-rw- root root 4096 2014-02-05 18:39 batt_discharging_cur
    -rw-rw-rw- root root 4096 2014-02-05 18:35 batt_temp
    -rw-rw-rw- root root 4096 2014-02-05 18:39 batt_temp_adc
    -rw-rw-rw- root root 4096 2014-02-05 18:39 batt_temp_adc_cal
    -rw-rw-rw- root root 4096 2014-02-05 18:38 batt_vol
    -rw-rw-rw- root root 4096 2014-02-05 18:39 batt_vol_adc
    -rw-rw-rw- root root 4096 2014-02-05 18:39 batt_vol_adc_cal
    -r–r–r– root root 4096 2014-02-05 18:36 capacity
    lrwxrwxrwx root root 2014-02-05 18:39 device -> ../../../axp192_battery
    -r–r–r– root root 4096 2014-02-05 18:38 health
    drwxr-xr-x root root 2014-02-05 18:39 power
    -r–r–r– root root 4096 2014-02-05 18:35 present
    -r–r–r– root root 4096 2014-02-05 18:38 status
    lrwxrwxrwx root root 2014-02-05 18:39 subsystem -> ../../../../../class/power_supply
    -r–r–r– root root 4096 2014-02-05 18:36 technology
    -r–r–r– root root 4096 2014-02-05 18:39 type
    -rw-r–r– root root 4096 2014-02-05 18:39 uevent

    In spite of that, your Current Widget doesn’t display anything on screen. Just the widget “Lightning” icon and in the notification bar I can read “no data – no data – no data”.

    What am I missing? Note, I could rebuild kernel, if needed…

  • Anders Wednesday, 17 July 2013, 12:47 PM

    Where do I find the logfile?

    • Nathan Khosla Wednesday, 17 July 2013, 1:08 PM

      Why do you need to see it? Did you get an error? The script is very simple, so I have not added any type of diagnostics or anything. There is no logging. There is even no error catching. Probably a poor decision on my part, but whatever. Maybe I will eventually update the script to at least catch the error and notify the user. If you want to post a screenshot of the error I can probably help.


      • Anders Thursday, 18 July 2013, 3:27 AM

        Hi! I don’t actually need to see it. I just want to email it to myself as you wrote so I can upload it here. I think something is wrong. If I go to settings, log, log actions and view log I get the message “log file not found” Under log options log filename and log applications are grey.


        • Nathan Khosla Thursday, 18 July 2013, 12:22 PM

          Ah. OK. I see what the problem is. Ignore my previous post. I thought you meant an error log of the analysis script. I actually have nothing to do with the development of CurrentWidget. If you want to email the dev, you should use his email (it is listed in the Google play store somewhere on the CurrentWidget page).

          I can, however, help you with your problem. I played a lot with CurrentWidget in order to see what options I had for the analysis, so I know my way around it. Just to confirm, if you add the widget to your home screen you see nonzero values for current, right? If so, your problem might be that logging might not be enabled. If you look at my first picture, you see at the bottom of the screenshot there is a checkbox for ‘Log file’? You have to check that. Without it, CurrentWidget will not log anything.

          Sorry about that. My directions were unclear (I reread and nowhere do I say that that checkbox needs to be checked).

          Hope that helps,

          • Anders Friday, 19 July 2013, 2:54 AM

            Hi. Thanks for your answer. I saw “log file” in the settings but it said “don’t log values to file” so I thought that if I checked it, it would do like that. Now I see it changed to “log values to file” when I checked it 🙂 Hmm, it still does not work, but it is probably because I have a Samsung Galaxy Note. I also have a Nexus 10 I will try it on.

            Thanks for your time

  • R Tuesday, 11 June 2013, 11:21 AM

    Hi,how can i execute the script?
    in terminal??

    • Nathan Khosla Tuesday, 11 June 2013, 1:23 PM

      Well, there are two ways. The first way is as I intended, which is following the above instructions and uploading the output of CurrentWidget. At that point, my server runs the script and spits out a number for you.

      The second way is to download the source from GitHub, modify it to work on a computer as a not-server script (currently it is made to accept a file from an HTML form and then return the analysis as HTML). This also includes installing things like numpy, which is less than a good experience. If you know what you are doing and want to play around, this is a good way to do it.

      If you need any help doing the first method, just reply and I am happy to help.

  • Luis Vidal Saturday, 20 April 2013, 6:17 AM

    Thank you!

  • Lemming Friday, 15 March 2013, 12:06 AM

    Thanks for your great Tool, Nathan!
    HTC DHD, stock battery (it shows me 1230mAh), ROM JellyTime (beginning of March), Germany currently in Korea
    I sended you an email.

  • Spaqin Wednesday, 6 March 2013, 10:57 AM

    Oh, still no comments?
    shit man, I’m so sorry
    HD2, same ROM, official extended battery, got it from someone else recently, probably heavily used and that white dot is pink/purple/red, so it was wet at some point in the past, approx. 2063mAh (should be 2300mAh).
    Oh, I’m from Poland by the way if it really matters.

    • Nathan Khosla Wednesday, 6 March 2013, 1:19 PM

      Thanks. Google Analytics tells me people are hitting this page, and my script has been run a good number of times, so at least there is that. The comments were more to satiate my own curiosity.

      Your two comments make me curious about what is an expected degradation in battery capacity. Hmm…I have some time set aside next week to update the script, and my only goal was to make it filter out a discharge cycle from a log containing multiple charges and discharges (so that this ridiculous email to yourself at 1% battery can be avoided). Perhaps I will investigate if there are any models for what battery degradation should look like vs number of cycles (given otherwise ideal-ish circumstances, of course) that I can incorporate. Sort of like a guess at how many full charge equivalent cycles your battery has undergone.

      Thanks for posting,

      • R Monday, 17 June 2013, 9:32 AM

        Going to try it tomorrow..

  • spaqin Friday, 15 February 2013, 11:15 AM

    no comments? that’s sad 🙁
    HD2, stock battery (1200mAh), approx. 2.5 years old, ROM is Xylo’s PAC from 13 Nov 2012, capacity now ~975mAh.

Leave a Comment