← All projects
Basics Beginner

ESP32 DevKit Pinout: Which GPIOs You Can Use and Which Are Better Left Alone

38 pins, yet only about fifteen are free for anything. A cheat sheet with explanations: the flash pins, the input-only GPIO34–39, the strapping pins that stop the board from flashing, ADC2 and Wi-Fi, current limits, and the pins that wake it from deep sleep.

Difficulty
Beginner
Time
20 min
Category
Basics
Updated

The short answer

For buttons, LEDs, relays and sensors, use GPIO4, 13, 14, 16–19, 21–23, 25–27, 32, 33 without a second thought. For analog inputs use GPIO32–39 (ADC1). Everything else comes with caveats, explained below.

The cheat sheet

GPIO What to know Verdict
0 strapping: LOW at start-up = flashing mode; the BOOT button careful
1, 3 UART0 TX/RX — Serial and flashing go through them leave alone
2 strapping, the on-board LED; must be LOW/free while flashing careful
4 ADC2, touch T0 ✔
5 strapping (HIGH at start-up), SPI SS ✔ with a caveat
6–11 the module's flash — using them kills the board ✘ never
12 strapping: HIGH at start-up switches the flash to 1.8 V — the board does not boot careful
13, 14 ADC2, touch ✔
15 strapping (HIGH at start-up), prints the boot log ✔ with a caveat
16, 17 default UART2 (PSRAM on a WROVER!) ✔ on a WROOM
18, 19, 23 SPI SCK, MISO, MOSI ✔
21, 22 I2C SDA, SCL ✔
25, 26 DAC1, DAC2, ADC2 ✔
27 ADC2, touch ✔
32, 33 ADC1, touch, RTC crystal ✔
34, 35, 36, 39 input only, no pull-ups, ADC1 inputs only

Strapping pins

At power-up the ESP32 reads GPIO0, 2, 5, 12 and 15 to decide how to boot. Hence the usual mysteries:

  • The board will not flash while a module is connected. The module pulls GPIO2 or GPIO12 the wrong way. GPIO12 is the dangerous one: HIGH at start-up selects a 1.8 V flash supply, and the board reboots in a loop with flash read err.
  • A relay clicks at power-up. GPIO0, 2, 5 and 15 carry pulses or PWM during boot — do not connect actuators that must not fire on their own.

GPIO34–39: input only

These pins cannot be outputs, and they have no internal pull-ups — INPUT_PULLUP silently does nothing. A button on them needs an external 10 kΩ resistor. On the other hand they are the best analog inputs: ADC1 works with Wi-Fi on.

ADC2 and Wi-Fi

The ADC has two units. ADC2 (GPIO0, 2, 4, 12–15, 25–27) is used by the radio, so with Wi-Fi on, analogRead() on those pins returns an error or 0. In a Wi-Fi project, sensors go on ADC1 only: GPIO32–39.

Current

The recommended current per pin is up to 20 mA, the absolute maximum 40 mA. An LED without a resistor or a relay without a transistor damages a GPIO. All pins together should stay under about 100 mA; heavy loads need a transistor or a MOSFET.

Deep sleep

The ESP32 can wake from a pin (ext0/ext1) only on the RTC GPIOs: 0, 2, 4, 12–15, 25–27, 32–39. A wake-up button on GPIO16 or 22 will not work.

Try it in the simulator

The simulator checks these rules: pinMode(6, OUTPUT) "kills" the board with an explanation, pinMode(34, OUTPUT) is an error, and analogRead() on ADC2 with Wi-Fi returns 0 with a warning. Open any example, move a wire to a "forbidden" pin and look at the Problems tab.