Full Guide to ESP32 Pinout Reference: What GPIO Pins Should We Use?

Table of Contents

Overview

Attractive features and capabilities of ESP32 microcontroller, has made it a pretty good option for a variety of IoT –Internet of Things- projects and applications. In order to make the fullest use of the ESP32 abilities and features, a sufficient knowledge of its pins is so essential. The goal of this tutorial is to introduce all types of pins available in this microcontroller and the features associated with each of those pins. So, stay with us until the end of this tutorial!

What You Will Learn

  • Different types of ESP32 pins and their features

The ESP32 Microcontroller –ESP32-WROOM-32- Pinout

Different types of ESP32 microcontrollers have been manufactured and are available on the market. The one we have fully examined and explained in this tutorial is the ESP32-WROOM-32 microcontroller which is  also known as WROOM32. This microcontroller is one of the most famous and widely used microcontroller among all ESP32 series and is also used in a lot of ESP32-based development boards. These development boards include ESP32 Wemos Lolin32, ESP32-CoreBoard, and so on. Also, if you’re using a development board based on an ESP32 microcontroller other than WROOM32, this tutorial can still be useful for you, since other types of ESP32 microcontrollers come with pins similar to the WROOM pins.              

 You can see the full pinout  of the ESP32-WROOM-32 microcontroller in the image below

In the following, we will describe and explain the pins of this microcontroller in more detail.

An Exhaustive Explaination of the ESP32 Pins

The ESP32 microcontroller has the following pins at a glance:

  • 18 12-bit ADC pins
  • 2 8-bit DAC pins
  • 3 SPI interfaces
  • 2 I2C interfaces
  • 3 UART interfaces
  • 16 PWM channels
  • 2 I2S interfaces
  • 10 touch pins

Different types of ESP32 pins are as follows.

GPIO Pins

The ESP32 microcontroller has the following GPIO –General Purpose Input/Output- pins.

ADC Pins

There are a total of 18 12-bit ADC –Analog to Digital Converter- pins in the ESP32 microcontroller. Being a 12-bit ADC means that it can convert the input voltage to a number between 0 and 4095. 0 for 0V input and 4095 for 3.3V input.

These 18 pins are as follows.

  • ADC1-CH0 (GPIO 36)
  • ADC1-CH1 (GPIO 37)
  • ADC1-CH2 (GPIO 38)
  • ADC1-CH3 (GPIO 39)
  • ADC1-CH4 (GPIO 32)
  • ADC1-CH5 (GPIO 33)
  • ADC1-CH6 (GPIO 34)
  • ADC1-CH7 (GPIO 35)
  • ADC2-CH0 (GPIO 4)
  • ADC2-CH1 (GPIO 0)
  • ADC2-CH2 (GPIO 2)
  • ADC2-CH3 (GPIO 15)
  • ADC2-CH4 (GPIO 13)
  • ADC2-CH5 (GPIO 12)
  • ADC2-CH6 (GPIO 14)
  • ADC2-CH7 (GPIO 27)
  • ADC2-CH8 (GPIO 25)
  • ADC2-CH9 (GPIO 26)
Note

Pay attention that channels related to the ADC2 interfere with the Wi-Fi. If the Wi-Fi of the ESP32 is running, you better use the ADC1 pins.

DAC Pins

The ESP32 microcontroller has 2 8-bit DAC –Digital to Analog- pins. The 8-bit resolution means that these converters can produce a voltage between 0 and 3.3V with the accuracy of 3.3/256 volts.

These 2 pins are as follows.

  • DAC1 (GPIO 25)
  • DAC2 (GPIO 26)

Capacitive Touch Pins

As already mentioned, the ESP32 microcontroller has 10 pins that can function as touch sensors. The other function of these pins is to wake up the ESP32 microcontroller from deep sleep. In order to know more about the ESP32 deep sleep mode, you can refer to the following tutorial.

The link to the “ESP32 Deep Sleep” tutorial

The 10 touch pins of the ESP32 microcontroller are as follows.

  • T0 (GPIO 4)
  • T1 (GPIO 0)
  • T2 (GPIO 2)
  • T3 (GPIO 15)
  • T4 (GPIO 13)
  • T5 (GPIO 12)
  • T6 (GPIO 14)
  • T7 (GPIO 27)
  • T8 (GPIO 33)
  • T9 (GPIO 32)

RTC Pins

The ESP32 microcontroller has a total of 16 RTC –Real Time Clock- pins, which are mainly used in the ESP32 already mentioned deep sleep mode. They can also be used to wake the ESP32 from deep sleep.

