The formula
Vout = Vin × R2 ÷ (R1 + R2) I = Vin ÷ (R1 + R2)
R1 goes from the input to the output, R2 from the output to ground. With 12 V, R1 = 47 kΩ and R2 = 10 kΩ the output is 12 × 10 ÷ 57 = 2.11 V, and the divider draws 0.21 mA.
Measuring a battery with an ADC
Choose the ratio so that the highest battery voltage, while charging too, stays below the ADC limit. A 1-cell Li-ion at 4.2 V through 100 kΩ and 100 kΩ gives 2.1 V: within range on every chip below, and only 21 µA drawn.
| Read by | max |
|---|---|
| ESP32 ADC | 2.45 V |
| ESP32-C3 ADC | 2.5 V |
| ESP32-S3 ADC | 2.9 V |
| RP2040 / Pico ADC | 3.1 V |
| Arduino Uno, 5 V reference | 4.8 V |
Suggested maximum at the ADC pin. ESP32 and ESP32-C3: datasheet range at 11/12 dB attenuation. ESP32-S3: Espressif’s measured range. RP2040: the ADC reads 0 V to ADC_AVDD, 3.3 V nominal. ATmega328P: 0 V to AVCC, kept a little below 5 V because the USB supply is often slightly low.
High values save battery but leave the ADC with a weak source. A 100 nF capacitor from the ADC pin to ground fixes that for slow signals such as a battery voltage.
Choosing the values
The ratio of the two resistors sets the voltage; their sum sets the current and how stiff the output is. Low values (1–10 kΩ) hold the output steady under a light load but draw milliamps. High values (100 kΩ–1 MΩ) draw microamps, which is what you want from a battery. With 1 % resistors the output can be off by up to about 2 %.
What a divider is not for
A divider can’t power anything: a load on the output sits in parallel with R2 and pulls the voltage down. To run a circuit at a lower voltage use a regulator. For slow logic signals, such as a 5 V serial TX into a 3.3 V RX, a divider of 1 kΩ and 2 kΩ is a common, simple level shifter.
Frequently asked questions
How do I get 3.3 V from 5 V with resistors?
For a signal, 1 kΩ on top and 2 kΩ below give 3.33 V. To power a 3.3 V circuit from 5 V, use a regulator: a divider’s voltage collapses as soon as something draws current.
Which resistors measure a 12 V battery with an ESP32?
A lead-acid battery reaches about 14.5 V when charging. 68 kΩ and 12 kΩ give 2.18 V at 14.5 V and keep the ESP32 ADC within range up to about 16 V. Add 100 nF at the pin and use an ADC1 pin.
Why does the output change when I connect something?
The load sits in parallel with R2 and lowers it. For about 1 % error, keep the load at least 100 times the divider’s output impedance (R1 and R2 in parallel); 10 times gives about 10 %. Or buffer the output with an op-amp.
Which one is R1?
R1 is the top resistor, between the input and the output. R2 is the bottom one, between the output and ground. Swapping them gives Vin − Vout instead of Vout.