Hello, in school we have a project and in this project we use a 12V battery, we needed something to measure out the battery capacity so we know how much the battery is still loaded in percentages. The teacher told us to do so with arduino. I found on google that you can convert the output voltages of the battery to percentages (it's a 12V lead acid battery) now we coded this with arduino so it measures the voltages, we did it exactly like showed on this site: Wireless battery voltage monitor using Arduino and Bluetooth so this shows us the voltages on our smartphone. But now we want to convert those voltages to percentages but i don't know how to code this in arduino so it converts the output voltages directly to percentages. Discharge and battery capacity - Rebelcell. this site shows how to convert from volt to percentages
I would really appreciate it if someone could help, thanks!
If I told you that the battery had a voltage of 12V when fully charged and a current voltage of 10V how would you calculate its current percentage charge using pencil and paper ?
You should consider that a 12V SLA battery is usually topped out somewhat higher than 12V*, so your measurement of voltage should take that into account without cooking your analog inout circuitry.
and in some circumstances may see spikes far above the nominal 22V point.
yes, thats the one i linked in my post, so i now know how to 'convert' from voltage to percentages but i don't know what to type into the code so it converts those voltages to percentages. i thought of something of: when the voltage is between 11.58 and 11.75, it shows 38% on the serial monitor.
How do i code this?
when the voltage is between 11.58 and 11.75, it shows 38% on the serial monitor
if ((v >= 11.58) && (v <= 11.75)) Serial.println("38%");
else
....
or you make the assumption that the decrease is linear in between the voltage points listed in the table and use map() to interpolate based on which interval is currently "active"