Checking battery levels

I am new to the arduino. I have built an Xbee controlled rover with the Uno and I need to be able to read the voltage on the battery so it can then be sent back to my computer program, warning the user of low battery. I have read a few threads here on doing so but I just can't seem to grasp the concept. I know the best way to do it is through a analog input. I am completely self taught so I need a pretty detailed description, thank you for any help or ideas :smiley:

Hi!

I'm not an expert but the only thing that you should do is read the voltage provided by the batteries. For example, a 3.3v batt will normally provide a higher voltage at full charge 3.7v or 4v and when low voltage will drop probably under 3.3v. You can get an idea of the voltage at "low" level in google, but that's the basics.

I hope this helps!

Firstly we need to know how you are powering the Arduino - it matters if its got a regulated 5V or not (with a regulated 5V it can be used as the analog reference).

As MarkT says, it depends on the power source. If you are powering the Arduino from a 9v battery connected to Vin and GND, then you can use a 50:50 voltage divider, i.e. connect an analog input pin to +9v and to ground through equal resistors, say 47K each. The reading you get from analogRead of that pin will be proportional to the battery voltage, with 1023 (the maximum reading) meaning about 10v.

If you are powering it from a battery connected directly to the 5v pin, then you can connect the 3.3v pin to an analogue input and measure that. The reading you get will be (3.3/battery_voltage)*1023. The 3.3v regulator is a low dropout type (at least on the Uno rev 2) so this will work right down to a battery voltage of 3.3v if you don't have any other significant load on the 3.3v pin.

Thank you for the responses..

I am powering the arduino through a sabertooth 2x5, powered by a 7.2 volt. The sabertooth has a 5v regulator which is used to power the arduino. So only 1 battery is used.

In that case the solution I gave for a 9v battery should meet your needs.

The reading you get from analogRead of that pin will be proportional to the battery voltage, with 1023 (the maximum reading) meaning about 10v.

From a 9V battery with a 2:1 voltage divider?
1023 will correspond to 9V.

No, 1023 will mean 10v. The default analog reference is Vcc which is 5v so it reads 1023 with 5v at the input pin. Since I specified a 2:1 voltage divider this means 10v at the battery. I used this method in a project last week and the computed battery voltage agreed with my dmm to better than 0.1 volt.

You're right 1023 does correspond to 10V - sorry.