Sunday, January 16, 2011

Estimating how long a battery can last on a single charge

One thing I've been curious about for some time now is how to calculate (or estimate fairly) how long a given battery is supposed to be able to power a device. It can't be as inefficient as fully charging a device then running it idle on battery until it drains out. What if it's not a brand new battery? How do I know if how long it lasts is the designed time period?

Seeing as the only mobile device I own is a mobile phone, and the fact that I have neither the knowledge nor the tools to measure how much power the thing's consuming, it just didn't motivate me enough to find out. Well, now I've found out. And it's surprisingly simple on a notebook running Linux. Ubuntu 10.10 in my case.

Batteries have ratings. Typically they'll be printed on the batteries as voltage (V) and mAh. Multiplying the two values in V and Ah gives you the total energy the battery is designed to store in Watt hours (Wh). Simple. Divide the value of mAh by 1000 to get Ah.

Ubuntu Indicators
Ubuntu's Indicators

The tricky part is to find out the rate the battery is being drained by the notebook. Thankfully, Ubuntu makes it easy. Run your notebook on battery and there'll be a battery power indicator in the top right corner. It'll be there with network indicator, session indicator, and all the other indicators. You can use that to open up a window showing your battery's stats.

Battery information
Battery information

The value you want is "Rate". That's how much average power your device is consuming. It's updated every few seconds. Divide the battery's max stored energy (Wh) by the rate of discharge (W) and you'll have an estimate of how long the battery should last on a single charge.

Ubuntu's power statistics includes the current and full energy for the battery so you don't even have to do the initial calculations yourself other than as a reference. "Energy" is how much charge is left in the battery, "Energy when full" is, of course, the maximum charge the battery can hold.