The ESP32 microcontroller, with its attractive features and capabilities, is an excellent choice for various IoT (Internet of Things) projects and applications. To make the most of the ESP32’s abilities, understanding its pins is crucial. This tutorial aims to introduce the different types of pins available in this microcontroller and their associated features. Join us until the end of this tutorial to learn everything you need to know!
What You Will Learn
- Different types of ESP32 pins and their features
The ESP-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 find the complete pinout diagram of the ESP32-WROOM-32 in the image below. We will describe and explain each pin in detail.
An Exhaustive Explanation of the ESP32 Pins
The ESP32 microcontroller has the following pins :
- 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
The ESP32 has the following GPIO (General Purpose Input/Output) 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)
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.
The ESP32 includes 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
In addition to their touch sensor functionality, the ESP32’s 10 capacitive touch pins can wake up the microcontroller from deep sleep. To learn more about the ESP32 deep sleep mode, refer to our “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)
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. These pins can also wake up 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)
The ESP32-WROOM-32 microcontroller provides 3 default SPI interfaces. One of them is designed for the communication between the ESP32 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)
Apart from the dedicated SPI interface, the ESP32 offers two additional SPI interfaces: HSPI (Hardware SPI) and VSPI (Virtual SPI). The table below shows the pins assigned to these interfaces. Note that you can define any other ESP32 pins as SPI if necessary.
|HSPI||GPIO 12||GPIO 13||GPIO 14||GPIO 15|
|VSPI||GPIO 19||GPIO 23||GPIO 18||GPIO 5|
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.
The ESP32 has 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 required.
The default I2C pins of ESP32 are as follows:
- SDA (GPIO 21)
- SCL (GPIO 22)
The ESP32 features 3 default UART interfaces, and you can define additional pins as UART interfaces in your code.
You can see the pins related to these 3 UART interfaces.
|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|
The ESP32 contains 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.
You can use all GPIO pins as an interrupt.
Power Supply Pins
The pins related to power supply are as follows.
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.
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.
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.
Once you’ve completed this tutorial, take on exciting challenges related to ESP32 pins:
- Learn to set up a touch sensor pin on the ESP32 and control an LED using its input.
Now that you have gained a comprehensive understanding of ESP32 pinout, it’s time to put your knowledge into practice. Start exploring the endless possibilities for your IoT projects! If you have any questions or need further assistance, feel free to ask in the comments below.