# Measuring 12 V via voltage divider: choosing the right resistors

I want to measure a 9 V battery via one of the analog input ports of my Arduino Nano. From all the schemes of this great answer, I choose the simplest one, the voltage divider. Assuming the maximum input voltage to be 12 V (just to be safe) and maximum divider's output voltage to be 5 V, I've solved it against R₂:R₁ proportion. It turns out that R₂:R₁ = 5:7. simulate this circuit – Schematic created using CircuitLab

With the values above, the input of A0 pin will be exactly 5 V.

The problem is that it could be any values. 5 Ω and 7 Ω or 5 MΩ and 7 MΩ!

I understand, that there should be another equation to take into account that will give me the values of those two resistors. Another brilliant answer demonstrates, that the values depend on the current I want to flow through the branches:

So the point is when determining the resistance of the resistors, we should take into account the input resistance of the load and the two voltage divider resistors should be as small as possible.

On the other hand, let's compare the current going through the divider in the circuit with large resistors on the divider and the circuit with small resistors on the divider. As you can see, the large resistors have current of just 2.5 μA going through them and the small resistors have current of 25 mA. The point here is that the current is wasted by the voltage divider and if this was for example part of a battery operated device, it would have a negative impact on the battery life. So the resistors should be as large as possible in order to lower the wasted current.

9 V batteries are known to have a little of energy canned inside, with the most popular 6LR61 having only about 550 mA·h. I do not want to waste it on heating the resistors, so, probably, I need to use large resistors. But how large? Too large R₁ will let only a little current to flow to the A0 pin and I've read somewhere that small currents may lead to `analogRead` measurement errors (underestimations?) due to ADC's internal capacitor.

Trying to find the right answer, I've read on the Arduino's forum that:

The ATmega328P datasheet has this info way in the back: Table 28-16 (page 328). The analog input resistance is claimed to be 100 Mohms.

During an actual sample, the input resistance is temporarily a lot lower as the sampling capacitor is charged up so it is recommended that whatever you connect to the A/D have an output impedance of 10k or less for best accuracy.

And here, I am stuck. I understand that I am connecting a voltage divider to the A/D, but what is it's "output impedance"? It should depend on R₁ and R₂ somehow, and solving that equation (`F(R₁, R₂) == 10 000`) will give me the exact value…

P.S. I saw some cunning schemes in the Internet with capacitors, diodes and op-amps (everybody say it's super easy and safe to use them for this task), but, please:

• I am just trying to understand the basics and making my first steps with electronics.
• The device I'm making should be lightweight and compact (although I should be able to compose it without any PCB magic). Two resistors seems to be fine.
• I'm going to read the voltage only once when the device is turned on, so I don't actually need super-fast op-amp's speed.
• I'll try not to plug negative voltage, so I do not need a protection. Yet.
• Wow that's a long question. I did a quick search and "noise" is not in there. So, here's yet another consideration: If the resistances are too large and the environment is noisy enough, nose may leak into your measurements and cause false readings. You can mitigate this by using lower resistances. You can also mitigate this in your firmware. You can also mitigate this by controlling the noise source. Oh, and chances are that you will always make multiple measurements to mitigate noise. It is common a 12 bit ADC to not have 12 bits (maybe only 8 bits) of resolution if no averaging is done. – st2000 Nov 12 '19 at 19:17
• Thanks, @st2000! I indeed read about large resistors "catching" the noise. I thought to mitigate that by reading the value, say, 10 times and averaging it. As I've said, it's only done once and need not be extra-fast. – madhead Nov 12 '19 at 19:28
• And, yes, I've tried to put everything I've learned so far in the question, because there is so much information on the Internet and so many parameter. Like your consideration about the noise. – madhead Nov 12 '19 at 19:30
• One more advice I saw, is just using ~10 kΩ as R₂ and never bother, but I want to understand the math. – madhead Nov 12 '19 at 19:33
• Another general consideration: Never apply a voltage to any pin on a logic chip (microprocessors included) which is higher than the supply voltage. So, if the micro is actually a 3V3 device, you should not apply a 5V signal to any of its pins. In fact, many designs have clamping circuits to avoid accidental high voltages. – st2000 Nov 12 '19 at 21:46

What you are looking for is called the Thévenin equivalent source. For the schematic you are showing, and assuming you can neglect the output resistance of the battery itself, the output resistance of the voltage divider is the same as the two resistors in parallel. If you want the maximum allowed resistance (minimum current) you have then to solve:

1/R1 + 1/R2 = 1/(10 kΩ)
R2 / (R1 + R2) = 5/12

which gives:

R1 = 12/5 × 10 kΩ = 24 kΩ
R2 = 12/7 × 10 kΩ ≈ 17.1 kΩ

You can then round the values down to the closest standard values, taking care that the rounding does not impose more than 5 V on the analog pin. For example, if you restrict yourself to the E6 series, you could choose

R1 = 22 kΩ
R2 = 15 kΩ

which would give you a Thévenin equivalent output resistance of 8.9 kΩ, and a maximum output voltage of 4.86 V.

• Thank you. So, basically, I need to cross out the batteries and calculate the resistance of the divider between the points I used to attach the Arduino (ground and between the resistors)? – madhead Nov 13 '19 at 9:44
• @madhead: Yes. That's basically what Thévenin's theorem tells you. – Edgar Bonet Nov 13 '19 at 13:15