Pages: [1]   Go Down
Author Topic: Reading Battery Voltage using ADC  (Read 997 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
int sensePin =0;

void setup ()
{
  analogReference(DEFAULT);
 
  Serial.begin(9600);

}

void loop ()
{
  Serial.println(analogRead(sensePin));
  delay(2000);

}

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.


* voltagedivider.png (4.06 KB, 91x239 - viewed 15 times.)

* Sensor.jpg (59.99 KB, 819x531 - viewed 19 times.)
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24454
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley

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.)
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24454
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: