The ideal resistance in the circuit for scaling a 24V nominal battery system down to an ESP32-WROOM-32 ADC pin is an 82kΩ upper resistor (R1) and a 10kΩ lower resistor (R2). This specific pairing yields a safe maximum of 3.13V at the GPIO pin during peak charging voltages, while maintaining a low enough source impedance to properly charge the ESP32’s internal sampling capacitor. Sizing resistance in the circuit isn't just about hitting a target voltage; it requires balancing power dissipation, ADC input impedance, and worst-case thermal drift.
The Core Topology: Scaling High Voltage to Logic Levels
When you need to measure a high-voltage DC source—like a 24V lead-acid battery bank or a LiFePO4 pack—with a 3.3V microcontroller, you must step the voltage down. The standard topology is a two-resistor voltage divider.
Here is the node mapping for our design:
- Node A (Vin): Connected to the positive terminal of the battery/system (up to 28.8V).
- Node B (Vout): The midpoint junction between R1 and R2, routed to the ESP32 GPIO (e.g., GPIO34).
- Node C (GND): The bottom of R2, tied to the shared system ground and the ESP32 GND pin.
A common alternative is placing a 3.3V Zener diode at Node B to clamp overvoltage. However, Zener diodes have a "soft knee" and begin leaking current well below their nominal breakdown voltage. This leakage introduces non-linear distortion into your ADC readings, making accurate battery state-of-charge (SoC) calculations nearly impossible. A purely resistive divider maintains strict linearity across the entire measurement range.
Behavior Matrix: What Happens When Resistance Shifts
Every circuit design must account for component failure. In a high-impedance sensor network, a single failed resistor can either blind your microcontroller or destroy it. Below is the failure-mode contrast for the R1/R2 divider topology.
| Fault Condition | Node B Voltage (at 28.8V Vin) | Result on ESP32 GPIO | System Behavior |
|---|---|---|---|
| R1 Open (e.g., trace break) | 0.0V | Safe (0V) | ADC reads 0. Failsafe, but triggers false "battery dead" alarm. |
| R1 Short (e.g., solder bridge) | 28.8V | Fatal | Exceeds 3.3V absolute max. Destroys the ESP32 ADC pin and potentially the whole chip. |
| R2 Open (e.g., cold joint) | 28.8V (pulled up via R1) | Fatal | Node B floats to Vin. Fries the ESP32 GPIO protection diodes. |
| R2 Short (e.g., debris) | 0.0V | Safe (0V) | ADC reads 0. Failsafe, R1 dissipates maximum power (approx 10mW, well within limits). |
Notice the asymmetry in safety: an open R2 is just as dangerous as a shorted R1. This is why high-reliability designs sometimes add a secondary 3.3V TVS (Transient Voltage Suppression) diode at Node B, not for clamping normal operation, but specifically to survive an R2 open-circuit fault.
Design Walkthrough: Sizing Resistance in the Circuit for a 24V System
Let’s run the exact math to arrive at our 82kΩ / 10kΩ values. A "24V" nominal battery system actually reaches 28.8V during absorption charging. We must size our resistance in the circuit to handle this peak, not the nominal resting voltage.
Step 1: Define the Target Output
The ESP32-WROOM-32 operates at 3.3V. To leave a 200mV safety margin for noise and transients, our target maximum Vout at Node B is 3.10V.
Step 2: Calculate the Ideal Ratio
Using the voltage divider formula: Vout = Vin × (R2 / (R1 + R2))
3.10V = 28.8V × (R2 / (R1 + R2))
Target Ratio = 0.1076
Step 3: Constrain R2 for the ESP32 SAR ADC
This is where most hobbyists fail. According to the Espressif ESP32 ADC documentation, the internal Successive Approximation Register (SAR) ADC has a relatively low input impedance. During the sampling phase, an internal capacitor must charge to the voltage at Node B. If your R2 value is too high (e.g., 100kΩ), the ADC pin will draw current faster than the divider can supply it, causing the reading to sag artificially low. To ensure accurate sampling without an external op-amp buffer, R2 should be 10kΩ or lower.
Step 4: Solve for R1
Setting R2 = 10,000Ω:
0.1076 = 10,000 / (R1 + 10,000)
R1 + 10,000 = 92,936
R1 = 82,936Ω
The closest standard E24 resistor value is 82kΩ. Let's verify the real-world voltage with 82kΩ and 10kΩ:
Vout = 28.8V × (10 / 92) = 3.13V. This is perfectly within our safe 3.10V-3.30V window.
If you use standard 5% carbon film resistors, R1 could drift to 77.9kΩ (-5%) and R2 could drift to 10.5kΩ (+5%).
Worst-case Vout = 28.8V × (10.5 / 88.4) = 3.42V.
This exceeds the 3.3V absolute maximum rating of the ESP32 and will degrade or destroy the silicon. You must use 1% tolerance metal film resistors for this topology.
Decision Tree: Picking Your Exact Resistor Values
Use this decision matrix to finalize your bill of materials (BOM) based on your specific power constraints. Do not default to "whatever is in the bin" when sizing resistance in the circuit for ADC scaling.
| System Constraint | Design Priority | Required Action | Final Concrete Pick (Part Numbers) |
|---|---|---|---|
| Mains-powered or large battery (>100Ah) | ADC accuracy and stability over power savings. | Keep R2 at 10kΩ to easily drive the ESP32 sampling capacitor. | Vishay MRS25000C8203FCT00 (82kΩ, 1%, 50ppm/°C) and MRS25000C1002FCT00 (10kΩ, 1%). |
| Small battery / IoT sleep node | Minimize quiescent current draw during deep sleep. | Increase R1/R2 by 10x (820kΩ / 100kΩ). Warning: You must add a 100nF ceramic capacitor at Node B to act as a charge reservoir for the ADC, or readings will fail. | Vishay MRS25 series 820kΩ & 100kΩ + KEMET C315C104K5N5TA (100nF cap). |
| High-precision BMS (State of Charge) | Eliminate thermal drift and impedance loading entirely. | Abandon the passive divider. Use an op-amp voltage follower buffer after a high-impedance divider. | Texas Instruments MCP6001 Op-Amp buffering a 1MΩ / 120kΩ divider. |
Default Recommendation: For 90% of DIY solar monitors, RV battery trackers, and bench power supplies, select the first row. The Vishay MRS25 metal film series offers 50ppm/°C temperature stability, meaning your ADC calibration won't drift when the enclosure heats up in the sun. Buy the 82kΩ and 10kΩ 1% variants.
Breadboard Verification: Step-by-Step Testing
Never wire a newly calculated voltage divider directly to a microcontroller. A single transposed digit in your resistor color code reading will send 24V straight into your 3.3V logic rail. Follow this verification sequence on your workbench.
- Insert the Components: Place the Vishay 82kΩ (R1) and 10kΩ (R2) resistors in series on a breadboard. Verify the color bands: R1 should be Grey-Red-Black-Red-Brown. R2 should be Brown-Black-Black-Red-Brown.
- Establish the Ground Reference: Connect Node C (the free leg of R2) to the negative rail of your breadboard. Connect your bench power supply's ground to this same rail.
- Apply Test Voltage: Set your bench power supply to 24.0V with a current limit of 100mA. Connect the positive output to Node A (the free leg of R1).
- Measure Node B (The Critical Step): Using a calibrated digital multimeter (DMM), probe Node B (the junction of R1 and R2). You should read between 2.58V and 2.62V. If you read >3V or <1V, power down immediately and check for a swapped resistor.
- Simulate Peak Charging: Increase the bench power supply to 28.8V. Probe Node B again. Your DMM must read 3.13V (±0.05V). This confirms the 1% tolerance is holding and the ESP32 will remain safe during battery equalization.
- Check for Noise (Optional but Recommended): If you have an oscilloscope, connect the probe to Node B. Look for high-frequency switching noise. If you see >50mV of ripple, add a 100nF ceramic capacitor in parallel with R2 to filter the ADC input.
- Connect to the MCU: Only after the DMM confirms 3.13V at 28.8V input should you run a jumper wire from Node B to your ESP32 GPIO34 pin.
By treating the selection of resistance in the circuit as a strict engineering exercise rather than a guessing game, you eliminate the most common cause of fried microcontrollers in DIY power systems. Stick to 1% metal film, respect the ADC's impedance requirements, and always verify with a meter before applying power to the logic board.






