The pins to avoid or handle with care
The ESP32 has 34 GPIOs, but on a DevKit only about two thirds of them behave like plain pins. Four groups need attention.
GPIO 6 to 11: taken by the flash
These six pins connect the chip to the SPI flash inside the module. DevKitC boards bring them out as CLK, SD0, SD1, SD2, SD3 and CMD, but touching them crashes the program or stops the board from booting.
GPIO 0, 2, 5, 12 and 15: strapping pins
The chip reads these pins at reset to decide how to start. Once the program runs they are normal GPIOs, so they work well as outputs or for buttons. Trouble comes from anything that forces the wrong level at power-up, such as a pull-up resistor, a module that drives the line or a sensor that holds it.
| GPIO | Default at reset | What it selects | In practice |
|---|---|---|---|
| 0 | Pull-up (HIGH) | Boot mode: HIGH runs the program, LOW enters download mode | Nothing may hold it LOW at power-up |
| 2 | Pull-down (LOW) | Must be LOW or floating for download mode | No pull-up; often the onboard LED |
| 5 | Pull-up (HIGH) | SDIO slave timing, with GPIO15 | Safe for most uses |
| 12 | Pull-down (LOW) | Flash voltage: LOW 3.3 V, HIGH 1.8 V | Never pull HIGH at reset |
| 15 | Pull-up (HIGH) | Boot log on UART0: HIGH prints it, LOW silences it | Safe; LOW only hides the log |
GPIO 34 to 39: input only
These pins have no output driver and no internal pull-up or pull-down. They are a good place for analog readings and buttons with an external resistor. They can’t drive an LED, a relay or a bus line. GPIO 37 and 38 exist on the chip but are not brought out on WROOM modules.
GPIO 1 and 3: the USB serial port
UART0 runs to the USB-serial chip and carries both uploads and Serial. You can reuse these pins in a finished project, but you lose the serial monitor and uploads can fail while something is connected.
ADC2 stops working when Wi-Fi is on
The ESP32 has two ADCs. ADC1 is on GPIO 32 to 39, ADC2 on GPIO 0, 2, 4, 12 to 15 and 25 to 27. The Wi-Fi driver uses ADC2, so as soon as Wi-Fi starts, reads on those pins fail or return garbage. In a connected project, put every analog input on ADC1. Measuring a battery? GPIO 34 or 35 with a resistor divider is the usual choice.
Even on ADC1 the readings are not linear near the ends of the range. With 12 dB attenuation Espressif recommends staying roughly between 0.15 V and 2.45 V for accurate results, so size the divider to keep the signal in that window.
Full ESP32 GPIO table
| GPIO | Status | ADC | Touch | RTC | Notes |
|---|---|---|---|---|---|
| GPIO0 | Use with care | ADC2_CH1 | T1 | RTC_GPIO11 | strapping |
| GPIO1 (TX) | Use with care | — | — | — | USB serial, UART0 TX |
| GPIO2 | Use with care | ADC2_CH2 | T2 | RTC_GPIO12 | strapping, LED on some boards |
| GPIO3 (RX) | Use with care | — | — | — | USB serial, UART0 RX |
| GPIO4 | Free to use | ADC2_CH0 | T0 | RTC_GPIO10 | — |
| GPIO5 | Use with care | — | — | — | strapping, VSPI SS |
| GPIO6 (CLK) | Do not use | — | — | — | SPI flash |
| GPIO7 (SD0) | Do not use | — | — | — | SPI flash |
| GPIO8 (SD1) | Do not use | — | — | — | SPI flash |
| GPIO9 (SD2) | Do not use | — | — | — | SPI flash |
| GPIO10 (SD3) | Do not use | — | — | — | SPI flash |
| GPIO11 (CMD) | Do not use | — | — | — | SPI flash |
| GPIO12 | Use with care | ADC2_CH5 | T5 | RTC_GPIO15 | strapping, HSPI MISO |
| GPIO13 | Free to use | ADC2_CH4 | T4 | RTC_GPIO14 | HSPI MOSI |
| GPIO14 | Free to use | ADC2_CH6 | T6 | RTC_GPIO16 | may be active at boot, HSPI SCK |
| GPIO15 | Use with care | ADC2_CH3 | T3 | RTC_GPIO13 | strapping, HSPI SS |
| GPIO16 | Free to use | — | — | — | PSRAM on WROVER, RX2/TX2 on some boards |
| GPIO17 | Free to use | — | — | — | PSRAM on WROVER, RX2/TX2 on some boards |
| GPIO18 | Free to use | — | — | — | VSPI SCK |
| GPIO19 | Free to use | — | — | — | VSPI MISO |
| GPIO21 | Free to use | — | — | — | I2C SDA |
| GPIO22 | Free to use | — | — | — | I2C SCL |
| GPIO23 | Free to use | — | — | — | VSPI MOSI |
| GPIO25 | Free to use | ADC2_CH8 | — | RTC_GPIO6 | — |
| GPIO26 | Free to use | ADC2_CH9 | — | RTC_GPIO7 | — |
| GPIO27 | Free to use | ADC2_CH7 | T7 | RTC_GPIO17 | — |
| GPIO32 | Free to use | ADC1_CH4 | T9 | RTC_GPIO9 | 32 kHz crystal |
| GPIO33 | Free to use | ADC1_CH5 | T8 | RTC_GPIO8 | 32 kHz crystal |
| GPIO34 | Input only | ADC1_CH6 | — | RTC_GPIO4 | input only |
| GPIO35 | Input only | ADC1_CH7 | — | RTC_GPIO5 | input only |
| GPIO36 (VP) | Input only | ADC1_CH0 | — | RTC_GPIO0 | input only |
| GPIO39 (VN) | Input only | ADC1_CH3 | — | RTC_GPIO3 | input only |
RTC pins can wake the chip from deep sleep (ext0 for one pin, ext1 for a group), and touch pins can wake it with a touch. Default roles are the ones used by Arduino-ESP32: Wire on 21/22, SPI (VSPI) on 18/19/23/5. Serial2’s default pins changed in core 3.x, so pass them explicitly.
Frequently asked questions
Which ESP32 pins are safe to use?
On a DevKit the GPIOs without restrictions are 4, 13, 14, 16 to 19, 21 to 23, 25 to 27, 32 and 33. GPIO 34 to 39 are fine as inputs. GPIO 0, 2, 5, 12 and 15 work once the program runs but decide how the chip boots, and GPIO 6 to 11 belong to the flash. On WROVER modules GPIO 16 and 17 are taken by the PSRAM.
Can I use ADC2 pins with Wi-Fi?
No. The Wi-Fi driver uses ADC2, so analog reads on GPIO 0, 2, 4, 12 to 15 and 25 to 27 fail while Wi-Fi is on. Use the ADC1 pins, GPIO 32 to 39. ADC2 works again only when Wi-Fi is stopped.
Why doesn’t my ESP32 boot after I connected something to GPIO12?
GPIO12 sets the flash voltage at reset. If a pull-up or a connected module holds it HIGH, the chip powers the flash at 1.8 V and modules with 3.3 V flash fail to start. Move the connection to another pin, or burn the flash voltage into the eFuses with espefuse set-flash-voltage 3.3V. That last step is permanent and can’t be undone.
Which pins can wake the ESP32 from deep sleep?
The RTC GPIOs: 0, 2, 4, 12 to 15, 25 to 27 and 32 to 39. Use ext0 to wake on one pin and ext1 to wake on a group of pins. Touch pins can also wake the chip with a touch.
What are the default I2C and SPI pins on the ESP32?
In Arduino-ESP32, Wire uses GPIO 21 for SDA and 22 for SCL, and SPI uses the VSPI pins: 18 SCK, 19 MISO, 23 MOSI and 5 SS. Thanks to the GPIO matrix you can move them to almost any pin that supports output by passing the pins to Wire.begin() or SPI.begin().
Are ESP32 pins 5 V tolerant?
No. The GPIOs work at 3.3 V and Espressif does not rate them for 5 V. Connect 5 V signals through a level shifter or a resistor divider.