I am powering an Arduino using a 5v battery (3.7v to a step-up module), and I need to measure the voltage. Let's say the battery delivers high current, is it safe to measure the voltage via Analog In? As in this:

The reason I'm asking is that I don't know much about the Arduino's ADC architecture and limitations. So normally, I'd do so for safety:

Are the connections in the first diagram safe for the ADC? Thanks in advance!

Note: A similar question was asked here: (Monitor DC Power Usage), but it doesn't answer the question of high current loads on the battery.

• Where did you get a 5V battery? – Keelan Apr 7 '13 at 17:11
• Actually it's a 3.7v battery that goes into a step-up voltage regulator circuit. I am indeed interested in measuring the 3.7v battery itself, but for the sake of example, just assumed its 5v to show that the Arduino is working. – Ahmed Farid Apr 7 '13 at 17:13
• Ah, but it might change things. Probably not though: the arduino won't care how much current is drawn by the battery, as long as not all that current goes through the IO pin. But I'm not sure, I don't know arduino. – Keelan Apr 7 '13 at 17:14
• That's true. I'm worried about the current input to the Analog In pin if I directly connect it to a battery. – Ahmed Farid Apr 7 '13 at 17:18

Check the datasheet for the input current on a I/O pin It depens on the exact type of controller on your Arduino. It is probably called Input Leakage Current I/O pin and will be near 1μA.

Here is a typical ATmega datasheet used on Uno / Duemilanove / ... , you can find the parameter on page 304. Check the datasheet for your specific controller for accurate details.

If you use a 3.7V battery and a step up converter to supply 5V to the controller, you can connect the battery directly to your controller analog input. However when the output voltage of the step up converter drops below the voltage of the battery (for whatever reason) then your entire Arduino will be fed through the analog input pin and that is what you don't want. All input pins have protection against overvoltage which enables this behaviour, but the diodes are not rated for continuous currents. In conclusion: it is best to include a series resistor between battery and input pin.

But now your measurement relies on the accuracy of the 5V power supply. Depending on which exact controller you have, there are various internal reference voltages available which are far more accurate than the power supply voltage. If you add an extra resistor to ground (R2) you can use such a reference to accurately measure the input voltage. This is called a (resistive) voltage divider. With the given ratio, the voltaga on the input pin will be 1V when the battery voltage is 3.7V:

$V_{measurement} = \dfrac{R2×V_{BATT}}{R1+R2}$

simulate this circuit – Schematic created using CircuitLab

• So in essence, it is possible to connect it directly to a battery but NOT recommended if the 5v varies. Even if the 5v is regulated and constant? – Ahmed Farid Apr 7 '13 at 18:11
• It should be safe if 5V is constant, but things go wrong all the time so: better safe than sorry. One or two resistors are much cheaper than a new microcontroller. Engineering is not only about making things work, it is also about making things that keep working as required. – jippie Apr 7 '13 at 18:15
• Another question if I may: Isn't a single resistance (1K) in parallel to the battery good enough to prevent a high current input? (See my second figure) – Ahmed Farid Apr 7 '13 at 18:19
• No, it does nothing other than draw the battery. – jippie Apr 7 '13 at 18:20

Another option is to use the Arduino's internal 1.1V bandgap voltage reference to determine the value of VCC without the use of any additional external parts as detailed at these two links:

http://jeelabs.org/2012/05/04/measuring-vcc-via-the-bandgap/

and

http://arduino.cc/forum/index.php?topic=88935.0

The only gotcha is that you need to determine a calibration value against the internal 1.1V bandgap since it can be off by as much as 10%.

But that would require no additional parts, and would allow your atmega to determine the voltage of its power source.

• Here is another article which discusses how to do this. The code it uses is slightly different: provideyourown.com/2012/… – ThomasW Jun 4 '13 at 6:44
• @ThomasW nice! Another great article on using the 1.1v bandgap. – Wing Tang Wong Jun 4 '13 at 20:29