In short: On an ESP32 DevKit, GPIO34-39 are input-only with no pull resistors, GPIO6-11 belong to the flash and must never be touched, GPIO0/2/5/12/15 are strapping pins that are read at reset, and ADC2 stops working while Wi-Fi is active, so use ADC1 pins (32-39) for analog reads.
Most ESP32 boards fail in the same boring ways: a sensor wired to GPIO12 that makes the board refuse to boot, a button on GPIO34 that floats because nobody told you it has no pull-up, an ADC reading that works on the bench and dies when Wi-Fi turns on. All of these come from the pin map. This guide walks the classic ESP32 (ESP32-WROOM-32 / 30-pin and 38-pin DevKit) pin by pin and explains why each restriction exists. The newer S2, S3 and C3 parts use different numbers, so always check your exact chip's datasheet.
The big picture: 34 GPIOs, but not all equal
The ESP32 chip exposes GPIO0-19, 21-23, 25-27 and 32-39. That is up to 34 pads, yet a typical DevKit gives you roughly 25 safe ones. The IO MUX lets most peripherals (UART, SPI, I2C, I2S, PWM) be routed to nearly any pin through the GPIO matrix, so the real constraints are physical: which pins are wired to flash, which are sampled at reset, and which connect to the analog blocks.
Input-only pins: GPIO34, 35, 36 and 39
GPIO34-39 are input-only, which means there is no output driver in the pad. GPIO36 and GPIO39 are labelled VP and VN on most boards (sensor positive and negative), and GPIO37/38 exist on the chip but are rarely broken out on DevKits. Two consequences catch beginners every time: you cannot drive an LED from them, and they have no internal pull-up or pull-down. A push-button on GPIO34 needs an external 10 kOhm resistor, otherwise the pin floats and the reading is noise.
Key fact: pinMode(34, INPUT_PULLUP) compiles without error but does nothing. The hardware simply has no pull resistor on GPIO34-39.
These pins are the natural home for analog sensors, because they are ADC1 channels and stay usable while Wi-Fi runs.
Flash pins: GPIO6 to GPIO11
On a WROOM module, six pins connect the chip to the integrated SPI flash that holds your firmware. Reading code from flash happens continuously through the cache, so toggling these pins as GPIO crashes the CPU with a cache or watchdog fault. Many 38-pin DevKits do print them as SD0, SD1, SD2, SD3, CMD and CLK. Treat them as if they were not there. (Modules with PSRAM, such as WROVER, additionally consume GPIO16 and GPIO17.)
Strapping pins and what to avoid at boot
When EN (reset) rises, the chip latches the level of five pins into the GPIO_STRAP register and uses it to choose its boot behaviour. After that moment they are ordinary GPIOs, but an external circuit that holds them the wrong way at power-up changes how the chip starts.
| Pin | Default | What it controls | Danger |
|---|---|---|---|
| GPIO0 | Pull-up (high) | Low at reset = serial download mode; high = run from flash | A circuit pulling it low on power-up never runs your program |
| GPIO2 | Pull-down | Must be low or floating to enter download mode | Drives the on-board LED on many boards; keep it unloaded |
| GPIO12 (MTDI) | Pull-down | Selects flash voltage: low = 3.3 V, high = 1.8 V | High at boot on a 3.3 V flash module causes a boot loop |
| GPIO5 | Pull-up | SDIO slave timing | Mostly harmless for normal designs |
| GPIO15 (MTDO) | Pull-up | Low silences the ROM boot log on UART0 | Pulled low means missing boot messages |
Key fact: GPIO12 is the nastiest. It sets VDD_SDIO, the supply for the flash. If a sensor or pull-up holds it high while the module has 3.3 V flash, the flash is under-powered and the board fails to boot with a flash read error. You can burn the VDD_SDIO eFuse to make this permanent, but wiring around it is easier.
Practical rules: do not hang relays, motor drivers or pull-ups on these five pins, and if you must, make sure the external level at reset matches the default. Auto-reset circuits on DevKits use DTR and RTS through two transistors to pulse EN and GPIO0 for you, which is why uploads work without pressing BOOT.
ADC, touch and DAC channels
The ESP32 has two 12-bit SAR ADCs. ADC1 has eight channels on GPIO36, 37, 38, 39, 32, 33, 34 and 35. ADC2 has ten channels on GPIO4, 0, 2, 15, 13, 12, 14, 27, 25 and 26, but the Wi-Fi driver owns ADC2, so analogRead() on those pins returns errors whenever Wi-Fi is started. The rule is simple: for any connected project, use ADC1.
Two more caveats from real measurements. The default 0 dB attenuation measures only up to about 1.1 V; 11 dB extends the range to roughly 3.1 V. The transfer curve is also nonlinear near the rails, so production designs use the factory eFuse calibration (the esp_adc_cal / calibration API in ESP-IDF) rather than a straight value*3.3/4095 formula.
The two 8-bit DACs live on GPIO25 (DAC1) and GPIO26 (DAC2), giving a step of about 3.3/256 = 12.9 mV. Ten capacitive touch channels sit on GPIO4, 0, 2, 15, 13, 12, 14, 27, 33 and 32 (T0-T9). Notice that touch reuses three strapping pins, so a finger resting on a touch pad at reset can alter boot behaviour.
A safe pin plan you can reuse
- Analog sensors: GPIO32-39 (ADC1). Add an external pull for 34-39 if used digitally.
- I2C: GPIO21 (SDA) and GPIO22 (SCL), the default Arduino mapping.
- SPI sensors/displays: VSPI on GPIO23 (MOSI), 19 (MISO), 18 (SCK), 5 (CS) - pick another CS if you worry about GPIO5.
- Relays and LEDs: GPIO16, 17, 25, 26, 27 are free of boot side effects.
- Deep-sleep wake: only RTC-capable pins (0, 2, 4, 12-15, 25-27, 32-39) can wake the chip via ext0/ext1.
This is the same discipline we teach for any microcontroller: read the reset-time behaviour before assigning peripherals. For a deeper look at the electrical behaviour of each pad, see our companion piece ESP32 GPIO pins explained, and for what happens when firmware talks to those peripherals read the ESP32 ADC calibration guide. If you are moving from boards to custom silicon, Avecas design services handle full SoC and PCB bring-up, while ChipXpert VLSI training covers the chip-level view of why pads and straps exist.
Ready to design real hardware instead of guessing at pinouts? Explore the embedded and VLSI tracks in the CourseTron course catalogue and build projects with hands-on labs.
Frequently asked questions
Which ESP32 pins are safe to use at boot?
GPIO4, 13, 14, 16-19, 21-23, 25-27, 32 and 33 have no boot-time function, so they are the safest outputs. Avoid GPIO0, 2, 5, 12 and 15 unless the default levels are respected, and never use GPIO6-11.
Why does my ESP32 not boot when a sensor is connected?
Most often the sensor or a pull-up is driving GPIO12 high or GPIO0 low during reset. Move the signal to a non-strapping pin or add a series resistor or buffer that only conducts after boot.
Can I use ADC2 pins with Wi-Fi?
No. The Wi-Fi driver takes ADC2, so reads fail while Wi-Fi is active. Use ADC1 pins (GPIO32-39) instead.
Do GPIO34-39 have internal pull-ups?
No. They are input-only and lack both pull-up and pull-down resistors, so add an external one for buttons and switches.