Eric built himself a battery monitoring system based on the ATmega328 Development Kit. He drained a 9V battery with 100mA of current and monitored the voltage drop until total depletion. He used this data to estimate how much time is left until depletion – [via]
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.
Monitoring battery voltage to calculate capacity with an Arduino - [Link]