# Meauring the voltage across the battery of an arduino

hello, I have a 3.3v battery that supplies power to an arduino uno. I connected this battery to the Vin to bypass the builtin regulator of the arduino. I want to monitor the voltage across this battery using the arduino it supplies.

I connected A0 to positive terminal of the battery and used this code: int val; val=analogRead(0); val1 = map(val, 0, 1023, 0, 5) ; //0-5V

I get contant value of 5v, is this correct? why do I get 5V when the battery is 3.3v?

boi_goog: I connected this battery to the Vin to bypass the builtin regulator of the arduino.

A quick check of the schematic... http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf ...reveals that Vin is the input to the regulator.

I want to monitor the voltage across this battery using the arduino it supplies.

I suggest you first get the wiring correct. Before you damage something.

(This is the correct place to ask for wiring help.)

ohh, ok, actually I was using the pro mini and I am reading the pro mini info of sparkfun, I thought the labeling is the same.

problem solved, thanks for the info

I have a follow up question, why do I always get 3.++ value even if there is not enough energy stored in the battery to power up the arduino?I am using 3 AAA batteries cpnnected in series which is 3.6V. What is the maximum voltage that can be measured when it is fully charge and the minimum voltage that can be measured when it can no longer power up the arduino?is .1v to 4.2v enough?

Very likely because you are measuring the battery's voltage relative to Vcc which is the battery's voltage. If that is what you are doing then analogRead will always return 1023.

This should help... http://forum.arduino.cc/index.php?topic=38119.0

oh, my case is different, since I am using 3.6 V at aref, I will need to boost the 3.6V to 5V using a dc-dc step up converter, so I just did some averaging, and seems the reading is making sense.
I have assumed that the voltage across AREF is 5V(constant) which is coming from the DC-DC Step-up converter.

204.6 = 1023/5

I used this code:

val = val + analogRead(0);
charglim++;
if(charglim>25)
{
val = val/charglim;

val1 = val/204.6 ; //0-5V
charglim = 0;
val = 0;
}