Electronic – arduino – Measuring Arduino internal voltage reference with respect to Vcc

arduinovoltage measurement

How do I read the internal reference voltages of the Arduino (Ardino Mega, ATmega2560, specifically the 2.56v reference) with respect to the input voltage?

I'm trying to measure the remaining battery capacity of a device through a voltage divider. The Vcc going into the Arduino is also hooked up to the battery and thus varies as well. I've measured the internal 2.56v reference so I know approximately what it should be regardless of the varying Vcc voltage but I can't find any simple documentation on exactly how to measure that particular internal reference voltage with respect to the Vcc.

Best Answer

You're trying to measure the battery voltage, but you need a stable reference point. This is precisely what you use the internal reference for.

Let's assume that your battery pack is a LiPo pack and has a nominal voltage of 3.7V and you want to shut things down when you get to 3.1V.

Now, the internal reference you have is 2.56V, so even at the cutoff point, 3.1V is too high. Let's chop this in half with the voltage divider you already have.

Now, the nominal voltage you'll see through the divider is 1.85V. Perfect! You can now use your internal reference for your ADC readings. In this case, 1.85V is what you'll see at the ADC for a battery voltage of 3.7V and 1.55V at the ADC is your cut off of 3.1V.