More Grey Batteries · May 26, 09:23 AM
I posted a while back about getting replacement laptop batteries from unofficial sources. It looks like I’ve come unstuck with my second replacement battery which has failed after just a few months use. Here are some details on it, and an example of how you can use free tools (Perl and gnuplot) to illustrate just how bad a battery is.
OK so the battery was cheap, and the connector looked like it wasn’t made from top grade plastic, but it seemed to work. The first hint of it being a dud was that it didn’t seem to last long between charges.
As well as the short life it seemed to die suddenly. Thinking it might just be a bug in the power management or something, I ignored it, but the problem became much worse. Finally I ran a script to record the battery info as provided by the ACPI subsystem of the kernel.
Here is the Perl script, it can run as an ordinary user and will keep going (like it says) to the bitter end:
#!/usr/bin/perl -W
#
#
# battery-discharge.pl
#
#
use strict;
# to monitor battery discharge until the bitter end!
# using info from /proc/acpi/battery/BAT0/state
while (1) {
my $time=`date +%s`;
chomp $time;
my $info = `cat /proc/acpi/battery/BAT0/state`;
my $rate = -1;
my $cap = -1;
my $volt = -1;
for my $line (split /\n/, $info){
if ($line =~ m/present rate:\s+(.*) mA/){
$rate = $1;
}elsif ($line =~ m/remaining capacity:\s+(.*) mAh/){
$cap = $1;
}elsif ($line =~ m/present voltage:\s+(.*) mV/){
$volt = $1;
}
}
print "$time $rate $cap $volt\n";
sleep 5;
}
Running the script using tee I could watch the power sapping away: ./battery-discharge.pl |tee failing-battery.dat which produced a file like this:
1211785892 141 6600 12848
1211785897 141 6600 12848
1211785902 140 6600 12851
1211785908 -1 6600 12851
1211785913 -1 6600 12851
1211785918 1839 6600 12385
1211785923 1839 6600 12385
1211785928 1835 1881 12384
The left column is system time in seconds, the next is discharge rate, then remaining capacity and finally voltage. I chose this format so I could easily plug the values into a gnuplot graph. Note the brief anomaly where the charge rate is negative – that’s the instant I unplugged the mains, and it was downhill from there on. I noted the time 1211785918 as the ‘zero time’ for the graph.
Gnuplot is a great tool. It has a bit of a learning curve, and, if there are good examples or a detailed ‘cookbook’ out there, I haven’t found them yet. But here’s an example script that I used to make the graph below:
set title "Failing battery model DELL 00 / serial 2967 / OEM Sony\nfrom HKBAY shop in eBay"
set xlabel "time / seconds"
plot "failing-battery.dat" \
using ($1-1211785918):2 \
title "discharge rate / mA" with lines, \
"failing-battery.dat" using ($1-1211785918):3 \
title "remaining capacity / mAh" with lines, \
"failing-battery.dat" using ($1-1211785918):4 \
title "voltage /mV"
You can either put this into a script file and run it as gnuplot <file> or simply type it into the gnuplot command line. That’s not as painful as it sounds thanks to gnuplot’s extensive command line editing support. The end result is a graph like this:

You can see the voltage dropping gradually. As it does, the discharge rate rises to draw constant power from the battery. Just before 500 seconds, the battery gives up and the capacity hits the floor. Shortly after, the computer powered off. It didn’t even have enough time to do an orderly shutdown.
I have mailed the eBay seller, HKBAY, and received a reply offering a RMA, and, maybe suspiciously suggesting that I could send the battery uninsured and untracked to save myself some money… but I don’t fancy the chances of this packet of toxic waste ‘going missing’ and my chance of a replacement with it! So I will be sending it, with a copy of the graph for good measure, tracked and insured.
If it comes to the worst I will have to spend more money on an official battery – I have recently found a non Dell source that sells Dell parts at reasonable prices, so I might go for that instead of taking a chance with another eBay special.
<<<Fedora Desktop Background · Removing duplicate RPM packages>>>

