Scarlett Ideas Back to catalog
ESP32 Pinout Guide: GPIO, Buttons & Ports Explained
Aug 28, 2026 Scarlett

Esp32 GPIO Pin Control Tutorial

The ESP32, a low-cost, low-power system on a chip (SoC) microcontroller, has gained massive popularity in the IoT (Internet of Things) and maker communities due...

The ESP32, a low-cost, low-power system on a chip (SoC) microcontroller, has gained massive popularity in the IoT (Internet of Things) and maker communities due to its versatility and advanced features. One of its standout features is its General Purpose Input/Output (GPIO) pins, which allow the ESP32 to interface with external circuits and devices. Let's delve into the world of GPIO on the ESP32 and explore its capabilities.

ESP32 Pinout Guide: GPIO, Buttons & Ports Explained

The ESP32 contains 34 GPIO pins, with each capable of functioning both as an input or output, making it versatile for various applications. These pins can be used to read from or write to other devices, handle interrupts, or control LEDs and other peripherals. In this article, we'll discuss the basics of ESP32 GPIO, its configuration, and some common use cases.

ESP32 Pinout Reference

ESP32 GPIO Pins: Overview and Configuration

Understanding the ESP32's GPIO layout is crucial for effective code writing and circuit design. The ESP32 GPIO pins are grouped according to their functions. Some are dedicated to specific tasks, while others can be reconfigured based on your project's need.

ESP32 PinOut – which pin is for what

The GPIO pins can be configured using the ESP-IDF (Espressif IoT Development Framework) or the Arduino framework. Configuration involves setting the pin mode (INPUT or OUTPUT), enabling pull-up or pull-down resistors, and setting pin direction.

Pin Mode and Direction

10 ESP32 Skills Every Maker Should Learn

Each GPIO pin on the ESP32 can be configured as either INPUT or OUTPUT. Setting a pin as INPUT allows your ESP32 to read voltage levels from other devices connected to that pin. In contrast, setting a pin as OUTPUT enables the ESP32 to provide voltage and control external devices like LEDs or relays.

Pull-up and pull-down resistors can also be enabled on INPUT pins. Pull-up resistors pull the voltage on the pin towards the power rail (VCC), while pull-down resistors pull it towards ground (GND). These resistors help to address floating inputs, ensuring that the ESP32 reads a stable signal.

GPIO Pin Functions

ESP32 and ESP8266 GPIO Programming with MicroPython - LED Blinking

The ESP32 GPIO pins serve various functions, including driving LEDs, I2C, SPI, UART, PWM, and ADC. For instance, GPIO5 and GPIO18 on the ESP32 can be used as pulse-width modulation (PWM) outputs, while GPIO36 to GPIO39 serve as analog-to-digital converters (ADCs).

Some GPIO pins, like GPIO0 and GPIO2, have special functions. These pins can be used for tasks like entering bootloader mode or enabling the flash serial debugging interface.

ESP32 GPIO in Action: Common Use Cases

Configuring & Handling ESP32 GPIO Interrupts In Arduino IDE

The ESP32's GPIO pins are the backbone of its connectivity and interactivity. They enable the ESP32 to communicate with other devices, sense the environment, and control external peripherals. Let's explore some common use cases of GPIO on the ESP32.

First, let's study how to read and write from GPIO pins using the Arduino framework.

DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
🤖 Build an AI Attendance System using ESP32! 📡📝
Anatomy esp32
an electronic device is connected to a red button on a white piece of breadboard
an electronic device is shown in this poster, with instructions on how to use it
Simulate ESP32 Projects in VS Code with Wokwi (Beginner Guide!)
esp32 Arduíno

Reading from GPIO pins: Digital Input

To read from a GPIO pin, set it as an INPUT and use the digitalRead() function. Here's a simple example that reads from GPIO2 connected to a push button:

void setup() {
  pinMode(2, INPUT_PULLUP); // Sets pin 2 as input with internal pull-up resistor
}

void loop() {
  if (digitalRead(2) == LOW) {
    // Button pressed, perform action here
  }
}

Writing to GPIO pins: Digital Output

To write to a GPIO pin, set it as an OUTPUT and use the digitalWrite() function. This example turns an LED connected to GPIO5 on and off:

void setup() {
  pinMode(5, OUTPUT); // Sets pin 5 as output
}

void loop() {
  digitalWrite(5, HIGH); // Turns LED on
  delay(1000); // Wait for 1 second
  digitalWrite(5, LOW); // Turns LED off
  delay(1000); // Wait for 1 second
}

The ESP32's GPIO capabilities are vast and span across multiple functionalities. From reading analog signals to driving I2C devices, the GPIO pins are instrumental in making the ESP32 a versatile and powerful tool for IoT and maker projects. With this understanding, you're ready to explore and build exciting projects with the ESP32's GPIO. What will your next project be?

More shots

ESP32 Pinout Guide: GPIO, Buttons & Ports Explained
ESP32 Pinout Guide: GPIO, Buttons & Ports Explained
ESP32 Pinout Reference
ESP32 Pinout Reference
ESP32 PinOut – which pin is for what
ESP32 PinOut – which pin is for what
10 ESP32 Skills Every Maker Should Learn
10 ESP32 Skills Every Maker Should Learn
ESP32 and ESP8266 GPIO Programming with MicroPython - LED Blinking
ESP32 and ESP8266 GPIO Programming with MicroPython - LED Blinking
Configuring & Handling ESP32 GPIO Interrupts In Arduino IDE
Configuring & Handling ESP32 GPIO Interrupts In Arduino IDE
DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
🤖 Build an AI Attendance System using ESP32! 📡📝
🤖 Build an AI Attendance System using ESP32! 📡📝

Related topics