This article on Esp32 pinout reference gives a complete idea about the pinout configuration, the function assigned to pins, what gpio pins we can use.

Esp32 chip has 48 pins with multiple functions. Not all the ESP32  development boards have all the pins exposed, and there are some unusable pins.

There are many questions about how to use ESP32 GPIO pins. What GPIO pins should we use? Which GPIO pins should we need to avoid? This article aims to make the reference guide for ESP32 pinout simple and easy to follow.

The image below illustrates the pinout of the ESP wroom 32. If you use an esp32 bare chip to build a custom board you can use it as a reference

Note: GPIO means General Purpose Input Output , we are using short for GPIO through out this article

Esp32 Wroom 32 pinout  diagram
Image of Esp32 WROOM

ESP32 Pinout Peripherals

Includes ESP32 Peripherals

Digital to Analog Converter ( DAC) and Analog to digital converter (ADC)  features assigned to specific static pins. However, you can decide which pins are UART, I2C, SPI, PWM, etc. You need to enter them in the code. This is possible due to the multiplexing feature of the ESP32 chip.

esp32 dev kit  pinout diagram  ,GPIO pin description

In spite of the fact that you can characterize the pins properties on the software, the pins define it by default as shown in the figure below. ESP32 DEVKIT V1 DOIT board‌ is an example of this and that it has 36 pins‌ which can be changed depending on the construction.

Additionally, there are pins that have specific features that make them suitable for a particular project or not. The following table shows the most suitable pins to use for inputs, outputs, and what to look out for.

It is OK to use pins highlighted in green. It is OK to use the ones highlighted in yellow, but you need to be careful, as they may have an unpredictable nature, mainly on the boot. GPIO pins highlighted in red are not recommended for use as inputs or outputs

GPIOInputOutputNotes
0pulled upOKoutputs PWM signal at boot
1TX pinOKdebug output at boot
2OKOKconnected to on-board LED
3OKRX pinHIGH at boot
4OKOK
5OKOKoutputs PWM signal at boot
6xxconnected to the integrated SPI flash
7xxconnected to the integrated SPI flash
8xxconnected to the integrated SPI flash
9xxconnected to the integrated SPI flash
10xxconnected to the integrated SPI flash
11xxconnected to the integrated SPI flash
12OKOKboot fail if pulled high
13OKOK
14OKOKoutputs PWM signal at boot
15OKOKoutputs PWM signal at boot
16OKOK
17OKOK
18OKOK
19OKOK
21OKOK
22OKOK
23OKOK
25OKOK
26OKOK
27OKOK
32OKOK
33OKOK
34OKinput only
35OKinput only
36OKinput only
39OKinput only

Continue reading for the details and fuctions of the esp32 gpio.

Click here to download the ESP32 Datasheet

Input only GPIO pins

GPIOs range from 34 to 39 GPIs – input only PIN. These pins have no internal pull-ups or pull-down resistors and cant is used to connect actuators to perform OUTPUT functions.

  • GPIO 34
  • GPIO 35
  • GPIO 36
  • GPIO 39

SPI Flash integrated with ESP-WROOM-32

GPIO pin 6 to GPIO pin 11 displayed on ESP32 development boards are normally connected to the integrated SPI flash on the ESP-WROOM-32 chip, which is not recommended for other uses. Therefore, do not use these pins in your projects:

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

Capacitive Touch GPIOs in ESP32

The ESP32 has 10 internal capacitive touch sensors. They understand the differences between anything that holds an electric charge like human skin. So they can detect the changes that occur when GPIOs are touched with one finger. These pins can be easily integrated into capacitive pads and replaced with mechanical buttons. Capacitive touch pins can also be used to wake ESP32 out of deep sleep.

Those internal touch sensors are connected to these GPIOs:

  • 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

Analog to Digital Converter (ADC) in ESP32

ESP32 has 18 x 12 bits ADC input channels (ESP8266 only has 1x 10 bits ‌ ADC). These are the GPIOs that can be used as ADCs and their respective channels:

  • 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)

ADC  input channels have 12 bit resolution. This means you get analog readings from 0 to 4095, of which 0 0V fits 4095 to 3.3V. You have the ability to set the resolution code and ADC range of your channels.

