ESP32 GPIO pins support digital input/output, analog sensing, PWM control, and communication with external devices. Explore the ESP32 GPIO pin diagram, individual pin functions, pin limitations, and practical Arduino IDE examples. Learn how to select the right GPIO pins for embedded systems and IoT applications.The ESP32 is a powerful microcontroller widely used in embedded systems, Internet of Things (IoT) applications, home automation, robotics, and wireless sensor networks. One of its most useful features is its General Purpose Input/Output (GPIO) pins, which allow the microcontroller to communicate with external devices such as LEDs, push buttons, sensors, displays, motors, and communication modules. Understanding ESP32 GPIO pins is essential for students who want to build practical electronics projects. Each GPIO pin can have different capabilities, including digital input, digital output, analog input, PWM output, or communication functions.
However, not every ESP32 pin works in the same way. Some pins are input-only, some are connected to internal flash memory, and others are used during booting. Choosing the wrong pin can cause unexpected behaviour or prevent the board from starting.
In this guide, we will explore the ESP32 GPIO pin diagram, individual pin functions, pin limitations, and practical applications.
GPIO stands for General Purpose Input/Output. These pins allow the ESP32 to receive signals from external components or send signals to control them.
For example:
The ESP32 supports flexible pin multiplexing, which means many GPIO pins can perform more than one function depending on how the pin is configured.
An ESP32 pinout diagram shows the location and functions of the pins available on a particular development board. It helps developers identify GPIO numbers, power pins, ground pins, and communication interfaces before connecting hardware.

