The battery meter in the corner of a phone's screen might make you think that you’re seeing a perfect, standardized measurement, but the reality is sometimes a little closer to the guess-your-weight booth at the carnival. Indeed, there’s a good chance your phone died despite proudly proclaiming that its battery has, say, 23 percent charge left, or your tablet hung on at 2 percent for what seems like hours. We’ve talked at length about how to squeeze more power from your smartphone battery and which chargers are best when your device is about to power down. But we don’t often discuss exactly why it’s so hard to predict batteries’ run time and state of charge to begin with.

One way to understand some of the electrical concepts happening inside your phone is to use the analogy of an opaque water barrel, where the water it contains represents the power a battery can hold. (Visualizing water flows is a lot easier than trying to imagine invisible electrons.) Because you can’t see inside the barrel and, for our purposes, you can’t measure its contents on a scale, you need an indirect way to figure out how full the barrel is. If you open the spigot at the bottom of the barrel and water shoots out with force, you know the barrel is pretty full. Likewise, a steady but less forceful stream might tell you that the barrel is filled to somewhere in the middle, and a trickle would tell you it’s almost empty.

Voltage in an electrical system is like water pressure in a plumbing system. In your home, water pressure is constant and the supply is effectively unlimited; similarly, an outlet’s voltage is constant and the supply of electricity is effectively unlimited. But with a barrel, the amount of water is limited, and the water pressure diminishes as the barrel empties. Similarly, the amount of power in a battery is limited, and voltage goes down as the power in the battery is used. The key to measuring a barrel’s content is to know how much pressure corresponds to a certain amount of water, so that you can use one to predict the other. Similarly, if a car battery’s output reads 13.2 volts when fully charged, and reads 11.8 volts when it’s unusably empty, you can use that scale (13.2 volts = 100 percent, 11.8 volts = 0 percent) to estimate the charge level in the future.

But it’s not quite so straightforward. The voltage change from 100 percent to 0 percent is not a straight line, but rather a curve—and it’s a different curve for every type of battery. And, as an indirect measurement, just matching the voltage to a chart doesn’t take into account other variables at play. For example, one major variable is the speed at which you drain a battery: The faster you drain it, the less power you’ll actually be able to use from the battery—in electronics, bigger, brighter screens and more-demanding processors require more power. So to know with any accuracy how long a device will last on the battery’s current charge, you also need to know how much power the device will draw at any given moment. Because power draw varies depending on what your device is doing, its software has to estimate how long the current charge will last based on your current draw, typical use, or some combination of the two—and lower-end devices generally don’t even bother.

If that wasn’t enough, batteries also lose a small amount of charge just sitting on the shelf. In our analogy, it’s as if tiny holes form in our water barrel as it ages, so the barrel slowly loses water. This is why your emergency flashlight doesn’t work after sitting in the closet for two years, and why your car won’t start if you haven’t driven it for a while. The good news is that batteries have gotten better in this respect over the years. Older cells, like the nickel-cadmium packs used in bulky VHS camcorders, would self-discharge 10 to 20 percent per month, or even more at higher temperatures. These days, built-in lithium batteries and rechargeable nickel-metal hydride (NiMh) AA batteries lose less than 3 percent per month—the rough equivalent of a tiny pinhole in the back of a 55-gallon barrel. Still, though that may not be much, it means your batteries do lose power.

There’s another problem to contend with when predicting battery life: Batteries lose capacity over time. We need to step away from our water-barrel analogy though. Instead, let’s think about a common household freezer. When warm, humid air gets in a freezer, it slowly cools, the water vapor condenses into water droplets on the freezer’s surfaces, and then those droplets freeze. Over repeated cycles of opening and closing the door, more air and water gets in, and the ice builds up. And when wear starts to affect the seals and hinges, allowing even more warm air in, the problem becomes increasingly worse. Before you know it, your freezer can fit a single TV dinner, and is surrounded by eight inches of ice on all sides.

Just like the layers of built-up ice in a freezer will eventually prevent you from putting as much inside, layers build up inside lithium batteries that will eventually prevent you from putting as much energy inside. Through a variety of processes with nasty names like “solid electrolyte interphase layer formation” and “electrolyte oxidation,” crystalline films are deposited on internal components at a molecular level that increase electrical resistance and decreases the battery’s overall performance. In the electrical world, added resistance means added heat, compounding the problem. Though high-quality batteries from reputable manufacturers have safeguards to prevent catastrophic failure (think “boom”), you’ll still be left with a battery that now only holds a fraction of a charge. Though you can defrost your freezer, there’s nothing you can do to reclaim the lost capacity of an aging device battery.

Batteries tend to balk at extreme heat or cold, performing best at room temperature.

Finally, just like most humans, batteries tend to balk at extreme heat or cold, performing best at room temperature. If the water in the barrel started to freeze, you’d lose more and more liquid water as the temperature dropped. A cold battery will lose usable capacity the same way; and if left out in subzero temperatures—like, say, Chicago in February—many batteries will stop working completely. On the heat side, some estimates say that a battery will lose up to 20 percent of its lifetime cycles (full discharges and charges) if it’s regularly operated at over 84 degrees Fahrenheit—a discouraging fact to anyone who lives in the desert Southwest.

Because the inside of this analogy barrel is a mess with variable pressures, rocks, pinholes, and ice cubes, the next obvious way to get information about the contents is to measure the water as you fill it up, and measure it again as you use it. Put in 40 gallons, use 15 gallons, and your barrel would have 25 gallons left. The battery version of this is called Coulomb counting, and your device’s battery-meter software does it by incorporating charge and discharge currents into its algorithms to help make the meter more accurate.

Taken together, all this information on voltage curves, the effects of aging, and changes in capacity over cycle life help form a data set that allows your device to make decent predictions about its battery’s current charge level. In fact, when a large hardware company tests a new battery or device, it will generally put dozens, hundreds, or more samples through tests to collect key data points. These tests make it easier to know—using our barrel analogy—how many pinholes there will be after a year and how the water pressure will change over the life of the barrel. The resulting algorithm might not always be right, but it’s likely to be a more accurate guess than one based on voltage alone.

So though the estimate on your battery meter isn’t always perfect, it isn’t outright lying to you. Between voltage, the current discharge rate, battery age, and the aggregate performance of its counterparts, it just has a lot to keep track of, and sometimes the resulting estimate just isn’t very accurate. In those cases, the best way for you to know how long your particular phone will last today is to keep in mind how it did yesterday—and keep an eye out for power outlets.

(Illustrations by Elizabeth Brown.)