Monitoring Arduino power supply

Hi Everyone,

I was wondering if it was possible to monitor the battery level that is powering my Arduino board. I've done some searching and it seems that I can use an analog input pin and use analogRead() to measure the voltage.

I intend to use a 5V USB battery pack plugged into the micro USB port on the Arduino board. Would I just be running a connection from that pack to an analog input pin as well? Is it safe to assume that since I'm using a 5V power supply, I do not necessary need to use a voltage divider before connecting it to the analog input?

My project requires a means of detecting a low battery condition so that it can disable some subsystems and then send out its last GPS location before the system shuts down.

Thanks.

Educated guess:
A 5volt USB battery pack contains a boost converter.
That boost converter tries to maintain 5volt on the USB connector, untill the internal 3.7volt LiPo battery drops below a certain minimum voltage.
Then the boost converter stops working, to protect the battery from over-discharging.
I don't see how you can measure that battery witout modding the battery pack.
Leo..

Wawa:
Educated guess:
A 5volt USB battery pack contains a boost converter.
That boost converter tries to maintain 5volt on the USB connector, untill the internal 3.7volt LiPo battery drops below a certain minimum voltage.
Then the boost converter stops working, to protect the battery from over-discharging.
I don't see how you can measure that battery witout modding the battery pack.
Leo..

That's a good point that I completely overlooked.

Let's assume that I could tap into the internal LiPo battery. Would I just wire the +3.7V to an analog input and (-) to GND?

I guess what I'm having the most trouble visualizing is how to measure battery voltage while it is also being used as a supply.

"how to measure battery voltage while it is also being used as a supply"
Use a resistor divider to bring the max voltage to <1.1V.
Use the internal bandgap reference voltage, which uses 1.1V for the ADC conversion. That 1.1V will be pretty steady as Vcc decreases from 5V on down.

+1

Grounds are already shared through the USB connector, so you just have to bring out battery positive.
If you mount the "top half" of the divider inside the battery pack, and use a high value resistor, nothing will happen if you accidently short the wire to ground.
The "to ground" resistor can live near Arduino's analogue input, with a 100n cap across.
Use a 3:1 divider, e.g 330k to ground an 1Megohm to battery.
You have to find out at what voltage the boost converter stops working.
Leo..