Voltage divider for ADCs
Scale a sensor or battery voltage into your microcontroller's ADC and check it lands inside the range where readings are accurate. The defaults fit an MQ-2 gas sensor's 5 V output to an ESP32.
Use ADC1 pins (GPIO32 to GPIO39). ADC2 reads fail while Wi-Fi is running.
Standard E12 pairs that fit, under 100 µA
- At the pin, highest
- 2.27V
- Range in use
- 93%
- Input per ADC step
- 1.32mV
- Divider current
- 227µA
The signal fits the recommended range.
- This divider draws more than 100 µA. On a battery node, switch it off between readings or use larger resistors.
Ratio 0.455. The ADC pin sees 5.45 kΩ; your signal sees a 22 kΩ load. R1 dissipates 620 µW.
How it works
R1 sits between the signal and the ADC pin; R2 between the pin and ground.
ratio = R2 ÷ (R1 + R2) voltage at pin = signal × ratio current = signal ÷ (R1 + R2) pin impedance = R1 × R2 ÷ (R1 + R2)
The accurate ranges for Espressif chips come from the ESP-IDF ADC documentation, one per attenuation setting. On the original ESP32, readings below about 100 to 150 mV are not reliable, so the tool flags a signal whose low end falls there.
Suggestions search every pair of standard E12 values from 1 kΩ to 1 MΩ, keep those that put your highest voltage just under the top of the range while drawing under 100 µA, and show the closest three.
What it leaves out
It assumes ideal resistors. With 5% parts the ratio can move by several percent; calibrate in firmware.
It doesn’t model the source. A sensor with a high output impedance loads differently than a battery.
Input per ADC step is approximate: real ADCs have offset and non-linearity, especially near the ends.
