So you'll be using the technique described in that post? Using the battery voltage as a reference to measure the 1.071V bandgap?

Yes, it seems to be working. The value I am getting off my battery with a multimeter though is 5.28v, but the value I am getting using the second technique in that post is 3.53v (I get 5.0v if I power it off USB). Does that sound right?

Basically, I am trying to accurately log battery level for my project. But as a side, I am trying to make sure my analogue values captured are accurate.

The value I am getting off my battery with a multimeter though is 5.28v, but the value I am getting using the second technique in that post is 3.53v (I get 5.0v if I power it off USB). Does that sound right?

Uh, no. If you're using the correct code / method, you should be getting a value very close to 528. Even if you're using 1.1V for the bandgap voltage you should be getting much much closer to 528 than 353.

Are you planning to power the processor directly from the battery?

How do you have the battery connected?

(I'll have some software questions when I'm in front of the other computer.)

With Vcc regulated to 5V, why aren't you: using Vcc as the reference, a voltage divider to get the battery voltage in range (I'd just cut it in half), and measuring that in the plain-ol-analogRead fashion?

The code you are trying to use was meant for a processor running directly from batteries. I don't think it functions correctly the way you are trying to use it (AREF > Vcc).

Thanks for all your help. I actually have no idea how I started down this path. The main thing I want to do is log my voltage of my source batteries. As such, a Voltage Divider (http://en.wikipedia.org/wiki/File:Resistive_divider.png = 2 resiters of the same value). Then send VOut to A0, and read the value, then double it. Sound right?

Do I even need a reference value?

But then, since I know the reference value now anyway. And my reference voltage is 2% out from 1.1v. As such, should I treat any value coming into A0 to A5 as being 2% too low? Its only 2%, I don't think I care that much as most of my connections are Digital anyway, and everything anyway seems to have different levels of accuracy. More curious now.

The bandgap / 1.1V reference would no longer be involved. You can forget about it.

The reference you would be working with is Vcc / 5V.

Thanks. So in theory, if my VCC drops to 4.8v, I should multiply every value in A0-A5 by 1.041 to get its real value, assuming that item is a 5v item ?

Is there a real way to test this?What if I get my 5v battery power source, measure VCC @ I assume 5v. Measure a 1.5v AA battery on A0. Then let the arduino power batteries go flat. When VCC gets to 4.8v, take a second reading from A0, and it should be 4% lower ? Maybe?

How low can the source arduino power get before it will no longer function?

How low can the source arduino power get before it will no longer function?

I have no idea. Some folks claim just north# of 6V is required on Vin but your testing contradicts that.

Quote

So in theory, if my VCC drops to 4.8v,...

In theory, that would be impossible. It's a 5V low dropout regulator so the cutoff should be at 5V.

Quote

Is there a real way to test this?

The first course of action is to get an opinion from someone who understands the switching circuit and voltage regulator (someone who isn't me). If you don't get a reply in a reasonable amount of time, I suggest posing your question in the General Electronics section (or spend some time searching the forum; I believe the topic has been discussed).

# For those living in the Southern Hemisphere that would be "just above".

just want to add my two cents - I am researching how to measure battery voltage through the bandgap method

if you connect the batterys to the vin barrel - you are not going to get the same voltage on vcc - far from it. The battery voltage goes through the voltage regulator. If at all possible - hook up your battery pack to vcc. (assuming it is not over 5.5 volts and not reversed!)So the results you measure may actually be correct

hooking up an arduino to usb does bypass the voltage regulatorhowever - this does not garantuee a clean 5v vccwhen I hook my arduino up to a usb 1.1 hub - I get around 4,3 volts on vccit took me quite some time figuring out why analog temperature sensors would give bad results. I finally figured out a simple trick, measure the 3,3v line on an analog pin and use that to calculate the voltage on Aref. This did cost me an analog pin. I am looking into the bandgap method for future projects.

way ahead of you there ...when I use the computers usb ports all is fine!just this usb 1.1 hubI have not looked into it that much further - it doesnt bother me since I figured out a way to measure the vccwhich actually was a good idea since I need this when I want to run my arduino off batteries.

I just got fascinated by the whole bandgap idea because it doesnt involve sacrificing an analog pin.

if you connect the batterys to the vin barrel - you are not going to get the same voltage on vcc - far from it. The battery voltage goes through the voltage regulator.

It that situation, use the regulated 5.0V (or 3.3V) supply on the Arduino as a reference and a voltage divider on the battery to get the voltage in range.

Quote

however - this does not garantuee a clean 5v vcc

Use the regulated 3.3V as a reference.

Quote

when I hook my arduino up to a usb 1.1 hub - I get around 4,3 volts on vcc

Yikes! You need to drop that thing for a powered hub. In my experience, this one is well worth the money...http://www.usbgear.com/computer_cable_details.cfm?sku=USBG-7U2ML&cats=104&catid=104%2C653%2C210%2C212

Quote

I finally figured out a simple trick, measure the 3,3v line on an analog pin and use that to calculate the voltage on Aref.

way ahead of you there ...when I use the computers usb ports all is fine!just this usb 1.1 hubI have not looked into it that much further - it doesnt bother me since I figured out a way to measure the vccwhich actually was a good idea since I need this when I want to run my arduino off batteries.

I just got fascinated by the whole bandgap idea because it doesnt involve sacrificing an analog pin.

Your welcome, and bandgaping was fun but CB did most of the heavy lifting. I just wanted to see if it could be useful or not and wouldn't stop bugging him for help and ideas. To tell the truth I almost never find my projects using all the analog input pins (and if so I just switch to the mega board or my 644P soon to be 1284P board, so just tying the 3.3v to a AI pin and using that as a compensation/refence value is simple enough. Heck on one of my boards I have a jumper from the anode of the power led wired to a AI pin as a reference, it works.

But for serious ADC results I just use I2C ADC chips, either the TI 12 bit ADS1015 for 16 bit ADS1115, they are what real ADC is be all about. Adafruit has some nice breakout boards for them and has support library all set to go.http://www.adafruit.com/products/1083http://www.adafruit.com/products/1085