Read the voltage of the battery while powering it

is their any way to measure the voltage of a battery while powering the arduino?

vhenamae: is their any way to measure the voltage of a battery while powering the arduino?

Sure, the typical way is to wire the battery voltage to a two resistor voltage divider and the then attenuated voltage is wired to a arduino analog input pin.

Lefty

is it fine if the power im using for the arduino is the one im measuring?

is it fine if the power im using for the arduino is the one im measuring?

Duzn madder.


Rob

vhenamae: is it fine if the power im using for the arduino is the one im measuring?

Not an issue in itself. The issue is that there must not be more then Vcc + .5vdc applied to a analog input pin. You haven't given us the battery voltage you will be using, but assuming it's more the +5vdc then some kind of voltage divider is a commonly used method to be able to measure it's value. One issue with that however is that the divider will consume some battery current at all times, unless there is a on/off switch between the battery and the voltage divider string.

i see.. actually ill be using NiMH 9v 200mA battery..

So it is going into the Vin or power jack and being regulated to 5V, that is the voltage reference for the measurement. Then a potential divider will cut this raw voltage down into the 0 to 5V region for you to measure.