The RTC pins of the ESP32 microcontroller are as follows.

  • RTC_GPIO0 (GPIO 36)
  • RTC_GPIO3 (GPIO 39)
  • RTC_GPIO4 (GPIO 34)
  • RTC_GPIO5 (GPIO 35)
  • RTC_GPIO6 (GPIO 25)
  • RTC_GPIO7 (GPIO 26)
  • RTC_GPIO8 (GPIO 33)
  • RTC_GPIO9 (GPIO 32)
  • RTC_GPIO10 (GPIO 4)
  • RTC_GPIO11 (GPIO 0)
  • RTC_GPIO12 (GPIO 2)
  • RTC_GPIO13 (GPIO 15)
  • RTC_GPIO14 (GPIO 13)
  • RTC_GPIO15 (GPIO 12)
  • RTC_GPIO16 (GPIO 14)
  • RTC_GPIO17 (GPIO 27)

SPI Pins

ESP32-WROOM-32 microcontroller has 3 default SPI interfaces. One of them is designed for the communication between the ESP32 microcontroller and the SPI flash memory, so, it’s recommended not to use. The pin mapping related to this SPI interface is as follows:

  • SCK/CLK (GPIO 6)
  • SDO/SD0 (GPIO 7)
  • SDI/SD1 (GPIO 8)
  • SHD/SD2 (GPIO 9)
  • SWP/SD3 (GPIO 10)
  • CSC/CMD (GPIO 11)

As mentioned above, the ESP32 comes with 3 default SPI interfaces and except for one, which is used to communicate with flash memory, the other 2 are available. These 2 are known as HSPI –Hardware SPI- and VSPI –Virtual SPI-. You can see the pins assigned to these interfaces in the table below.

SPI MISO MOSI CLK CS
HSPI GPIO 12 GPIO 13 GPIO 14 GPIO 15
VSPI GPIO 19 GPIO 23 GPIO 18 GPIO 5
Note

Note that you’re not limited to using the two interfaces introduced above, and you can define any other pins of the ESP32 as SPI.

I2C Pins

The ESP32 comes with 2 internal I2C channels and also a default pair of pins for the I2C communication protocol. And just like SPI, you can define any other pins of the ESP32 as I2C, if needed.

The default I2C pins of ESP32 are as follows.

  • SDA (GPIO 21)
  • SCL (GPIO 22)

UART Pins

In this microcontroller, there are 3 default UART interfaces and the other pins can also be defined as UART interface in the code.

You can see the pins related to these 3 UART interfaces.

UART RXD TXD RTS CST
UART0 GPIO 1 GPIO 3 GPIO 22 GPIO 19
UART1 GPIO 9 GPIO 10 GPIO 11 GPIO 6
UART2 GPIO 16 GPIO 17 GPIO 7 GPIO 8

PWM Pins

The ESP32 microcontroller has a PWM controller circuit that can be used to generate PWM signals in 16 different channels and control them independently.

To generate a PWM signal, you first need to set the following values in your code.

  • Signal frequency
  • Pulse width
  • PWM channel

Then, you can set this PWM signal as the output of any of the ESP32 GPIO pins that are capable of being set as an output. –The GPIO pins 34-39 cannot be set as output, so you can’t use them to get PWM signals.

Interrupt Pins

You can use all GPIO pins as an interrupt.

Power Supply Pins

The pins related to power supply are as follows.

3.3V Pin

The pin number 2 of the ESP32 microcontroller, as depicted in the image above, is its main power supply pin. Forasmuch as the microcontroller operates at 3.3V logic level, it’s important to prepare an accurate power supply for the microcontroller to minimize the chances of damage to the chip.

GND Pins

The pins number 1, 15 and 38 of this microcontroller are the GND pins. When powering the microcontroller, it’s necessary to connect them all to the ground of the external power supply.

EN Pin

The pin number 3 is the EN –Enable- pin of the ESP32 microcontroller. This pin is so-called “Active High” and needs to be connected to a high logic level -3.3V- for the microcontroller to operate.

What’s Next?

After completing this tutorial, you can experience new challenges related to this tutorial:

  • Next, set up one of the touch sensor pins of the ESP32 and control an LED with it

Liked What you see?

Get updates and learn from the best

More To Explore

Comments (2)

  • apires Reply

    RX and TX pins are swaped!
    GPIO1 is TX;
    GPIO3 is RX;

    November 29, 2022 at 10:01 am
    • Ali Abdolmaleki Reply

      Hi Dear
      if you connect any device with serial port you should connect Device TX pin to ESP RX pin and Device RX pin to ESP TX pin.

      regards.

      November 30, 2022 at 9:33 am

Leave a Reply

Your email address will not be published. Required fields are marked *