We see in all today electronic devices like mobile a Visual battery charging indicator,that a graphical Container composed of bars that increases one by one when the battery is charged for long, and decreases one by one when the mobile is used for long time. I see the same thing laptop in every GUI operating system like windows and Linux.

batter charging

I am thinking from long long ago , under what logic this works? How the Program is managed to Monitor the battery. I made a simple logic based on Amps-hour, that how much time the bar should increase when the battery is in charging mode.??? But that does not work perfectly for me. Also i read a battery indicator Android application source code of my fried, but the function he used were System Calls based on Andriod Kernel (Linux Kernel).

I need the thing from the scratch.... I need this logic to know............. Because i am working on an Operating system kernel project, which later on will need battery charging monitor.

But the thing i will implement right now is to show just percentage on the Console Screen. Please give me an idea how i can do it.... Thanks in Advance

  • \$\begingroup\$ Have you looked at the battery datasheet yet? \$\endgroup\$ Jul 25, 2015 at 5:24
  • \$\begingroup\$ No, I am not doing this for a specific battery. I want this for a generic battery. Whether i connect a 12V or 5v the program should work for both \$\endgroup\$
    – Habibullah
    Jul 25, 2015 at 5:33

1 Answer 1


Getting an accurate state-of-charge for a battery is not a trivial thing. The easiest method is coulombe counting, i.e. how much current for how much time. Unfortunately it's very inaccurate due to aging of the battery and temperature effects.

A more accurate method is impedance tracking. This tracks the internal impedance of the battery over time and allows much more accurate state of charge estimation. It also requires knowledge of the battery chemistry, capacity, etc. You can't just switch batteries from one type to another and expect it to work.

You can read about impedance tracking here: Impedance Tracking


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.