Reading Battery Voltage using ADC

So I have a project in which I test the voltage of AAA batteries. Basically its a product line scenario where batteries are tested for their correct voltage before being packed. I am new to electronics and was not sure hot to read the voltage, through some research I learnt that I might be able to do this by using an ADC and monitoring the resolution. The Arduino Mega supplies 5v and the batteries are 1.5V so I read that I must apply a Voltage divider. The schematic I found is the following. (see attchment - voltagedivider)

So I hooked up the setup onto a breadboard (see attachment - sensor)

and used the following code to check the resolution

int sensePin =0;

void setup ()


void loop ()


On the breadboard view, there are two black leads which the battery is connected across, when i touch them together a resolution of 308 is given, which would equal 1.5V, however when I put a battery in between I get all kinds of resolution. cant help but think I have not grasped the concept because clearly something is wrong.


I don't understand why you've got a potential divider - just connect a single cell between ground and an analogue input.

alainagius: The Arduino Mega supplies 5v and the batteries are 1.5V so I read that I must apply a Voltage divider.

To read less than 5V on a analog input there is no need for a voltage divider. Why did you think you need one?

I was instructed to do so but to be honest i think the person got it wrong, should the pin from the voltage divider go into the AREF pin so that the reference voltage would be 1.5V to maximise resolution? If so, and even if not, how should I hook up the contacts to the Analog Input? From 5V to the battery and from the battery to A0 or should it be going to ground, sorry if seems stupid but Ive done all the research I can and this is all very new to me

alainagius: Ive done all the research I can and this is all very new to me

Which is the reason I asked why you thought you needed a divider. :)

If you want to maximize resolution, then yes you would want to provide a 1.5V reference to AREF. However, how much resolution do you really need? The ADC has 1024 steps. The default reference is 5V. So that is 4.88mV per step. Let's call it 10mV. Is that enough resolution for your application?

As for connecting to A0, the positive of one cell will go to A0. The negative will go to Ground. Ground is a reference. All devices must share the same reference. (Voltage is a potential, which is measured against some common reference.)

Because the research I did led me to believe I needed one hehe I must have understood wrong but in fact I started to doubt the use of it, well the thing is that max voltage on a battery, 1.5V would give me a 308 reading so the range is from 0-308 so its about 30% potential, I'll try doing as you suggest and see if the resolution is good enough, if not I might look in to using AREF. Also someone else told me to connect a load (resistor) across the battery since even when it is almost depleted it will show about 1.5V, does this make sense to you?

You could put a 2:1 divider onto Aref, which would give you 2.5V FSD, so giving you just under 2.5mV resolution.

Yes, you should (briefly) put the battery under load.

Let me ask you this before deciding if you need to do anything with the Aref or not. You are measuring 1.5vdc DC batteries for some kind of fail/pass test procedure. What value is your decision point value if the battery is to be accepted or rejected? I suspect that the standard 0-5vdc range will be more then good enough resolution for such a test/pass procedure. Also the mah rating of your 1.5v cells should be looked at for the proper sizing of a load resistor. What cell size are you testing?


OK so first off, just tried the setup as James C4S instructed me to with a 5V reference and it worked, a put a 1kOhm resistor and the resolution seemed to play around so I put a 12kOhm resistor (trial and error) and the resolution stabilised. The Arduino Mega has a built in 2.56V and 1.1V reference so I applied the 2.56V range and so I managed to use a larger percentage of the resolution available.

It seems to be ok with a 12kOhm resistor but if you can suggest any math that I should look into to determine an ideal resistance value I would be very grateful. The 1.5V cells have 2500mAh

Well 1k ohm is just a 1.5ma load and 12k is just a .000125 ma load, neither of which is really 'load testing' a 2500ma cell. I would think C/10 (250ma) would be the minimum size load you would want for a decent 'voltage under load' measurement, or 250ma = 6 ohm 1 watt resistor.

Ok I'll give that a go! Thanks a lot all!