GPIO 0 is a multifunction pin that can operate as a general-purpose input/output. It is also a strapping pin, meaning its level during reset helps determine the boot configuration.
Functions:
Example: GPIO 0 can be used as a button input in a suitable design, but the connected circuit must not interfere with the boot process.
GPIO 1 is commonly used as the transmit pin for UART0, which provides serial communication between the ESP32 and a computer.
Functions:
Example: When you upload a program and view messages in the Arduino IDE Serial Monitor, GPIO 1 may carry the ESP32’s transmitted serial data.
GPIO 2 supports digital input/output and can serve as a strapping pin on the original ESP32.
Functions:
Example: You can connect an LED to GPIO 2 through a suitable current-limiting resistor and control it using a program.
#define LED_PIN 2
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}This program turns the LED on for one second and off for one second. Some development boards have an onboard LED connected to GPIO 2, but this is not universal.
GPIO 3 is commonly used as the receive pin for UART0.
Functions:
Example: A USB-to-serial interface can send program data to the ESP32 through this pin during uploading or serial communication.
GPIO 4 is a general-purpose digital pin that can also support peripheral functions.
Functions:
Example: GPIO 4 can control a relay-driver input or read a digital sensor output, provided the circuit is electrically compatible.
Always use a suitable driver circuit for loads that require more current than a GPIO can safely supply.
GPIO 5 supports general-purpose input/output and is a strapping pin on the original ESP32.
Functions:
Example: GPIO 5 can be used to control an indicator LED or a compatible external control input.
GPIO 6, 7, 8, 9, 10, and 11 are generally connected to the SPI flash interface on common ESP32-WROOM-32 modules.
Functions:
Can you use them as normal GPIO pins? For common ESP32-WROOM-32 development boards, these pins should generally be avoided because they are needed for the module’s flash memory.
GPIO 12 supports digital input/output and other peripheral functions. On the original ESP32, it is also a strapping pin that can affect the flash supply-voltage configuration.
Functions:
Example: It may be used as a digital control signal when the hardware design is compatible.
GPIO 13 is a general-purpose digital pin that supports several peripheral functions.
Functions:
Example: GPIO 13 can be configured as an output to control an LED or as an input to read a compatible digital sensor.
Its final function depends on the firmware configuration and the other peripherals being used.
GPIO 14 supports digital input/output and can be assigned to peripheral signals.
Functions:
Example: GPIO 14 can control a digital output device in an IoT prototype.
Check whether the selected pin is already assigned to debugging or another peripheral before using it.
GPIO 15 is a multifunction pin and a strapping pin on the original ESP32.
Functions:
Example: It can be used as an indicator output or a digital input in a compatible circuit.
Since GPIO 15 participates in boot configuration, check the board’s startup requirements before attaching external hardware.
GPIO 16 is commonly available as a general-purpose digital pin on ESP32-WROOM-32 development boards.
Functions:
Example: GPIO 16 can read a digital sensor or control an LED.
Availability can differ on modules that use certain GPIOs for additional memory or other onboard hardware.
GPIO 17 supports general-purpose input/output and can be used for digital control tasks.
Functions:
Example: It can operate a digital indicator or provide a logic-level control signal to an external driver.
On the original ESP32-WROOM-32, GPIO 16 and GPIO 17 are generally available, but always check the specific module.
GPIO 18 is commonly used as a general-purpose pin and can serve as the default SCLK signal in many VSPI configurations.
Functions:
Example: GPIO 18 can provide the clock signal for an SPI-compatible display or sensor when the SPI peripheral is configured accordingly.
If the project uses SPI, do not assign the same pin to an unrelated output without planning the pin mapping.
GPIO 19 is a flexible digital pin commonly used as the default MISO signal in many VSPI configurations.
Functions:
Example: When communicating with an SPI sensor, GPIO 19 can receive data from the peripheral through the MISO line.
It can be reassigned in suitable configurations if the application does not need the default SPI mapping.
GPIO 20 is not available as a normal GPIO on the original ESP32 chip used in common ESP32-WROOM-32 boards.
GPIO 21 is commonly used as the default I2C SDA (Serial Data) pin on many original ESP32 development boards.
Functions:
Example: GPIO 21 can carry data between the ESP32 and an I2C temperature sensor, OLED display, or other I2C device.
The I2C pin mapping is configurable in many software frameworks, so GPIO 21 is a common default rather than a universal requirement.
GPIO 22 is commonly used as the default I2C SCL (Serial Clock) pin.
Functions:
Example: When the ESP32 communicates with an I2C display, GPIO 22 provides the clock signal in a typical default configuration.
GPIO 21 and GPIO 22 are frequently paired for I2C projects, although the software and hardware must be configured consistently.
GPIO 23 is commonly used as the MOSI signal in many VSPI configurations.
Functions:
Example: GPIO 23 can transmit data from the ESP32 to an SPI display or memory peripheral.
It is also suitable for other digital functions when SPI is not using the pin.
GPIO 24 is not a normal user GPIO on the original ESP32. GPIO 25, however, is a commonly available multifunction pin.
ESP32 GPIO 25 functions:
Example: GPIO 25 can be used to generate a DAC voltage on the original ESP32, making it useful for certain analog-output experiments.
GPIO 26 supports digital input/output and has an analog-output capability on the original ESP32.
Functions:
Example: GPIO 26 can generate a variable DAC output for a basic analog-signal experiment or function as a digital control pin.
The DAC output has limitations in resolution, voltage range, and drive capability. It is not a replacement for a high-precision external DAC.
GPIO 27 is a general-purpose pin with analog-input and peripheral capabilities.
Functions:
Example: GPIO 27 can read a compatible digital sensor or be configured for an analog measurement where ADC2 restrictions are acceptable.
On the original ESP32, ADC2 has restrictions when Wi-Fi is active. For analog measurements that must work reliably alongside Wi-Fi, an appropriate ADC1 pin is often a better choice.
GPIO 28, 29, 30, and 31 are not available as ordinary GPIO pins on the original ESP32-WROOM-32 platform.
Pin numbers and exposed GPIOs vary across different ESP32 chips, so use the exact chip datasheet rather than assuming every number in a sequence is available.
GPIO 32 is a general-purpose pin with analog-input support on the original ESP32.
Functions:
Example: GPIO 32 can read an analog sensor voltage or provide a digital output for an indicator.
ADC1 is especially useful when Wi-Fi is active because it does not have the same Wi-Fi-related ADC2 restriction on the original ESP32.
GPIO 33 supports digital input/output and analog input on the original ESP32.
Functions:
Example: GPIO 33 can be used to read a compatible analog sensor or generate a PWM signal to control LED brightness.
As with every ADC input, ensure the incoming voltage remains within the permitted input range.
GPIO 34 is an input-only GPIO on the original ESP32.
Functions:
Limitations:
Example: GPIO 34 is suitable for reading a sensor’s analog output or detecting a digital signal. An external pull-up or pull-down may be necessary for a stable digital input.
GPIO 35 is another input-only pin on the original ESP32.
Functions:
Example: You can connect a compatible analog sensor output to GPIO 35 and read the voltage using the ADC.
GPIO 35 cannot drive an LED directly because it does not support normal digital output.
GPIO 36, often labelled VP on original ESP32 boards, is an input-only pin with ADC1 support.
Functions:
Example: GPIO 36 can measure a compatible analog sensor signal or read a digital input.
It does not support normal digital output and lacks the usual internal pull-up and pull-down configuration.
GPIO 37 is not generally exposed as a usable pin on common ESP32-WROOM-32 development boards. Its availability depends on the particular ESP32 chip and module.
GPIO 38 is also not normally exposed as a usable GPIO on common ESP32-WROOM-32 development boards. Check the exact chip documentation before using this number in a design.
GPIO 39, often labelled VN, is an input-only GPIO with ADC1 support on the original ESP32.
Functions:
Example: GPIO 39 can read a compatible sensor signal or measure an analog voltage within the allowed input range.
Like GPIO 34, 35, and 36, it cannot operate as a normal digital output and does not have the standard internal pull-up or pull-down functionality.
The following table summarizes commonly used GPIOs on the original ESP32-WROOM-32 platform. Peripheral functions can be reassigned, and exact availability depends on the module and board.
| GPIO pin | Common functions | Important note |
| GPIO 0 | Digital I/O | Boot strapping |
| GPIO 1 | UART0 TX | Common serial output |
| GPIO 2 | Digital I/O, PWM | Boot strapping |
| GPIO 3 | UART0 RX | Common serial input |
| GPIO 4 | Digital I/O, PWM | General-purpose pin |
| GPIO 5 | Digital I/O, PWM | Boot strapping |
| GPIO 6–11 | Flash interface | Avoid using on common WROOM-32 boards |
| GPIO 12 | Digital I/O, ADC2 | Boot/flash-voltage strapping |
| GPIO 13–15 | Digital I/O, PWM | GPIO 15 is a strapping pin |
| GPIO 16–19 | Digital I/O | Check module availability |
| GPIO 21–23 | Digital I/O, I2C/SPI defaults | Common communication pins |
| GPIO 25–27 | Digital I/O, ADC2 | GPIO 25 and 26 have DAC on original ESP32 |
| GPIO 32–33 | Digital I/O, ADC1 | Useful for analog inputs |
| GPIO 34–39 | Input-only | No normal digital output |
Students can configure GPIO pins using the Arduino IDE and the ESP32 board package.
#define LED_PIN 2
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}In this example, pinMode() configures GPIO 2 as an output. digitalWrite() changes its output level, while delay() introduces a pause between transitions.
#define BUTTON_PIN 18
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) {
Serial.println("Button pressed");
}
delay(100);
}This example configures GPIO 18 as an input with an internal pull-up. Connect a normally open push button between GPIO 18 and GND. When pressed, the pin reads LOW.
ESP32 GPIO pins are used in a wide range of embedded systems and IoT applications.
GPIO output signals can turn LEDs on and off or control brightness using PWM. This is useful for status indicators and smart lighting systems.
GPIO pins can read digital signals from compatible sensors. Analog-capable pins can measure sensor voltages when the input range and ADC characteristics are suitable.
The ESP32 can control relay-driver circuits, read switches, and monitor sensors in smart-home applications. The relay or load should be driven using suitable interface circuitry rather than directly from a GPIO.
GPIO pins can support I2C and SPI displays, including OLED modules and compatible TFT screens. Correct pin mapping and voltage compatibility are essential.
GPIO pins can provide logic-level control signals to motor-driver modules, read encoders, and interface with digital sensors. Motors must be powered through appropriate driver circuits.
The ESP32 can collect sensor readings and transmit data over Wi-Fi or Bluetooth. GPIO selection matters when combining analog measurements with wireless communication.
Before selecting pins for a project, students should understand these limitations.
Understanding ESP32 GPIO pins is a fundamental step in embedded systems development. GPIO pins allow the ESP32 to interface with LEDs, push buttons, sensors, displays, and communication peripherals, making them essential for IoT and automation projects.
By learning the ESP32 GPIO pin diagram, individual pin functions, input-only limitations, ADC capabilities, and boot-related restrictions, students can select suitable pins and build more reliable projects.
For beginners, starting with an LED output, a push-button input, and a simple sensor interface is a practical way to understand GPIO configuration. As skills improve, these concepts can be applied to wireless monitoring, smart-home systems, robotics, and other embedded applications.
The original ESP32 chip has up to 34 GPIOs numbered 0–19, 21–23, 25–27, and 32–39. However, some are reserved for flash, some are input-only, and not all are exposed on every development board.
On common ESP32-WROOM-32 boards, beginners should generally avoid GPIO 6–11 because they are connected to flash memory. They should also take care with boot-strapping pins such as GPIO 0, 2, 5, 12, and 15.
No. Original ESP32 GPIO pins are designed for 3.3 V logic and are not 5 V tolerant. Use a suitable voltage divider or logic-level shifter when interfacing with a 5 V signal.
An input pin reads an external digital signal, such as a push button or sensor output. An output pin drives a logic-level signal, such as switching an LED through a current-limiting resistor.
Indian Institute of Embedded Systems – IIES