# Calculate battery state of charge percentage

What is the correct formula to calculate battery state of charge percentage based on the battery type (12v, 24v, 48v and so on) and the current battery voltage.

For example if I have a 12v battery and the battery has 12.06v left in it, it would give me around 50% capacity left.

I am looking for the formula used in this chart(12v battery type):

UPDATE EXAMPLE OF MY CURRENT WAY OF DETERMINING STATE OF CHARGE:  function battery_percentage($voltage_type,$battery_voltage) { if($voltage_type == 12) { if($battery_voltage <= 10.5) { $battery_percentage = 0; } elseif($battery_voltage <= 11.31) { $battery_percentage = 10; } elseif($battery_voltage <= 11.58) { $battery_percentage = 20; } elseif($battery_voltage <= 11.75) { $battery_percentage = 30; } elseif($battery_voltage <= 11.9) { $battery_percentage = 40; } elseif($battery_voltage <= 12.06) { $battery_percentage = 50; } elseif($battery_voltage <= 12.20) { $battery_percentage = 60; } elseif($battery_voltage <= 12.32) { $battery_percentage = 70; } elseif($battery_voltage <= 12.42) { $battery_percentage = 80; } elseif($battery_voltage <= 12.5) { $battery_percentage = 90; } elseif($battery_voltage <= 12.6) { $battery_percentage = 100; } elseif($battery_voltage >= 12.6) { $battery_percentage = 100; } } elseif($voltage_type == 24) { if($battery_voltage <= 22) {$battery_percentage = 0; } elseif($battery_voltage <= 23.02) {$battery_percentage = 10; } elseif($battery_voltage <= 23.32) {$battery_percentage = 20; } elseif($battery_voltage <= 23.62) {$battery_percentage = 30; } elseif($battery_voltage <= 23.92) {$battery_percentage = 40; } elseif($battery_voltage <= 24.20) {$battery_percentage = 50; } elseif($battery_voltage <= 24.48) {$battery_percentage = 60; } elseif($battery_voltage <= 24.74) {$battery_percentage = 70; } elseif($battery_voltage <= 25) {$battery_percentage = 80; } elseif($battery_voltage <= 25.24) {$battery_percentage = 90; } elseif($battery_voltage <= 25.46) {$battery_percentage = 100; } elseif($battery_voltage >= 25.46) {$battery_percentage = 100; } } elseif($voltage_type == 48) { if($battery_voltage <= 45.5) { $battery_percentage = 0; } elseif($battery_voltage <= 46.04) { $battery_percentage = 10; } elseif($battery_voltage <= 46.64) { $battery_percentage = 20; } elseif($battery_voltage <= 47.24) { $battery_percentage = 30; } elseif($battery_voltage <= 47.84) { $battery_percentage = 40; } elseif($battery_voltage <= 48.40) { $battery_percentage = 50; } elseif($battery_voltage <= 48.96) { $battery_percentage = 60; } elseif($battery_voltage <= 49.48) { $battery_percentage = 70; } elseif($battery_voltage <= 50) { $battery_percentage = 80; } elseif($battery_voltage <= 50.48) { $battery_percentage = 90; } elseif($battery_voltage <= 50.92) { $battery_percentage = 100; } elseif($battery_voltage >= 50.92) { $battery_percentage = 100; } }  • Have you searched for this on here? Hint it has been asked many times.... – Solar Mike Oct 16 '18 at 10:29 • I can't find anything, I'm not sure what the correct name/wording to use for exactly what I'm looking for. – Raymond Rudman Oct 16 '18 at 10:40 • First result on here, looking for “battery stae of charge”... electronics.stackexchange.com/q/281065/152903 – Solar Mike Oct 16 '18 at 10:44 • I have read that already and gives no formula – Raymond Rudman Oct 16 '18 at 10:46 • Yes and it does not answer my question, I'm not worried about load and all that, I need the formula without any load on the battery. – Raymond Rudman Oct 16 '18 at 10:50 ## 4 Answers There is no correct formula to "measure" the state of a battery from it's open load voltage. As Tony EE rocketscientist has already listed in his answer to this question there are numerous factors that determine the open load voltage of a battery. So the battery meters you find on your phone and any other device does not use a particular formula. Instead it is an educated GUESS. The manufacturer of a product with a battery will have some practical information resulting from tests with that particular product or a very similar product (like the previous model phone). Also some usage data and age might be considered. All that information is combined into a guess for the battery level. That guess can be as simple as a lookup table like shown in your question, measure 12.20 V => show 60% battery full. This not only applies to Lithium based batteries used in phones but also to 12 V car batteries. • I understand that but I am not exactly wanting a 100% accurate answer, I am building a monitoring system for tower sites, my system pulls the voltage if what the router states the battery is at. In my system, I define if the tower site is running a 12v battery or 24v and so on. I am looking for something that will give me a guessed answer like you stated by providing the battery voltage type and the read voltage from the battery(what my router states the voltage is), I have something already but Is only in increments of 10(0%, 10%, 20%...) but I need something that will be in increments of 1. – Raymond Rudman Oct 16 '18 at 11:15 • Is there any way I can do this by using a formula to give me a guess? Have a look at the updated question on how I am currently getting the SoC – Raymond Rudman Oct 16 '18 at 11:17 • Sure, it is called interpolation however you will never have a reliable 1% reading. Most battery level scales are crude because the value is a guess anyway. There is no point in displaying in 1% steps when 10% steps are already inaccurate. For example: if the battery was just loaded, it will have a slightly increased temperature. That temperature change by itself can already make the battery level appear more than 1% higher or lower. – Bimpelrekkie Oct 16 '18 at 11:21 • I know that, I'm not worried about the correct readings, I just want to know how they calculated the difference in-between the values on the chart – Raymond Rudman Oct 16 '18 at 11:24 • You have already been told “the manufacturer did some tests and measured it”... – Solar Mike Oct 16 '18 at 11:27 If your use case has pretty constant operating conditions wrt current rates, duty cycle, ambient temperatures etc, and you have the gear and knowledge to determine actual SoC via controlled constant load testing down to 0% under "average" conditions and the batteries are proactively replaced before they age much, then extensive test benchmarking will allow you to create a table showing rough correspondence between resting or at least quiescent / low usage times voltage and guessed SoC. Likely 10-20% accuracy at best, some of the time. A coulometer to cross-reference with might help, but getting a proper OTS SoC meter to even 5% accuracy is several hundred dollars. I work this out as a pretty accurate solution based solely on the values it could be updated to detect battery and change the values based on that but I hard coded it for 24v and it works pretty good for what I needed. $volt = 24.79; //this value is the only one that constantly changes.
$high = 25.46;$low = 23.02;
$sum = (($volt- $low) / ($high - $low)) * 100; if (round($sum) >= 100)
\$sum = 100; // if greater than 100% then keep it there.


There is good correlation between a battery's 'state of charge' and its internal resistance and none between its 'state of charge' and its open circuit voltage.

Battery testers utilise internal resistance and open circuit voltage readings to output results such as 'Recharge & Test', 'Good Battery - SOC XX %' and 'Bad battery'.