Introduction
When working with the ESP32, understanding which GPIO pins are safe to use is extremely important. Unlike simpler microcontrollers, the ESP32 contains special-purpose pins, bootstrapping pins, and restricted pins that behave differently during startup.
Using the wrong pin can cause problems such as:
- The board failing to boot
- Upload errors
- Unstable hardware behavior
In this guide, you will learn which ESP32 pins are safe to use, which pins require caution, and which pins should be avoided. You will also learn how bootstrapping pins work and how they affect the startup process of the ESP32.
Understanding ESP32 GPIO Pins
The ESP32 has more than 30 GPIO pins, but not all of them are available for general use. Some pins are reserved internally for flash memory, while others are used during the boot process.
GPIO stands for General Purpose Input/Output, meaning these pins can function as either inputs (reading sensors or buttons) or outputs (controlling LEDs, motors, or relays).
However, certain GPIO pins have special restrictions that developers must understand before using them in their circuits.
ESP32 Valid GPIO Pins
The following GPIO pins are considered safe and commonly used for most ESP32 projects.
| GPIO | Notes |
|---|---|
| GPIO2 | Often used for onboard LED |
| GPIO4 | Safe general-purpose pin |
| GPIO5 | Commonly used for SPI |
| GPIO12 | Bootstrapping pin (use with caution) |
| GPIO13 | Safe general-purpose pin |
| GPIO14 | Safe general-purpose pin |
| GPIO15 | Bootstrapping pin |
| GPIO16 | Safe general-purpose pin |
| GPIO17 | Safe general-purpose pin |
| GPIO18 | SPI clock pin |
| GPIO19 | SPI MISO |
| GPIO21 | Default I2C SDA |
| GPIO22 | Default I2C SCL |
| GPIO23 | SPI MOSI |
| GPIO25 | DAC capable |
| GPIO26 | DAC capable |
| GPIO27 | Safe general-purpose pin |
| GPIO32 | Analog capable |
| GPIO33 | Analog capable |
These pins are typically safe for connecting:
- LEDs
- Sensors
- Relays
- Displays
- Communication modules
Input Only Pins
Some ESP32 pins can only be used as input pins and cannot drive output signals.
| GPIO | Description |
|---|---|
| GPIO34 | Input only |
| GPIO35 | Input only |
| GPIO36 | Input only |
| GPIO39 | Input only |
These pins are commonly used for:
- Analog sensors
- Buttons
- Interrupt signals
Because they lack internal pull-up or pull-down resistors, external resistors may be required in some circuits.
Pins to Avoid
Certain ESP32 pins should generally not be used in normal applications.
| GPIO | Reason |
|---|---|
| GPIO6 – GPIO11 | Connected internally to SPI flash memory |
These pins are reserved for the ESP32’s internal flash storage and interfering with them can cause the board to crash or fail to boot.
Bootstrapping Pins
Bootstrapping pins determine how the ESP32 starts up when power is applied or when the reset button is pressed.
These pins must be in the correct logic state during startup. If external hardware changes their voltage level, the ESP32 may enter an incorrect boot mode.
Common Bootstrapping Pins
| GPIO | Function |
|---|---|
| GPIO0 | Determines boot mode |
| GPIO2 | Must be HIGH during boot |
| GPIO4 | Bootstrapping pin |
| GPIO5 | Bootstrapping pin |
| GPIO12 | Flash voltage selection |
| GPIO15 | Boot configuration |
Because of their role during startup, these pins should be used carefully in circuits.
GPIO0 and Flash Mode
GPIO0 is particularly important because it determines whether the ESP32 boots normally or enters firmware flashing mode.
| GPIO0 State | Boot Mode |
|---|---|
| HIGH | Normal program execution |
| LOW | Firmware upload mode |
This is why many ESP32 boards include a BOOT button that temporarily pulls GPIO0 LOW during firmware uploads.
Best Practices When Choosing ESP32 Pins
To avoid hardware issues in your projects, follow these guidelines:
- Prefer using GPIO4, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, and GPIO33.
- Use bootstrapping pins only when necessary.
- Avoid GPIO6–GPIO11 entirely.
- Remember that GPIO34–GPIO39 are input-only pins.
- Always check the ESP32 pinout diagram before wiring your circuit.
Following these practices will ensure your ESP32 projects run reliably without unexpected boot issues.
Example: Safe LED Connection
For example, connecting an LED to GPIO4 is considered safe and does not interfere with the boot process.
Basic wiring:
GPIO4 → Resistor → LED → GND
This configuration allows the ESP32 to control the LED without affecting startup behavior.
Conclusion
Understanding ESP32 GPIO pins is essential for building stable and reliable projects. While the ESP32 offers many GPIO options, some pins have special functions related to flash memory and boot configuration.
By learning which pins are safe to use and how bootstrapping pins behave, you can avoid common beginner mistakes such as boot failures or unexpected hardware behavior.
In the next step of your ESP32 learning journey, you can explore more advanced topics such as interrupts, PWM control, I2C communication, and SPI devices to build more complex embedded systems.