ESP32 Pinout Reference Guide

The ESP32 serves as a versatile microcontroller has become a cornerstone for numerous IoT projects, home automation solutions, and robotics applications. Its adaptability and user-friendly features make it an indispensable tool for modern innovators. With embedded components like Bluetooth and Wi-Fi, the ESP32 excels in various applications, making it a top choice for diverse uses. Let’s delve into the ESP32 pinout.

ESP32 board

Table of Contents


The ESP32 development board boasts 25 GPIO pins that can be assigned various functions through programming. These pins come in different types, including digital-only, analog-enabled, and capacitive-touch-enabled. Analog-enabled and capacitive-touch-enabled GPIOs can also serve as digital GPIOs. Most digital GPIOs offer the flexibility of configuring internal pull-up or pull-down resistors, or setting them to high impedance.

ESP32 pin layout

However, it’s crucial to note that GPIO34, GPIO35, GPIO36 (VP), and GPIO39 (VN) cannot be configured as outputs. While they can be utilized as digital or analog inputs or for other purposes, they lack internal pull-up and pull-down resistors. Be mindful that GPIO34 to GPIO39 are strictly input-only pins without internal pull-up or pull-down resistors, restricting their use to inputs only.

  • Green-highlighted pins are safe for use.
  • Yellow-highlighted pins can be used but require caution due to potential unexpected behavior, especially during startup.
  • Red-highlighted pins are not recommended for use as inputs or outputs.

esp32 pin diagram


PWM (Pulse Width Modulation) pins play a crucial role in generating signals essential for managing devices like servos, motors, and dimmable LEDs. These pins prove invaluable when precision control over the intensity or position of a device is required, typically devices that respond to PWM signals. For instance, PWM allows you to regulate the speed of a DC motor or adjust the brightness of an LED.

ESP32 PWM Pinout

The ESP32 LED PWM controller boasts 16 independent channels that can be tailored to generate PWM signals with diverse characteristics. All pins capable of functioning as outputs can serve as PWM pins (excluding GPIOs 34 to 39). To establish a PWM signal, you must define specific parameters in your code:

  • Signal’s Frequency: Determine the desired frequency.
  • Duty Cycle: Specify the duty cycle.
  • PWM Channel: Choose from the available 16 channels (numbered 0 to 15).
  • GPIO Output: Designate the GPIO where the signal will be output.

Here are the steps to dim an LED with PWM using the Arduino IDE:

  • Choose a PWM channel from the available 16 (0 to 15).
  • Set the PWM signal frequency; for LEDs, a frequency of 5000 Hz is often suitable.
  • Define the signal’s duty cycle resolution. We’ll opt for 8-bit resolution, allowing brightness control with values ranging from 0 to 255.
  • Specify the GPIO or GPIOs where the signal will appear using the ledcAttachPin(GPIO, channel) function.
  • This function takes two arguments: the GPIO responsible for outputting the signal and the channel generating the signal. 

I2C (SCL and SDA)

I2C (Inter-Integrated Circuit) pins facilitate bidirectional communication with I2C-compatible devices like sensors, displays, and real-time clocks. These pins come into play when you want to seamlessly connect or exchange data with multiple I2C devices in a pin configuration. This simplifies interfacing with various sensors and peripherals. I2C operates as a serial, synchronous, multi-device, half-duplex communication protocol, allowing multiple masters and slaves to coexist on the same bus. It employs two bidirectional open lines: a serial data line (SDA) and a serial clock line (SCL), equipped with pulled resistors.

The ESP32 incorporates 2 I2C controllers (also referred to as ports) responsible for communication on the I2C bus. Each I2C controller can function as either a master or a slave.

ESP32 I2C Pins

Typically, an I2C slave device has a 7-bit or 10-bit address. ESP32 supports both I2C standard mode (Sm) and fast mode (Fm), reaching speeds of up to 100kHz and 400kHz. The I2C0 bus is the default for Arduino libraries, connected to GPIO22 (SCL) and GPIO21 (SDA) pins on the ESP32. However, you can use any ESP32 pin with the Wire.h library by specifying the pins using the Wire.begin(SDA_PIN, SCL_PIN) function. This flexibility ensures efficient I2C communication across a variety of configurations.


SPI (Serial Peripheral Interface) pins facilitate high-speed serial communication with devices like displays, memory modules, and other microcontrollers. These pins are crucial for applications demanding rapid data transfer between the ESP32 and external devices, particularly in scenarios where real-time data exchange is paramount.

The ESP32 incorporates three SPIs (SPI, HSPI, and VSPI) capable of operating in both slave and master modes. These SPIs support various essential functions:

  • Four timing modes for SPI format transfer.
  • Speeds of up to 80 MHz and clock division options.
  • A FIFO of up to 64 bytes.

