Skip to content
GEEKnodes

Electronics

Voltage Divider Calculator: Formula and Uses with Arduino and ESP32

Work out the output voltage of a resistor divider. The formula, how to pick R1 and R2, reading a battery with an ADC and shifting 5 V to 3.3 V safely.

A voltage divider is two resistors in series that give you a fraction of the input voltage. It’s one of the most useful circuits around: you can use it to measure batteries, read resistive sensors and step 5 V signals down to 3.3 V.

In short

  • Vout = Vin × R2 / (R1 + R2): the output depends only on the ratio between the resistors.
  • It’s for measuring voltages, not for powering anything.
  • Typical values: between 1 kΩ and 100 kΩ in total.

Calculator

Vout
—
Current
—
Total power
—

How it works

The two resistors are connected in series between the input voltage and ground. The output is taken at the point where they meet:

Vin ──[ R1 ]──┬──[ R2 ]── GND
              │
             Vout
Divider schematic: R1 connects Vin to Vout and R2 connects Vout to GND.
Vout is taken at the junction between the two resistors.

The same current flows through both, so the voltage is split in proportion to their values. If R1 and R2 are equal, Vout is exactly half of Vin.

The formula

Vout = Vin × R2 / (R1 + R2)

And if you know the Vout you want and one of the resistors, you can solve for the other:

R1 = R2 × (Vin − Vout) / Vout

Practical uses

Measuring a battery with Arduino or ESP32

An ESP32’s ADC only accepts up to 3.3 V (and in practice it’s more accurate below ~2.5 V). To measure a 2-cell LiPo battery (up to 8.4 V) you need to bring the voltage down:

  • R1 = 100 kΩ, R2 = 33 kΩ → Vout = 8.4 × 33 / 133 ≈ 2.08 V.
  • Divider current draw: 8.4 / 133,000 ≈ 63 µA, acceptable in a battery-powered device.
An 8.4 V battery feeds a 100 kΩ and 33 kΩ divider; its 2.08 V output goes to the ADC.
The divider keeps the measured voltage within the ADC’s range.

In your code, multiply the reading by (R1 + R2) / R2 to get the real voltage back.

Stepping a 5 V signal down to 3.3 V

To connect the TX output of a 5 V module to the RX of an ESP32 or a Raspberry Pi:

  • R1 = 1 kΩ, R2 = 2 kΩ → Vout = 5 × 2 / 3 ≈ 3.33 V.
A 1 kΩ and 2 kΩ divider brings 5 V TX down to about 3.3 V for RX.
The signal goes one way: from TX to RX.

It works for one-way signals that aren’t very fast. For bidirectional buses (like I2C), use a level shifter. We explain it in I2C, SPI and UART.

Reading a resistive sensor (LDR, thermistor)

If you replace R2 with a sensor whose resistance changes (an LDR with light or an NTC with temperature), Vout varies with the quantity you want to measure. You read it with an analog input.

How to choose the values

Total R1 + R2AdvantageDrawback
Under 1 kΩVery stableDraws a lot of current and heats up
10 kΩ – 100 kΩGood balance—
Over 1 MΩMinimal current drawThe ADC input or the load skews the reading

A handy rule: the impedance of whatever you connect to Vout has to be at least 10 times higher than R2, or the output will drop.

Why it can’t power anything

A very common mistake is using a divider to get 3.3 V from 5 V and powering a module with it. As soon as the module draws current, it acts like a resistor in parallel with R2 and Vout drops. On top of that, the voltage will change depending on how much the module draws at any given moment. To power something, use a regulator (LDO or DC-DC converter).

Common mistakes

  • Swapping R1 and R2: R1 is the top one (toward Vin) and R2 the bottom one (toward GND).
  • Forgetting the headroom: if the battery can go above its nominal voltage (a charged LiPo gives 4.2 V per cell), calculate with the maximum voltage.
  • Tolerances: with 5% resistors, the result can be off by several percent. Use 1% resistors or calibrate in code.
  • Divider always connected: in battery-powered devices, the divider draws current even when you’re not measuring. Use high values or a transistor to disconnect it.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor