The ESP32 is the favourite chip for Wi-Fi and Bluetooth projects, but its pins come with more catches than most boards. Some are wired to the flash memory, some decide how the chip boots, some are input only, and one whole bank of analogue inputs stops working when Wi-Fi is on. This page covers Espressif's own ESP32-DevKitC V4 board with the original ESP32 chip, and the rules apply to most ESP32 boards built on the same chip.
The pins
The board has two 19-pin headers, J2 and J3. Pin 1 of each is at the antenna end, away from the USB socket. Each row of the table shows the two pins opposite each other across the board.
Power Ground GPIO / signal Control
| J2 notes | Function | Pin | Pin | Function | J3 notes |
|---|---|---|---|---|---|
| 3.3 V in or out | 3V3 | 1 | 1 | GND | |
| Reset when pulled low | EN | 2 | 2 | GPIO23 | SPI MOSI (Arduino default) |
| VP. Input only. ADC1_0 | GPIO36 | 3 | 3 | GPIO22 | I²C SCL (Arduino default) |
| VN. Input only. ADC1_3 | GPIO39 | 4 | 4 | GPIO1 | TX0: USB serial |
| Input only. ADC1_6 | GPIO34 | 5 | 5 | GPIO3 | RX0: USB serial |
| Input only. ADC1_7 | GPIO35 | 6 | 6 | GPIO21 | I²C SDA (Arduino default) |
| ADC1_4, touch 9 | GPIO32 | 7 | 7 | GND | |
| ADC1_5, touch 8 | GPIO33 | 8 | 8 | GPIO19 | SPI MISO (Arduino default) |
| DAC 1, ADC2_8 | GPIO25 | 9 | 9 | GPIO18 | SPI SCK (Arduino default) |
| DAC 2, ADC2_9 | GPIO26 | 10 | 10 | GPIO5 | Strapping. SPI SS (Arduino default) |
| ADC2_7, touch 7 | GPIO27 | 11 | 11 | GPIO17 | WROOM and SOLO modules only |
| ADC2_6, touch 6 | GPIO14 | 12 | 12 | GPIO16 | WROOM and SOLO modules only |
| Strapping (MTDI): keep low at boot. ADC2_5 | GPIO12 | 13 | 13 | GPIO4 | ADC2_0, touch 0 |
| GND | 14 | 14 | GPIO0 | Strapping: BOOT button. ADC2_1 | |
| ADC2_4, touch 4 | GPIO13 | 15 | 15 | GPIO2 | Strapping: low or floating for flashing. ADC2_2 |
| Don't use: SPI flash | FLASH GPIO9 | 16 | 16 | GPIO15 | Strapping (MTDO). ADC2_3 |
| Don't use: SPI flash | FLASH GPIO10 | 17 | 17 | FLASH GPIO8 | Don't use: SPI flash |
| Don't use: SPI flash | FLASH GPIO11 | 18 | 18 | FLASH GPIO7 | Don't use: SPI flash |
| 5 V in (or USB 5 V) | 5V | 19 | 19 | FLASH GPIO6 | Don't use: SPI flash |
The flash pins are shaded like ground pins because you should treat them as unusable. The "Arduino default" notes are the defaults in Espressif's Arduino core. Almost any output-capable GPIO can be used for I²C, SPI, UART or PWM through the chip's pin matrix.
Pins to avoid or use with care
- GPIO6 to GPIO11 connect to the module's SPI flash memory. Using them will crash the board. Espressif says to avoid them.
- Strapping pins: GPIO0, GPIO2, GPIO5, GPIO12 and GPIO15. The chip reads these at reset to decide how to start. GPIO0 low selects download mode, which is what the BOOT button does. GPIO2 must be low or floating to flash new code. GPIO12 must be low at power-up on modules with 3.3 V flash, such as the ESP32-WROOM-32, or the chip sets its flash voltage to 1.8 V and won't boot. GPIO15 low at boot silences the boot messages. They're fine to use after boot, as long as whatever you connect doesn't hold them at the wrong level during reset.
- GPIO34 to GPIO39 are input only and have no internal pull-up or pull-down resistors. Use them for sensors and buttons with an external resistor.
- ADC2 doesn't work while Wi-Fi is on. Espressif's documentation says ADC2 pins can't be used when Wi-Fi is in use. For analogue readings in a Wi-Fi project, use the ADC1 pins: GPIO32 to GPIO39.
- GPIO1 and GPIO3 are the serial port to the USB chip, used for uploading code and the serial monitor.
- GPIO16 and GPIO17 are only available on boards with WROOM or SOLO modules. On WROVER modules they connect to the extra PSRAM.
That leaves a comfortable set of general-purpose pins: GPIO4, 13, 14, 16 to 19, 21 to 23, 25 to 27, 32 and 33, plus the input-only pins.
Powering the board
Espressif lists three ways to power the DevKitC: the USB socket, the 5V and GND pins, or the 3V3 and GND pins. Use only one at a time. Connecting more than one can damage the board or your power source. The module's datasheet asks for a supply that can deliver at least 500 mA, because Wi-Fi transmissions draw short bursts of current, though the average is far lower. Weak USB cables and hubs are a common cause of random resets.
Current limits
The ESP32-WROOM-32 datasheet gives typical figures at maximum drive strength of about 40 mA sourced and 28 mA sunk per pin. Those are typical maximums, not a comfortable working current. Run LEDs at a few milliamps and switch anything bigger with a transistor. Our transistor switch simulator shows how.
Analogue: ADC and DAC
The ESP32 has two 12-bit ADCs. Its readings are less linear than many microcontrollers', especially near 0 V and the top of the range, so calibrate if accuracy matters. Our ADC guide explains why. GPIO25 and GPIO26 are 8-bit DAC outputs, handy for simple audio and test signals.
Other ESP32 chips
Newer chips such as the ESP32-S3, C3 and C6 have different pin numbers and rules. The ESP32-S3, for example, has native USB and more GPIOs. Always check the pinout for your exact board and chip.
Sources
The main references behind this guide. Numbers we worked out ourselves, such as the code outputs, come from running the code.