Among these SPI interfaces, only VSPI and HSPI are usable, while the third SPI bus is dedicated to the integrated flash memory chip. Standard libraries often utilize VSPI pins.

Similar to I2C, you have the flexibility to bit-bang the SPI protocol on any GPIO pins using the bus.begin(CLK_PIN, MISO_PIN, MOSI_PIN, SS_PIN) command.

UART (TX and RX)

UART pins facilitate asynchronous serial communication, making them essential for interfacing with devices like GPS modules, Bluetooth modules, and other microcontrollers. When you need to communicate with devices using serial communication, it enables the seamless transmission and reception of data in a human-readable and understandable format.

The UART protocol serves as the foundation for easy data exchange between two devices. On the ESP32, three UART buses are available: UART0, UART1, and UART2. These can be employed to communicate with sensors, Arduinos, Raspberry Pis, and computers.

  • UART0: By default, it operates on pins GPIO1 (TX0) and GPIO3 (RX0) of the ESP32. This UART is commonly used for communication with a computer through the serial monitor and for flashing new programs onto the ESP32 board. It conveniently displays messages in the console using Serial.println().
  • UART2: To utilize UART2, simply include Serial2.begin() in the setup() function, and employ Serial2.println() for sending messages. By default, UART2 operates on pins GPIO16 (RX2) and GPIO17 (TX2). However, you have the flexibility to change these pins during setup, which can be particularly useful with a Wrover module.

ESP32 UART pin out

GPIO Interrupt

The ESP32 provides up to 32 interrupt slots for each core, each assigned a specific priority level and categorized into two types:

  • Hardware interrupts: These respond to external events, such as a GPIO interrupt (e.g., a key press) or a touch interrupt (e.g., touch detection).
  • Software Interrupts: These respond to software instructions, for instance, a timer interrupt or a watchdog timer interrupt triggered by a timer timeout.

In the ESP32, we can define an interrupt service routine (ISR) function that executes when a GPIO pin changes its logic level. All GPIO pins on an ESP32 board can be configured to function as interrupt request inputs.

Within the Arduino IDE, we utilize the attachInterrupt() function to set up interrupts on a pin-by-pin basis. The syntax is as follows:

					attachInterrupt(GPIOPin, ISR, Mode);

This function takes three arguments:

  • GPIOPin: Specifies the GPIO pin as the interrupt pin, informing the ESP32 which pin to monitor.
  • ISR: Represents the name of the function called each time the interrupt occurs.
  • Mode: Defines when the interrupt should trigger. 

Five constants are predefined as valid values:

  • FALLING: Triggered when the pin transitions from HIGH to LOW.
  • RISING: Triggered when the pin transitions from LOW to HIGH.
  • CHANGE: Triggered when the pin undergoes any change in logic level.
  • LOW: Triggered when the pin is low.
  • HIGH: Triggered when the pin is high.


The ESP32 comes equipped with five essential strapping pins: GPIO0, GPIO2, GPIO5, GPIO12, and GPIO15. These pins serve a crucial role in determining whether the ESP32 boots in the regular mode (to execute the program stored in flash memory) or enters FLASH mode (for uploading new programs to flash memory). The ESP32’s initial mode, whether BOOT or FLASH, is dictated by the state of these pins during the power-on sequence. Fortunately, on most development boards featuring built-in USB/Serial, the pins are automatically configured, eliminating the need for user intervention to set them in the correct state for flashing or boot mode.

It’s important to note that when peripherals are connected to these strapping pins, complications may arise during attempts to upload new code or flash the ESP32 with updated firmware. The presence of peripherals can interfere with the ESP32 entering the intended mode. While the strapping pins return to their normal functionality after a reset release, exercising caution in their usage is advised.


The ESP32 features two primary power pins: VIN and 3V3.

  • VIN Pin: Ideal for directly powering the ESP32 and connected peripherals, this pin is particularly useful when a regulated 5V power supply is available.
  • 3V3 Pin: Output from the on-board voltage regulator, offering a stable power source with a maximum output capacity of 600mA.

Both of these pins play a crucial role in providing power to the ESP32 and ensuring the proper functioning of connected devices. Additionally, the ground pin, labeled as GND, completes the power circuit, offering a reference point for effective electrical grounding.

More content you may be interested in

esp32 pinout
ESP32 Pinout Reference Guide

The ESP32 is a versatile microcontroller with extensive functionalities. Its pinout includes GPIO pins for digital, analog, and capacitive touch, PWM pins for precise control,

esp32 pwm project
ESP32 PWM Tutorial

This article delves into PWM on the ESP32, crucial for precise control in applications like LED dimming, motor regulation, and audio generation. It explains the

Scroll to Top