I would like to display a battery percentage based on the remaining charge in the battery. I do not know if there is a better way of doing it other than measuring the voltage across the batteries.
How do i accommodate the sudden voltage drop of loads that are switched on. For example assuming a single lipo battery with a 100% at 4.2 volts and a 0% at 3.5volts. With the logic circuits total resistance, the voltage will drop a little bit by lets say 0.05 volts, which is then read i can display the battery is at 94%. seems straight forward. Now if we add lets say a high power motor and upon turning it on (lets ignore the voltage drop over time) the battery voltage will drop by lets say 0.25 volts(due to added resistance) which mean that my microcontroller will read 3.95 volts or 64% (assuming linear voltage curve which is NEVER the case in batteries). But if we turned the motor back to off the voltage drop of the battery will go back to only 0.05 so i have to display 94% again.
I do not like displaying battery percentage that is going up and down, it will lead to confusion. Also i know that proper battery indicators do not go up and down, so i can conclude that there is something they have done to accommodate switched loads.