
Eric built himself a battery monitoring system based on the ATmega328 Development Kit he received as a prize in our 7400 contest. 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.
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.
Via the forum.

Nice graph! For the best accuracy you want to account for temperature, and the recent history of current draw from the battery also.