0 0
iTechBuilders

Esp32 Pinout: Your Ultimate Guide To Gpios, Functions, And Projects

  • Home
  • Projects
  • ESP32 Pinout: Your Ultimate Guide to GPIOs, Functions, and Projects
ESP32 Pinout: Your Ultimate Guide to GPIOs, Functions, and Projects

ESP32 Pinout: Your Ultimate Guide to GPIOs, Functions, and Projects

09 Sep 2025 0 Comments Blog

Master the ESP32 pinout with this definitive guide. Learn the functions of each GPIO, including ADC, DAC, I2C, SPI, and touch sensors. Avoid common mistakes with strapping pins and get practical code examples for your next IoT project. Perfect for beginners and advanced users.

The ESP32 is a powerful, feature-rich microcontroller that has become a cornerstone of IoT and wireless projects. But with its complex dual-core processor and multitude of pins, it can be intimidating for beginners and experienced makers alike. What are all those GPIOs for? How do you use the touch sensors? Where do you connect I2C devices?

This ultimate guide will demystify the ESP32 pinout for popular development boards like the ESP-WROOM-32. We’ll break down every pin, explain its primary and special functions, and show you exactly how to use them with practical wiring examples and code. By the end, you'll be confidently connecting sensors, displays, and modules to build advanced IoT applications.

ESP32 Pinout
ESP32 Board
Arduino Uno Board

“Mastering the ESP32 pinout is the key to unlocking the full potential of WiFi, Bluetooth, and dual-core processing in your DIY projects.”

ESP32 Technical Specifications

Before we dive into the pins, let's review what makes the ESP32 so powerful:

  • Microcontroller: Xtensa® Dual-Core 32-bit LX6 microprocessor
  • Wireless Connectivity: WiFi 802.11 b/g/n (2.4 GHz) & Bluetooth v4.2+
  • Operating Voltage: 3.3V
  • Input Voltage: 7-12V (recommended via USB/VIN)
  • Digital I/O Pins: 36+ (most are multifunctional)
  • Analog Input Pins: 18 (12-bit ADC)
  • Analog Output Pins: 2 (8-bit DAC)
  • Flash Memory: 4 MB (typical)
  • SRAM: 520 KB | Clock Speed: Up to 240 MHz

Detailed ESP32 Pin Description

The ESP32's GPIOs are highly configurable. This is both a strength and a complexity. The following guide is based on the common 36-pin ESP-WROOM-32 module found on boards like the DOIT DEVKIT V1.

1. Power Pins

Crucial: The ESP32 is a 3.3V device. Applying 5V to any GPIO will likely damage the chip.

  • 3.3V: Output from the onboard regulator. Use to power external components.
  • GND: Ground pins.
  • VIN: Input voltage (7-12V recommended) if not powering via USB.
  • EN (Enable): Pull this pin LOW to reset the chip. Has an internal pull-up resistor.

2. Digital & Analog GPIO Pins

Most pins are multifunctional. Their function is determined by your code. Note: Many pins have restrictions.

  • GPIO 0-5, 12-19, 21-23, 25-27, 32-33: General Purpose Digital I/O pins.
  • GPIO 34-39: Input-Only Pins. Cannot be used as outputs. They also lack internal pull-up/pull-down resistors.
  • ADC1 (GPIO 32-39): Analog Inputs (8 channels). Note: Cannot be used when WiFi is active.
  • ADC2 (GPIO 0, 2, 4, 12-15): Analog Inputs (10 channels). Note: Cannot be used when WiFi is active.
  • DAC1 (GPIO 25) & DAC2 (GPIO 26): True 8-bit Analog Output (Digital to Analog Converters).

// Example: Read Analog Sensor (LDR on GPIO 32)
void setup() {
  Serial.begin(115200);
}
void loop() {
  int analogValue = analogRead(32); // Read from GPIO 32 (ADC1_CH4)
  Serial.println(analogValue);
  delay(500);
}
  

3. Special Function Pins (The Real Power)

This is where the ESP32 truly shines with built-in hardware support for advanced protocols.

  • Touch Sensors (Capacitive): GPIO 2, 4, 12, 13, 14, 15, 27, 32, 33. Use touchRead().
  • I2C (Two Default Pairs): Default SDA: GPIO 21 | Default SCL: GPIO 22 (can be remapped)
  • SPI (VSPI & HSPI):
    • VSPI: MOSI (GPIO 23), MISO (GPIO 19), SCK (GPIO 18), SS (GPIO 5)
    • HSPI: MOSI (GPIO 13), MISO (GPIO 12), SCK (GPIO 14), SS (GPIO 15)
  • UART (3 Serial Ports):
    • UART0: RX0 (GPIO 3), TX0 (GPIO 1) – Used for programming and Serial Monitor.
    • UART1: RX1 (GPIO 9), TX1 (GPIO 10) – Often used for flash.
    • UART2: RX2 (GPIO 16), TX2 (GPIO 17) – Free to use.
  • PWM: All GPIOs capable of output can be used for 16-channel PWM (using the LEDC peripheral).

// Example: Read Touch Sensor (GPIO 4)
void setup() {
  Serial.begin(115200);
  delay(1000);
}
void loop() {
  int touchValue = touchRead(4); // Read from T0 (GPIO 4)
  Serial.printf("Touch value: %d\
", touchValue);
  delay(1000);
}
  

4. Strapping Pins (Important for Boot Mode)

Certain pins must be at specific logic levels on boot to enter certain modes (like flashing). Do not use these pins with pull-ups/pull-downs or components that might hold them high/low on boot.

  • GPIO 0: Must be HIGH to boot normally, LOW to enter flashing mode.
  • GPIO 2: Must be HIGH on boot.
  • GPIO 12 (MTDI): Boot voltage determines flash voltage. Keep floating or pull LOW.
  • GPIO 15 (MTDO): Must be HIGH on boot.
  • GPIO 5: Must be HIGH on boot.

Project Example: Fade an LED with ESP32 PWM

Using the LEDC library for smooth fading on GPIO 16 (any output-capable GPIO will work).


// ESP32 Fade LED with PWM (LEDC)
#define LED_PIN 16
#define PWM_CHANNEL 0
#define PWM_FREQ 5000
#define PWM_RESOLUTION 8

int dutyCycle = 0;
int fadeAmount = 5;

void setup() {
  ledcSetup(PWM_CHANNEL, PWM_FREQ, PWM_RESOLUTION);
  ledcAttachPin(LED_PIN, PWM_CHANNEL);
}

void loop() {
  ledcWrite(PWM_CHANNEL, dutyCycle);
  dutyCycle = dutyCycle + fadeAmount;
  if (dutyCycle <= 0 || dutyCycle >= 255) {
    fadeAmount = -fadeAmount;
  }
  delay(30);
}
  

Conclusion and Next Steps

You now have a comprehensive understanding of the powerful and complex ESP32 pinout. Start by experimenting with digital writes and analog reads, then move on to its unique features like touch pins, Bluetooth, and dual-core processing. The best way to learn is by doing.

Ready for your next project? Check out our other in-depth guides:

Comments

0
No comments yet. Be the first to comment!

Leave a Comment