
ADC Explained: Resolution, Reference Voltage, and ESP32 Limits
An ADC, or analog to digital converter, turns a voltage into a number. A 12-bit ADC divides its input range into 4,096 steps, numbered 0 to 4,095. A 10-bit ADC divides the range into 1,024 steps, numbered 0 to 1,023. The reference voltage sets the top of that range, and on the ESP32 ADC2 pins stop working while Wi-Fi runs.
ADC explained: what is an ADC?
An ADC measures a voltage on a pin and returns a digital number. The number is proportional to the input voltage divided by the reference voltage, times the number of steps. A sensor that outputs a voltage, such as a temperature sensor, a light sensor or a potentiometer, needs an ADC to turn its signal into a number your code can use. A sensor that outputs a digital signal, such as an I2C temperature sensor, does not need an ADC, because the sensor chip does the conversion itself.
Most microcontroller ADCs use successive approximation, or SAR. The ADC samples the pin voltage, compares it against an internal reference in a series of steps, and writes a digital value. The conversion takes microseconds, and the result is a single number per read. That number is not a voltage until your code converts it, using the resolution and the reference voltage.
What is resolution and why does it matter?
Resolution is the number of bits in the ADC result, and it decides the smallest voltage change the ADC can see. A 10-bit ADC has 1,024 steps. A 12-bit ADC has 4,096 steps. On a 3.3 V range, a 10-bit step is 3.3 V divided by 1,024, or about 3.22 mV per step. A 12-bit step is 3.3 V divided by 4,096, or about 0.81 mV per step. The 12-bit ADC sees a change four times smaller than the 10-bit ADC.
| ADC resolution (bits) | Steps (count) | Step size on 3.3 V (mV) | Boards |
|---|---|---|---|
| 10 | 1,024 | 3.22 | Arduino Uno, Nano, ESP8266 |
| 12 | 4,096 | 0.81 | ESP32, ESP32-S3, Raspberry Pi Pico, RP2040 |
More bits do not always mean more accuracy. The ESP32 ADC is 12-bit, but its effective resolution is about 10 to 11 bits, because noise and nonlinearity eat the last bits. Averaging 16 to 64 readings gives a steadier result than chasing the last bit of a single read. A 10-bit ADC on an Arduino Uno with a clean supply and a short wire can beat a noisy 12-bit reading on a long wire next to a Wi-Fi antenna.
What is reference voltage?
The reference voltage is the voltage that maps to the top ADC value. On an Arduino Uno, the default reference is the 5 V supply, so a 5 V input reads 1,023 and a 2.5 V input reads about 511. On the Raspberry Pi Pico, the reference is 3.3 V, so a 3.3 V input reads 4,095. On the ESP32, the reference voltage is about 1.1 V at the ADC itself, not 3.3 V, and the chip applies attenuation to scale the input before it reaches the ADC.
That ESP32 detail causes the most confusion. A 3.3 V signal on an ESP32 ADC pin does not damage the pin, because the attenuation scales it down before the converter, but the raw reading does not map linearly to 3.3 V without the attenuation setting. Use analogReadMilliVolts on the ESP32 Arduino core, which applies the factory calibration and returns millivolts, instead of converting the raw count yourself with a 3.3 V assumption.
What is attenuation on the ESP32?
Attenuation reduces the input voltage before it reaches the ADC, which widens the measurable range. The ESP32 Arduino core offers four settings: 0 dB, 2.5 dB, 6 dB and 11 dB. At 0 dB, the measurable range is about 0 mV to 950 mV. At 2.5 dB, it is about 100 mV to 1,250 mV. At 6 dB, it is about 150 mV to 1,750 mV. At 11 dB, it is about 150 mV to 2,450 mV, which is the widest range and the default in the Arduino core.
Set the attenuation per pin for your sensor range. A sensor that outputs 0 V to 1 V needs 2.5 dB attenuation. A sensor that outputs 0 V to 3.3 V needs 11 dB attenuation, and even then the top of the range saturates at about 3.1 V. The ESP32 ADC is also nonlinear near the ends of its range, so readings near 0 mV and near the top are compressed. For a battery voltage measurement, use a voltage divider that keeps the ADC input in the middle of its range, and average many readings.
Why does ADC2 stop working with Wi-Fi on the ESP32?
The original ESP32 has two ADC units. ADC1 has 8 channels on GPIO 32 to 39. ADC2 has 10 channels on GPIO 0, 2, 4, 12 to 15 and 25 to 27. The Wi-Fi driver uses ADC2 internally, so ADC2 cannot be read while Wi-Fi is active. The Espressif ESP-IDF ADC guide states this directly: the application can only use ADC2 when the Wi-Fi driver has not started, and a read on ADC2 fails between Wi-Fi start and Wi-Fi stop.
The symptom is a sensor that reads correctly before WiFi.begin and returns zero or a stale value after the connection starts. The fix is to move the sensor to an ADC1 pin, GPIO 32 to 39. Remember that GPIO 34 to 39 are input only, so they read a sensor but cannot drive an output. The S3 also restricts ADC2 while Wi-Fi runs. The C3 has only one ADC unit, so it has no ADC2 conflict at all. Check the ADC section of your chip datasheet before you wire a sensor.
Some ADC2 pins carry extra traps. GPIO 0, 2 and 15 are strapping pins, so a sensor on those pins can stop the board from booting. On the ESP32 DevKitC, GPIO 0 cannot be used freely because of the auto program circuit. Prefer ADC1 pins for any sensor in a Wi-Fi project, and keep ADC2 for projects with no Wi-Fi at all.
How do Arduino, ESP32 and Pico ADCs compare?
| Spec (unit) | Arduino Uno ATmega328P | ESP32 | Raspberry Pi Pico RP2040 |
|---|---|---|---|
| Resolution (bits) | 10 | 12 | 12 |
| Steps (count) | 1,024 | 4,096 | 4,096 |
| ADC channels (count) | 6 on DIP, 8 on TQFP | 18 across two units | 4 external plus temperature |
| Reference voltage (V) | 5, supply by default | About 1.1 before attenuation | 3.3 |
| Max sample rate | About 10 ksps | Up to 2 Msps with DMA | 500 ksps |
| Wi-Fi conflict | None | ADC2 blocked by Wi-Fi | None on base Pico |
The Pico ADC is the simplest to use: a 3.3 V reference, 12-bit resolution, and no Wi-Fi conflict on the base board. The Arduino ADC is the simplest to understand: a 5 V reference and a direct count to voltage conversion. The ESP32 ADC is the most capable and the most confusing, because of its attenuation settings and its ADC2 conflict, so read the ADC section of the ESP-IDF guide before you trust a reading.
How do you get an accurate reading?
Follow five steps. First, pick an ADC1 pin on the ESP32, or any ADC pin on the Pico or Arduino. Second, set the attenuation for your sensor range on the ESP32, or set the reference on the Arduino. Third, keep the wires short and add a 0.1 uF capacitor from the ADC pin to ground to filter noise. Fourth, average 16 to 64 readings instead of trusting one. Fifth, use the calibrated millivolt function where the core provides one, such as analogReadMilliVolts on the ESP32, instead of converting the raw count with an assumed reference.
Never exceed the ADC input voltage. On the ESP32, the pin tolerates 3.3 V, but the measurable range tops out near 3.1 V at 11 dB attenuation. On the Pico, the pin tolerates 3.3 V and the ADC input must stay below the 3.3 V supply plus a small margin. On the Arduino Uno, the pin tolerates 5 V. A sensor that outputs more than the ADC range needs a voltage divider, and the divider ratio must be included in your conversion math.
Code: read an ESP32 ADC pin with averaging
The sketch below reads an ESP32 ADC1 pin with 11 dB attenuation and averages 32 readings. It uses the ESP32 Arduino core. It was not compiled in this draft, and the compile result is logged as code not compiled in the header.
// ESP32 ADC read with averaging on an ADC1 pin
// Board: ESP32 DevKit V1. Sensor on GPIO 34, which is ADC1 channel 6.
const int adcPin = 34; // ADC1 only, so Wi-Fi can run at the same time
void setup() {
Serial.begin(115200);
analogSetPinAttenuation(adcPin, ADC_11db); // Widest range, about 0 to 3.1 V
analogReadResolution(12); // 12-bit result, 0 to 4095
}
void loop() {
long total = 0;
for (int i = 0; i < 32; i++) {
total += analogReadMilliVolts(adcPin); // Calibrated millivolts, not raw counts
delay(2);
}
long averageMilliVolts = total / 32;
Serial.print("Sensor voltage (mV): ");
Serial.println(averageMilliVolts);
delay(500);
}
For the Pico ADC pins in this guide, see the Raspberry Pi Pico pinout guide.
FAQ
Why does my ESP32 analogRead return 0 when Wi-Fi is on?
Your sensor is on an ADC2 pin, and the Wi-Fi driver uses ADC2. Move the sensor to an ADC1 pin, GPIO 32 to 39, and the readings return.
Is a 12-bit ADC always better than a 10-bit ADC?
No. A 12-bit ADC has finer steps, but noise and nonlinearity limit its effective resolution to about 10 to 11 bits on the ESP32. A clean 10-bit reading beats a noisy 12-bit reading, so average many samples and keep wires short.
What voltage can I put on an ESP32 ADC pin?
Up to 3.3 V on the pin. The measurable range tops out near 3.1 V at 11 dB attenuation, so a sensor above that needs a voltage divider.
How many ADC pins does the ESP32 have?
18 channels across two ADC units: 8 on ADC1 at GPIO 32 to 39, and 10 on ADC2 at GPIO 0, 2, 4, 12 to 15 and 25 to 27. A 30-pin board exposes 16 of them, because GPIO 37 and 38 are not broken out.
What is the ADC reference voltage on an Arduino Uno?
5 V by default, from the supply. A 5 V input reads 1,023 and a 2.5 V input reads about 511. The reference can be changed to the internal 1.1 V bandgap or an external AREF voltage.
Parts used
ESP32 DevKit V1 Development Board, 30-Pin WROOM-32: the ESP32 board for the ADC examples, with 18 ADC channels. ELEGOO UNO R3 Microcontroller Board: the Arduino board for the 10-bit ADC comparison.
Sources
- Espressif ESP-IDF ADC guide, ADC1 and ADC2 channels, Wi-Fi conflict, attenuation
- Espressif ESP32 Series Datasheet v5.3
- Raspberry Pi RP2040 Datasheet, build date 2025-02-20, 12-bit ADC, 500 ksps
- ATmega328P pinout and limits, Microchip datasheet DS40002061B
Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.





