How do electronics know what battery percentage they have?

In: Technology

Most batteries have a different output (voltage) based on how full they are.

For example in a lipo battery (common hobby bats) a charged 1 cell battery will output 4.2 volts, and its “dead” when it reaches 3.0 volts. So around 3.6v would be 50% charged.

However you can overcharge and over discharge these batteries, but doing that may result in a bad time that usually involves fire and toxic smoke.

It’s an estimate. A clever one based on lots of calculations, but it’s still an estimate.

Imagine you have a dumb battery cell, and it outputs at a voltage. Say, 5V. That’s the only thing you can measure from a battery, is what the voltage is (temperature is also measured for protection against overcharging and overheating). You run your device, and it works fine until the battery gets to 3.9V, at which point it starts misbehaving, and there’s a potential to damage the device or lose data.

So, the calculation is then done as follows:

Voltage 5V = Battery 100%

Voltage 4.5V = Battery 50%

Voltage 4V = Battery 0%

Why not 3.9V? Well, some margin is left between 4V and 3.9V for you to find a charger whilst the battery keeps things like the clock and other volatile things going. It also helps prevent against things like the phone requiring more juice than the charger can provide during start-up, so that it doesn’t flake out whilst you’re switching it on, things like that.

Basically, it’s a calibration based on trial and error. Battery calculations are also nowadays self-calibrating, which is why your laptop is able to tell you that it needs a new battery (and why Apple were fined for manipulating phones based on battery stats).

In short there are two ways, sometimes combined.

1) Measure the battery voltage and compare this against a graph that you obtained through calibration. This will tell you at what voltage, what the battery SOC (State-of-Charge) is. This will not be a linear relation. (being halfway between two extremes does not imply being half charged). Generally this is the *least* accurate way to measure, but it isn’t affected by long-term errors.

2) You measure the current going in and out of the battery. You know how much energy a battery will hold if full. Current can describe how much energy escapes the battery every second. Therefore if you measure half the energy has left, the battery is half full. This method is affected by errors over long periods of time, but is much more accurate on shorter periods.

There is another way for batteries with flat voltage curve and devices with known consumption curve (for example device that transmit something every n seconds and sleep rest of the time).

You calculate your average day (for example) current consumption and your battery life expectancy and then you subtract your day consumption every day and project your percentage.

Batteries have a maximum and minimum voltage. The processor reads the voltage and you can use a formula to calculate the percentage left till minimum voltage.

Or in more advanced cases you count the actual energy units going in and out of the battery, these are known as coulomb counters.

[Here is a good chat on the subject.](https://forum.arduino.cc/index.php?topic=476131.0)

I actually work with batteries for a living. A basic concept with any batteries is “nominal voltage”. Say you have a 12V car battery; A fully charged car battery isnt actually 12V but more like 12.6V. If a car battery is at 12V or below its essentially “dead”. Lower voltages than the nominal 12V would mean something severe happened to the battery, like a dry cell, or cold damage.

The same goes for phones and many electronics. Many rechargeable lithium ion batteries have 3.7V nominal voltage. This means a fully charged battery will naturally be a small bit higher. So a 3.7V nominal battery at 3.8V would tell me it has a bit of charge on it still.

If anyone has any questions feel free to ask, ill try to answer the best i can!

Voltaje is like the amount of water you have in a tank. If at the bottom of that tank there is a hole the water will start flowing through it and the pressure the water is flowing with depend on the amount of water on the tank, the more water the more pressure you just need to set a sensor (count how much water is flowing per second/time) at the hole to measure the pressure and you will know how much water there is left.

Edit: and voltaje is the amount of energy you have on a battery