Voltage divider calculator for Arduino and ESP32 analog pins
Pick your board and the voltage you want to read. Get two resistors from your kit, the voltage at the pin and the number the board will report.
The short answer
A voltage divider is two resistors in a row that scale a voltage down so an analog pin can read it. The pin voltage is the input times R2, divided by R1 plus R2. To read a 9 V battery on an Arduino Uno, use 10 kΩ for R1 and 10 kΩ for R2: the pin gets 4.5 V.
Size a divider for an analog pin
Pick your board and the voltage you want to read. The answer updates as you go.
Its analog pins read 0 to 5 V as 0 to 1023.
Pick one, or type your own voltage below.
Use the highest it can ever be: a full 9 V battery, not a flat one.
Use these two resistors
R1, to the pin
10 kilohms
Brown, Black, Orange, Gold
R2, pin to GND
10 kilohms
Brown, Black, Orange, Gold
At 9 V the pin sits at 4.5 V and the board reports 921 of 1023.
- Warning. Never connect 9 V straight to the pin. The chip maker's maximum for one ATmega328P pin is 5.5 V, and above it the chip can be damaged. The two resistors bring it down to a safe level.
- Voltage at the pin
- 4.5 VKeep it at or below 5 V
- Arduino Uno reports
- 921On a scale of 0 to 1023
- Current through the divider
- 450 µAIt flows all the time
- One step of the reading
- 9.766 mVReading times this gives the voltage
- Pin reaches the supply at
- 10 VNever measure more than this
Wire it in one line: the voltage you measure, then the 10 kΩ resistor, then the analog pin. The 10 kΩ resistor goes from the same pin to GND. Join the two grounds.
Other kit pairs that work
- R1 12 kΩ and R2 12 kΩ: pin at 4.5 V, reads 921.
- R1 8.2 kΩ and R2 8.2 kΩ: pin at 4.5 V, reads 921.
- R1 6.8 kΩ and R2 6.8 kΩ: pin at 4.5 V, reads 921.
Assumes an Uno R3 or a clone with the ATmega328P chip running at 5 V. The Uno R4 uses a different chip, so these pin limits do not apply to it.
Where these limits come from
Microchip ATmega48A/PA/88A/PA/168A/PA/328/P data sheet DS40002061B, sections 24.1, 24.6.1 and 24.7.
Microchip ATmega48A/PA/88A/PA/168A/PA/328/P data sheet DS40002061B, section 29.1 Absolute Maximum Ratings (voltage on any pin).
Build it
A photoresistor with a 10 kΩ resistor is the same divider, read on A0. The AI Builder opens the editor with a night light that reads the light level and turns an LED on when the room gets dark. It plans the project for an Arduino Uno.
Made for analog pins
The tool knows the analog range of each board: 0 to 5 V read as 0 to 1023 on an Uno, Nano or Mega, and 0 to 3.3 V read as 0 to 4095 on an ESP32. It gives you the number the board will report, not only a voltage.
Resistors you already own
Every pair comes from standard kit values and adds up to between 10 kΩ and 40 kΩ. That is low enough for a steady reading, and high enough that the divider draws under 1 mA from a 9 V battery.
It tells you what is not safe
A voltage above the supply of the board can damage an analog pin. The tool says so in plain words, shows the highest voltage the chosen pair can take, and flags a pair that 5 percent resistors could push over the limit.
How it is worked out
Two resistors in a row share the voltage in proportion to their values. The pin sits between them:
V pin = V in x R2 / (R1 + R2)
The board then turns the pin voltage into a number. On an Uno, Nano or Mega the chip maker gives the formula: reading = V pin x 1024 / 5, rounded down, with 1023 as the highest value. On an ESP32 the tool estimates V pin x 4095 / 3.3, and says about, because that chip publishes no exact formula.
Worked example: a 12 V supply on an Uno. With 6.8 kΩ for R1 and 3.9 kΩ for R2, the pin sits at 12 x 3900 / 10700 = 4.374 V, and the board reports 895.
What the tool assumes
- You enter the highest voltage the input can ever reach. At that voltage the tool aims the pin at 4.5 V on a 5 V board, which leaves a margin below the supply, and at 2.45 V on an ESP32, the top of the range that chip reads dependably.
- R1 is always rounded up to a kit value, so the pin never lands above that target.
- R1 plus R2 stays between 10 kΩ and 40 kΩ. The pin then sees 10 kΩ or less, which is what the analog input of the Uno, Nano and Mega is designed for.
- Kit resistors are 5 percent parts. The tool checks the pin voltage with both resistors off in the bad direction.
- The analog reference is the supply of the board, the Arduino default. If the 5 V of your board is a little low or high, the reading shifts with it.
- The pin limits come from the datasheet of the chip maker: the ATmega328P for the Uno and the classic Nano, the ATmega2560 for the Mega, and the ESP32 series datasheet. The Uno R4, 3.3 V Nano variants and the ESP32-S2, S3 and C3 have other analog ranges.
- The tool stops at 60 V. It is for batteries and low-voltage supplies, never for mains power.
Need more depth? The full voltage divider calculator from InteRFace R&D adds finer resistor series, your own tolerance, a load on the output and regulator feedback dividers. It opens in a new tab.
The divider you may already have built
A light sensor circuit is the same thing with one resistor that moves. The photoresistor guide is written for an Uno: it wires a photoresistor from the 5 V pin to A0 and a 10 kΩ resistor from A0 to GND. On an ESP32 the photoresistor goes on the 3.3 V pin instead, because 5 V would put more on the pin than that chip allows. Pick the photoresistor preset in the calculator to see the reading for the resistance your sensor has right now.
In ArduinoStudio the reading feeds a Check block, which lets a sequence continue above or below a level you set. You can test that with no parts in the Arduino simulator in the browser: it gives each analog pin a slider. The slider stands in for the voltage, so the divider itself still has to be right on the real board.
Need to find the two resistors in your kit? The resistor color code calculator shows their bands. For an LED on a pin, use the LED resistor calculator.
Try an analog pin with no parts
Test the logic of an analog project before the divider is on the desk. The demo opens a working project in the browser with no account. It shows the logic, not the voltage on a real pin.
Open the live demoMore calculators and guides
Quick answers
How do I read a 9 V battery with an Arduino?
Use two resistors: 10 kΩ for R1 and 10 kΩ for R2. R1 goes from the battery plus to an analog pin, R2 from the same pin to GND, and the battery minus to GND. At 9 V the pin sits at 4.5 V and an Uno reports 921. Multiply the reading by 9.766 mV to get the battery voltage back.
Can I connect 5 V to an ESP32 analog pin?
No. ESP32 pins run at 3.3 V, and 5 V is above what the chip maker allows on a pin. Use a divider: 5.6 kΩ for R1 and 4.7 kΩ for R2 bring 5 V down to 2.282 V.
Why are ESP32 analog readings not exact?
The analog input of the ESP32 is not even across its range, and the chip maker states that readings differ from chip to chip. It gives 150 mV to 2.45 V as the range the chip reads dependably at the default setting. This tool aims the pin at 2.45 V or less and marks every ESP32 reading with the word about.
Which way round do the two resistors go?
R1 goes from the voltage you measure to the analog pin. R2 goes from the same pin to GND. The GND of the thing you measure must be joined to a GND pin of the board. Swapping R1 and R2 puts most of the voltage on the pin, which can damage it.
How does a photoresistor use a voltage divider?
A photoresistor is a resistor that changes with light. Put it between the supply pin of the board and A0: the 5 V pin on an Uno, the 3.3 V pin on an ESP32. Add a fixed 10 kΩ resistor between A0 and GND, and the two form a divider whose output follows the light. Bright light lowers its resistance and raises the reading.
Does a voltage divider drain the battery?
A little, all the time. The pair for a 9 V battery draws 450 µA for as long as the battery is connected, even while the board is off. For a project that must last months on one battery, disconnect the divider between readings.
Last updated 2026-12-02.