ESP32 ADC Pins: Complete Analog Input Guide
The ESP32 has 18 Analog-to-Digital Converter (ADC) channels spread across two independent ADC blocks: ADC1 and ADC2. Understanding the difference between them β especially the Wi-Fi conflict on ADC2 β is critical for reliable analog sensor readings in ESP32 projects.
This guide covers every ESP32 ADC pin, explains the ADC1 vs ADC2 conflict, shows you how to read analog values in Arduino, and helps you choose the right pins for your sensors.
ESP32 ADC Pin Table
Here is the complete list of all 18 ADC channels on the classic ESP32 (ESP-WROOM-32):
| ADC Block | Channel | GPIO Pin | Notes |
|---|---|---|---|
| ADC1 | CH0 | GPIO36 | Input-only (SENSOR_VP) |
| ADC1 | CH3 | GPIO39 | Input-only (SENSOR_VN) |
| ADC1 | CH6 | GPIO34 | Input-only |
| ADC1 | CH7 | GPIO35 | Input-only |
| ADC1 | CH4 | GPIO32 | Also TOUCH9, RTC |
| ADC1 | CH5 | GPIO33 | Also TOUCH8, RTC |
| ADC1 | CH0 | GPIO36 | Also SENSOR_VP |
| ADC1 | CH1 | GPIO37 | Not broken out on most dev boards |
| ADC1 | CH2 | GPIO38 | Not broken out on most dev boards |
| ADC2 | CH0 | GPIO4 | Also TOUCH0 |
| ADC2 | CH1 | GPIO0 | Strapping pin |
| ADC2 | CH2 | GPIO2 | Strapping pin |
| ADC2 | CH3 | GPIO15 | Strapping pin |
| ADC2 | CH4 | GPIO13 | Also TOUCH4 |
| ADC2 | CH5 | GPIO12 | Strapping pin (MTDI) |
| ADC2 | CH6 | GPIO14 | Also TOUCH6, HSPI_CLK |
| ADC2 | CH7 | GPIO27 | Also TOUCH7 |
| ADC2 | CH8 | GPIO25 | Also DAC_1 |
| ADC2 | CH9 | GPIO26 | Also DAC_2 |
ADC1 vs ADC2: The Wi-Fi Conflict
Both ADC1 and ADC2 are 12-bit successive-approximation ADCs with the same resolution (0β4095). However, there is one critical difference:
- ADC1 is independent and works reliably whether Wi-Fi is on or off.
- ADC2 is shared with the Wi-Fi subsystem. When the Wi-Fi driver is active, ADC2 measurements become unreliable or fail entirely.
This is a hardware limitation documented by Espressif. The Wi-Fi driver uses the ADC2 hardware for its own signal detection. If your project uses any Wi-Fi functionality (HTTP, MQTT, WebSockets, OTA, etc.), you must avoid ADC2 pins for analog sensors.
Input-Only ADC Pins
Four ADC1 pins β GPIO34, GPIO35, GPIO36, and GPIO39 β are input-only. They lack output drivers and cannot drive LEDs, relays, or other output loads. They can only read analog or digital input signals.
These pins are excellent choices for dedicated analog sensors, as there is no risk of accidentally configuring them as outputs.
Arduino Code: Reading ESP32 ADC
Here is a simple Arduino sketch to read analog values from an ADC1 pin:
// ESP32 ADC1 Example - Read analog from GPIO34
const int adcPin = 34; // GPIO34 is ADC1_CH6
void setup() {
Serial.begin(115200);
// Optional: set ADC resolution (default is 12-bit)
analogReadResolution(12);
// Optional: set ADC attenuation for higher voltage range
analogSetAttenuation(ADC_11db); // 0-3.3V range
}
void loop() {
int adcValue = analogRead(adcPin);
float voltage = adcValue * (3.3 / 4095.0);
Serial.print("ADC Value: ");
Serial.print(adcValue);
Serial.print(" Voltage: ");
Serial.println(voltage);
delay(500);
}
ADC Attenuation Settings
The ESP32 ADC has configurable attenuation that changes the measurable voltage range:
| Attenuation | Measurable Range | Typical Use |
|---|---|---|
ADC_0db | 0β1.1V | Low-voltage sensors |
ADC_2_5db | 0β1.5V | Medium range |
ADC_6db | 0β2.2V | General purpose |
ADC_11db | 0β3.3V | Most common (default) |
Reading Multiple ADC Channels
Here is an example that reads all available ADC1 pins:
// ESP32 Read All ADC1 Channels
const int adcPins[] = {32, 33, 34, 35, 36, 39};
const int numPins = 6;
void setup() {
Serial.begin(115200);
analogReadResolution(12);
analogSetAttenuation(ADC_11db);
}
void loop() {
for (int i = 0; i < numPins; i++) {
int val = analogRead(adcPins[i]);
Serial.print("GPIO");
Serial.print(adcPins[i]);
Serial.print(": ");
Serial.print(val);
Serial.print(" ");
}
Serial.println();
delay(1000);
}
ESP32 ADC Accuracy and Calibration
The ESP32 ADC is known for non-linearities across its range. For precise measurements, Espressif provides an ADC calibration API (esp_adc_cal) that uses factory-programmed eFuse values to improve accuracy.
Key accuracy facts:
- Typical uncalibrated error: Β±2% to Β±6% depending on voltage range
- With eFuse calibration: Β±1% to Β±2%
- For precise measurements, use an external ADC (e.g., ADS1115) or the calibration API
Best ADC Pins for Common Sensor Types
| Sensor Type | Recommended Pins | Notes |
|---|---|---|
| Potentiometer / Voltage Divider | GPIO34 GPIO35 | Input-only, safe, no conflicts |
| Temperature Sensor (LM35, TMP36) | GPIO32 GPIO33 | Also usable as GPIO |
| Light Sensor (LDR + resistor) | GPIO36 GPIO39 | Input-only but detectable via ADC |
| Soil Moisture Sensor | GPIO34 | Input-only, dedicated analog |
| Hall Effect Sensor | GPIO32 | Also supports touch sensing |
π§ Try Our Interactive ESP32 Pinout Tool
Click on any pin in our interactive tool to see its full ADC configuration, alternate functions, and hardware notes.
Open Interactive PinoutFrequently Asked Questions
Can I use ADC2 pins if I don't use Wi-Fi?
Yes. If your project does not enable Wi-Fi or Bluetooth, ADC2 pins work identically to ADC1. This is common in battery-powered deep-sleep sensor nodes that wake, read sensors, process data, and sleep without connecting to Wi-Fi.
What is the maximum ADC sampling rate?
The ESP32 ADC can sample at up to 6 kHz (6,000 samples/second) with 12-bit resolution in continuous mode. For most sensor applications, this is more than sufficient.
Why are my ADC readings noisy?
ESP32 ADC noise is common due to the chip's internal switching. Mitigation strategies include: using the ADC calibration API, averaging multiple readings, adding a 100nF capacitor between the analog pin and ground, and using shielded wires for sensitive measurements.