ESP32 ADC pins have no linear behavior. You can distinguish between 0, 0.1V, or 3.2 and 3.3V. You need to keep that in mind when using ADC pins. You will get a behavior similar to the one shown in the image below.

Graph showing ESP32 ADC pins have no linear behavior

Digital to Analog Converter (DAC) in ESP32

ESP32 has 2 x 8 bits of DAC channels for converting digital signals into analog voltage signal p output. These are DAC channels:

  • DAC1 (GPIO25)
  • DAC2 (GPIO26)

RTC GPIOs

ESP32 has RTC GPIO pin support. GPIO pins leading to the RTC low-power subsystem can be used while ESP32 is in deep sleep. These RTC GPOs can be used to wake up ESP32 from a deep sleep while running Ultra Low Power (ULP) co-processor. The following GPIOs can be used as an external excitation source. For more details refer to ESP32 Datasheet

  • RTC_GPIO0 (GPIO36)
  • RTC_GPIO3 (GPIO39)
  • RTC_GPIO4 (GPIO34)
  • RTC_GPIO5 (GPIO35)
  • RTC_GPIO6 (GPIO25)
  • RTC_GPIO7 (GPIO26)
  • RTC_GPIO8 (GPIO33)
  • RTC_GPIO9 (GPIO32)
  • RTC_GPIO10 (GPIO4)
  • RTC_GPIO11 (GPIO0)
  • RTC_GPIO12 (GPIO2)
  • RTC_GPIO13 (GPIO15)
  • RTC_GPIO14 (GPIO13)
  • RTC_GPIO15 (GPIO12)
  • RTC_GPIO16 (GPIO14)
  • RTC_GPIO17 (GPIO27)

ESP32 LED PWM Controller

The ESP32 LED PWM controller has 16 independent channels that can be configured to generate different quality PWM signals. All pins that can act as P output can be used as PWM pins (GPIOs 34 to 39 cannot generate PWM).

To set up a PWM signal, you need to define these parameters in the code:

  • Signal frequency
  • Duty cycle
  • PWM channel

GPIO where you want to the signal output.

I2C

ESP32 has two I2C channels, which can be set to either SDA or SCL. When using ESP32 with the Arduino IDE, the default I2C pins are:

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

SPI

By default, the pin mapping for SPI is:

SPIMOSIMISOCLKCS
VSPIGPIO 23GPIO 19GPIO 18GPIO 5
HSPIGPIO 13GPIO 12GPIO 14GPIO 15

Strapping pins

The ESP32 chip has the following strapping pins:

  • GPIO 0
  • GPIO 2
  • GPIO 4
  • GPIO 5 (must be high at boot)
  • GPIO 12 (minimum on boot)
  • GPIO 15 (must be high at boot)

These pins used to embed the ESP32 bootloader or in flashing mode. On most development boards with built-in USB / Serial, you do not have to worry about the condition of these pins. The board puts the pin in the correct position for flashing or boot mode.

However, if you have associated devices connected to those pins, you may have trouble trying to upload new code, flashing ESP32 with the new firmware, or resetting the board. If you have some peripherals attached to the strapping pins, and you have trouble uploading code or flashing ESP32, those peripherals may prevent ESP32 from entering the correct mode.

Read the boot mode selection documentation to guide you in the right direction. After resetting, flashing or booting, the pin works as expected.

High pins on the boot

Some GPIOs change its state to HIGH or output PWM signals when booted or reset. This means that if you have ptputs connected to these GPIOs, you may get “” unexpected results when resetting or booting ESP32.

  • GPIO 1
  • GPIO 3
  • GPIO 5
  • GPIO 6 to GPIO 11 (ESP32 integrated with integrated SPI flash memory – not recommended for use).
  • GPIO 14
  • GPIO 15

Enable (EN)

Enable (EN) is the 3.3V regulator’s enable pin. It’s always pulled up by default, so connect to the ground to disable the 3.3V regulator. This means that you can use this pin connected to a pushbutton to restart your ESP32 Development board .

Refered from the ESP32 datasheet, the maximum rated current drawn by a GPIO is 40mA. ESP32 Built-in Hall Effect Sensor The ESP32 also features a built-in hall effect sensor that detects changes in the surrounding magnetic field.

Author

Write A Comment