Recipe
Scale a voltage down for an input pin
Use when: a signal or supply is higher than the voltage a board's input pin is allowed to see
Goal: two resistor values whose output stays inside the pin's safe range at the highest input, without wasting much current or being loaded down
Taught in Voltage dividers
Quick recipe
-
1
Take the largest voltage the input can ever reach, not the label value. Read the pin's maximum and its HIGH threshold from the chip's datasheet.
Example
A 5 V sensor output into an ESP32-S3: input up to 5.0 V; pin maximum about 3.6 V; reads HIGH above about 2.5 V.
Why: a divider scales whatever comes in, so the worst case at the input sets the worst case at the pin.
-
2
Choose an output with margin below the maximum, and compute the ratio k = V_{out}/V_{in}.
Example
Target 3.0 V from 5.0 V: k = 3.0/5.0 = 0.6.
Why: aiming at the maximum leaves no room for a supply that runs a little high or a resistor a little off its marked value.
-
3
Pick the bottom resistor so the divider's current is acceptable and any load is at least 10 times bigger than it.
Example
R2 = 3.3 kΩ: an input drawing nanoamps is millions of ohms, far more than 10 times bigger.
Why: the ratio fixes the voltage, so the size is a free choice, spent on current and loading.
-
4
From k = R_2/(R_1 + R_2), R_1 = R_2\,\dfrac{1 - k}{k}.
Example
R_1 = 3.3\ \text{k}\Omega \times \dfrac{0.4}{0.6} = 2.2\ \text{k}\Omega.
Why: this is the divider formula rearranged for the one unknown.
-
5
Round R1 to a resistor you can buy, and recompute the output at the highest input.
- the new output is still below the pin's maximum and above its HIGH threshold — done.
- it crossed either limit — move R1 to the next value in the safe direction (bigger R1 lowers the output) and recompute.
Why: rounding changes the ratio, and only the recomputed number proves the pin is safe.
Common mistakes
- Designing for the nominal input (9 V) when the real one runs higher (a fresh 9 V battery).
- Getting the ratio upside down: the output is across R2, the bottom resistor.
- Choosing megohm resistors to save current and then measuring a loaded, lower output.
- Forgetting that the divider only protects the pin while both resistors are in place.