1 Title: The life and death of a laptop battery
5 <p>When I get a new laptop, the battery life time at the start is OK.
6 But this do not last. The last few laptops gave me a feeling that
7 within a year, the life time is just a fraction of what it used to be,
8 and it slowly become painful to use the laptop without power connected
9 all the time. Because of this, when I got a new Thinkpad X230 laptop
10 about two years ago, I decided to monitor its battery state to have
11 more hard facts when the battery started to fail.</p>
13 <img src="http://people.skolelinux.org/pere/blog/images/2015-09-24-laptop-battery-graph.png"/>
15 <p>First I tried to find a sensible Debian package to record the
16 battery status, assuming that this must be a problem already handled
17 by someone else. I found
18 <a href="https://tracker.debian.org/pkg/battery-stats">battery-stats</a>,
19 which collects statistics from the battery, but it was completely
20 broken. I sent a few suggestions to the maintainer, but decided to
21 write my own collector as a shell script while I waited for feedback
23 <a href="http://www.ifweassume.com/2013/08/the-de-evolution-of-my-laptop-battery.html">a
24 blog post about the battery development on a MacBook Air</a> I also
26 <a href="https://github.com/jradavenport/batlog.git">batlog</a>, not
27 available in Debian.</p>
29 <p>I started my collector 2013-07-15, and it has been collecting
30 battery stats ever since. Now my
31 /var/log/hjemmenett-battery-status.log file contain around 115,000
32 measurements, from the time the battery was working great until now,
33 when it is unable to charge above 7% of original capacity. My
34 collector shell script is quite simple and look like this:</p>
39 # http://www.ifweassume.com/2013/08/the-de-evolution-of-my-laptop-battery.html
41 # http://blog.sleeplessbeastie.eu/2013/01/02/debian-how-to-monitor-battery-capacity/
42 logfile=/var/log/hjemmenett-battery-status.log
44 files="manufacturer model_name technology serial_number \
45 energy_full energy_full_design energy_now cycle_count status"
47 if [ ! -e "$logfile" ] ; then
58 # Print complete message in one echo call, to avoid race condition
59 # when several log processes run in parallel.
60 msg=$(printf "%s," $(date +%s); \
62 printf "%s," $(cat $f); \
67 cd /sys/class/power_supply
70 (cd $bat && log_battery >> "$logfile")
74 <p>The script is called when the power management system detect a
75 change in the power status (power plug in or out), and when going into
76 and out of hibernation and suspend. In addition, it collect a value
77 every 10 minutes. This make it possible for me know when the battery
78 is discharging, charging and how the maximum charge change over time.
79 The code for the Debian package
80 <a href="https://github.com/petterreinholdtsen/battery-status">is now
81 available on github</a>.</p>
83 <p>The collected log file look like this:</p>
86 timestamp,manufacturer,model_name,technology,serial_number,energy_full,energy_full_design,energy_now,cycle_count,status,
87 1376591133,LGC,45N1025,Li-ion,974,62800000,62160000,39050000,0,Discharging,
89 1443090528,LGC,45N1025,Li-ion,974,4900000,62160000,4900000,0,Full,
90 1443090601,LGC,45N1025,Li-ion,974,4900000,62160000,4900000,0,Full,
93 <p>I wrote a small script to create a graph of the charge development
94 over time. This graph depicted above show the slow death of my laptop
97 <p>But why is this happening? Why are my laptop batteries always
98 dying in a year or two, while the batteries of space probes and
99 satellites keep working year after year. If we are to believe
100 <a href="http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries">Battery
101 University</a>, the cause is me charging the battery whenever I have a
102 chance, and the fix is to not charge the Lithium-ion batteries to 100%
103 all the time, but to stay below 90% of full charge most of the time.
104 I've been told that the Tesla electric cars
105 <a href="http://my.teslamotors.com/de_CH/forum/forums/battery-charge-limit">limit
106 the charge of their batteries to 80%</a>, with the option to charge to
107 100% when preparing for a longer trip (not that I would want a car
108 like Tesla where rights to privacy is abandoned, but that is another
109 story), which I guess is the option we should have for laptops on
112 <p>Is there a good and generic way with Linux to tell the battery to
113 stop charging at 80%, unless requested to charge to 100% once in
114 preparation for a longer trip? I found
115 <a href="http://askubuntu.com/questions/34452/how-can-i-limit-battery-charging-to-80-capacity">one
116 recipe on askubuntu for Ubuntu to limit charging on Thinkpad to
117 80%</a>, but could not get it to work (kernel module refused to
120 <p>I wonder why the battery capacity was reported to be more than 100%
121 at the start. I also wonder why the "full capacity" increases some
122 times, and if it is possible to repeat the process to get the battery
123 back to design capacity. And I wonder if the discharge and charge
124 speed change over time, or if this stay the same. I did not yet try
125 to write a tool to calculate the derivative values of the battery
126 level, but suspect some interesting insights might be learned from
129 <p>Update 2015-09-24: I got a tip to install the packages
130 acpi-call-dkms and tlp (unfortunately missing in Debian stable)
131 packages instead of the tp-smapi-dkms package I had tried to use
132 initially, and use 'tlp setcharge 40 80' to change when charging start
133 and stop. I've done so now, but expect my existing battery is toast
134 and need to be replaced. The proposal is unfortunately Thinkpad