Skip to main content
Topic: Arduino Battery Monitor Part II (Read 8063 times) previous topic - next topic

Arduino Battery Monitor Part II

In my last blog post: http://
I took an Adruino Uno and a Protoshield and made a simple battery monitor, so I could measure the voltage of a discharging 9V battery when it was drained through a constant 100mA load. Below is the 9V battery discharge curve:
The 100mA constant load was chosen because my ProtoStack Arduino Clone with LCD draws about 92mA and I wanted to write a sketch to display a battery bar and the approximate hours battery life left. Since all batteries have an internal equivalent series resistance (ESR), it is important to take that into account when only using a battery's voltage to monitor its state of charge. Since we discharged the battery through a load that is similar to the ProtoStack board with LCD, the ESR of the battery has automatically been accounted for in the voltage measurements.

With the plotted excel data from the discharge monitor I created a look-up table in software to approximate the battery life:

Battery Voltage,              Hours Life Left ,                Displayed Battery Bars
7.87V > Batt ,                      4.5hrs,                                        4
7.45V > Batt <= 7.87V,          4.0hrs,                                        4
7.23V > Batt <= 7.45V,          3.5hrs,                                        4
7.08V > Batt <= 7.23V,          3.0hrs,                                        3
6.94V > Batt <= 7.08V,          2.5hrs,                                        3
6.77V > Batt <= 6.94V,          2.0hrs,                                        2
6.56V > Batt <= 6.77V,          1.5hrs,                                        2
6.30V > Batt <= 6.56V,          1.0hrs,                                        1
5.71V > Batt <= 6.30V,        0.5hrs,                                        1
              Batt <= 5.71V,        mins left,                                    0

Here is the sketch I wrote: http://

I tied the input voltage through a resistor divider (220K Ohm series and 100K Ohm shunt) to the A0 pin on the micro.
One issue I ran into was the 9V battery can go down as low as 5.71V before it is completely dead. The ProtoStack board has a 1N4004 reverse polarity protection diode and a 7805 Linear Regulator to generate its 5V rail. These components require that the input voltage be greater than 7.8V in order to create the 5V rail properly.
So I replaced the 1N4004 diode with a schottky diode that has a much lower 0.2V forward voltage and used a L4941 5V linear regulator to replace the 7805. The L4941 has a drop out voltage of less than 0.45V when sourcing 1Amp. With these mods I was able to go down to 5.30V input voltage before the LCD stopped functioning.
I used the Parallax 16x2 LCD commands to create the custom characters for the "EH" and Full & Empty Battery Bar Segments. Here is a link to the spreadsheet I used to calculate the values for the custom characters. http://

This was a fun project to get myself familiar with the Arduino Analog pins. Now my ProtoStack Board is all ready for a future portable battery powered electronics project. http://

Re: Arduino Battery Monitor Part II

Reply #1
This is really cool, congratulations on a great project.

I'm going to post it up on the blog :)
Got a question? Please ask in the forum for the fastest answers.


Re: Arduino Battery Monitor Part II

Reply #2
That is pretty sweet! You should take it off all that arduino hardware and design a PCB just for it!

This is a perfect example of the types of projects I truly enjoy to build and modify for my own applications. I have never dont much with battery powered anything, but I would like to start learning the differences and a project like this would be a great start. I also see alot of potential! Kind of like a DMM for battery power and perhaps even have a hardware solution to change the batterys 'usage'? i cant think of the word but how much power the circuit is taking from the battery. instead of a set 100mA.

I have seen alot of projects like this; as in battery levels before. usually onboard a device that is for something else; so the software knows how much battery is left (you know just a divider). but i like the idea of a battery level tester. DP is great at making tools, this would be right up there alley. Like:

* LCD and Serial output
* Perhaps a results output that can be pasted into excel to design a quick graph of power over time
* adjustable load, (even programmable maybe? for x hours run this; then run this and so on)
* & changeable source so you can test a CRC24 (is that right?) small battery on a circuit you know takes XXXmA and learn if that battery will work for how long.
* im sure there are a ton of other uses; but I would assume that would be the biggest

But I do not use arduino, ever. I am however an AVR guy, as in AVRs are my main micro controller. (Though I am trying to get PICs and even TI's MCP micros under my belt as well..) So I think it would be that much cooler if it had its own hardware and its own software solutions instead of the thought of needing arduinos hardware and worse arduinos software to create or modify (though im sure it wouldnt be tough at all to port from arduino into straight c, it would just take some time to create new LCD drivers and such; im sure the main routines are fairly simple).

Have you thought about ditching the arduino clutch and building the project from the ground up, with your own hardware and own SOftware solutions?

edit: I know saying arduino is a clutch will get all the arduino guys in a hoots :) I meant it as in using arduinos pre-made hardware and pre-made software solutions instead of building from scratch, thats all. As one person said to me about arduino; its just another method to the same end (bit cheaper but I do agree :P). I have heard a ton of pros/cons to the arduino and when its all boild down it doesn't really matter to me, so i dont like nor hate the arduino. You just wont catch me using it.