ESP32 – Pinout

In this post, we’ll be taking a closer look at the ESP32 Wroom 32D hardware, and more specifically, the ESP32 pinout. ESP32 Wroom 32D is based on the Xtensa Dual-Core 32-bit LX6 with 600 DMIPS. The ESP32 Wroom 32D pinout consists of 39 digital pins, 18 analog inputs. The versatility of the pinout provides many different options such as driving motors, LED’s, reading sensors and more. In this post, we’ll go over the capabilities of the ESP32 Wroom 32D pinout.

ESP32 Peripherals

The ESP32 peripherals include:

  • 18 Analog-to-Digital Converter (ADC) channels
  • 3 SPI interfaces
  • 3 UART interfaces
  • 2 I2C interfaces
  • 16 PWM output channels
  • 2 Digital-to-Analog Converters (DAC)
  • 2 I2S interfaces
  • 10 Capacitive sensing GPIOs

The ADC (Analog to Digital Converter) and DAC (Digital to Analog Converter) features are assigned to specific static pins. However, you can decide which pins are UART, I2C, SPI, PWM, etc – you just need to assign them in the code. This is possible due to the ESP32 chip’s multiplexing feature.

Power Supply

There is one way to power the ESP32 Wroom 32D, the fist is the 3.3V Pin. This pin is used to power the ESP32 board using an external power source. The board can be powered by 1.8 ~ 3.6 Volts but the manufacturer recommends 3.3 Volts.

The GND pins are used to close the electrical circuit and provide a common logic reference level throughout your circuit. Always make sure that all GNDs (of the Arduino, peripherals and components) are connected to one another and have a common ground.

You can find 1 reset pin on the ESP32, CHIP_PU serves as the reset pin of the ESP32.

Analog

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

Analog to Digital Conversion

ADC stands for Analog to Digital Converter. ADC is an electronic circuit used to convert analog signals into digital signals. This digital representation of analog signals allows the processor (which is a digital device) to measure the analog signal and use it through its operation. The ESP32 Pins ADC1_X and ADC2_X are capable of reading analog voltages. The ADC converts voltage into bits which the microprocessor can understand.

  • 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: ADC2 pins cannot be used when Wi-Fi is used. So, if you’re using Wi-Fi and you’re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead, that should solve your problem.

The ADC input channels have a 12 bit resolution. This means that you can get analog readings ranging from 0 to 4095, in which 0 corresponds to 0V and 4095 to 3.3V. You also have the ability to set the resolution of your channels on the code, as well as the ADC range.

The ESP32 ADC pins don’t have a linear behavior. You’ll probably won’t be able to distinguish between 0 and 0.1V, or between 3.2 and 3.3V. You need to keep that in mind when using the ADC pins.

Digital Pins

All of the ESP32 serve as digital input/output pins.

Note: Each pin can provide up to 40 mA max. But the recommended current is 20 mA. The absolute max current provided (or sank) from all pins together is 200mA.

Digital

Digital is a way of representing voltage in 1 bit: either 0 or 1. Digital pins on the ESP32 are pins designed to be configured as inputs or outputs according to the needs of the user. Digital pins are either on or off. When ON they are in a HIGH voltage state of 3.3V and when OFF they are in a LOW voltage state of 0V. When the digital pins are configured as output, they are set to 0 or 3.3 volts.

Between 0-3.3 volts which is converted into digital representation (0 or 1). To determine this, there are 2 thresholds: Below 0.8v – considered as 0. Above 2v – considered as 1. When connecting a component to a digital pin, make sure that the logic levels match. If the voltage is in between the thresholds, the returning value will be undefined.

Input only pins

GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal pull-ups or pull-down resistors. They can’t be used as outputs, so use these pins only as inputs:

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

Digital to Analog Converter (DAC)

There are 2 x 8 bits DAC channels on the ESP32 to convert digital signals into analog voltage signal outputs. These are the DAC channels. DAC1 (GPIO25) and DAC2 (GPIO26).

PWM

In general, Pulse Width Modulation (PWM) is a modulation technique used to encode a message into a pulsing signal. A PWM is comprised of two key components:  frequency and duty cycle. The PWM frequency dictates how long it takes to complete a single cycle (period) and how quickly the signal fluctuates from high to low. The duty cycle determines how long a signal stays high out of the total period. Duty cycle is represented in percentage.

On the ESP32, the PWM enabled pins produce a constant frequency of ~ 500Hz, while the duty cycle changes according to the parameters set by the user. See the following illustration:

PWM signals are used for speed control of DC motors, dimming LEDs and more. The ESP32 PWM controller has 16 independent channels that can be configured to generate PWM signals with different properties. All pins that can act as outputs can be used as PWM pins (GPIOs 34 to 39 can’t generate PWM). To set a PWM signal, you need to define these parameters in the code:

  • Signal’s frequency;
  • Duty cycle;
  • PWM channel;
  • GPIO where you want to output the signal.

Serial Communication

Serial communication is used to exchange data between the Arduino board and another serial device such as computers, displays, sensors and more. Each Arduino board has at least one serial port. Serial communication occurs on digital pins 0 (RX) and 1 (TX) as well as via USB. Arduino supports serial communication through digital pins with the SoftwareSerial Library as well. This allows the user to connect multiple serial-enabled devices and leave the main serial port available for the USB.

Software serial and hardware serial – Most microcontrollers have hardware designed to communicate with other serial devices. Software serial ports use a pin-change interrupt system to communicate. There is a built-in library for Software Serial communication. Software serial is used by the processor to simulate extra serial ports. The only drawback with software serial is that it requires more processing and cannot support the same high speeds as hardware serial.

SPI

SPI – SS/SCK/MISO/MOSI pins are the dedicated pins for SPI communication. Serial Peripheral Interface (SPI) is a serial data protocol used by microcontrollers to communicate with one or more external devices in a bus like connection. The SPI can also be used to connect 2 microcontrollers. On the SPI bus, there is always one device that is denoted as a Master device and all the rest as Slaves. In most cases, the microcontroller is the Master device. The SS (Slave Select) pin determines which device the Master is currently communicating with. SS/SCK/MISO/MOSI pins are the dedicated pins for SPI communication. SPI enabled devices always have the following pins:

MISO (Master In Slave Out) – A line for sending data to the Master device
MOSI (Master Out Slave In) – The Master line for sending data to peripheral devices
SCK (Serial Clock) – A clock signal generated by the Master device to synchronize data transmission.
SS (Slave Select) pin determines which device the Master is.

By default, the pin mapping for SPI is:

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

SPI flash integrated

GPIO 6 to GPIO 11 are exposed in some ESP32 development boards. However, these pins are connected to the integrated SPI flash on the ESP-WROOM-32 chip and are not recommended for other uses. So, don’t 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)

I2C

I2C is a communication protocol commonly referred to as the “I2C bus”. The I2C protocol was designed to enable communication between components on a single circuit board. With I2C there are 2 wires referred to as SCL and SDA. SCL/SDA pins are the dedicated pins for I2C communication.

SCL is the clock line which is designed to synchronize data transfers.
SDA is the line used to transmit data.

Each device on the I2C bus has a unique address, up to 255 devices can be connected on the same bus. The ESP32 has two I2C channels and any pin can be set as SDA or SCL. The default I2C pins are.

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

Interrupt 

An external interrupt is a system interrupt that occurs when outside interference is present. Interference can come from the user or other hardware devices in the network. Common uses for these interrupts in ESP32 are reading the frequency a square wave generated by encoders or waking up the processor upon an external event. on the ESP32, all GPIOs can be configured as interrupts.

Capacitive touch GPIOs

The ESP32 has 10 internal capacitive touch sensors. These can sense variations in anything that holds an electrical charge, like the human skin. So they can detect variations induced when touching the GPIOs with a finger. These pins can be easily integrated into capacitive pads, and replace mechanical buttons. The capacitive touch pins can also be used to wake up the ESP32 from deep sleep.

Those internal touch sensors are connected to these GPIO’s.

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

There is RTC GPIO support on the ESP32. The GPIOs routed to the RTC low-power subsystem can be used when the ESP32 is in deep sleep. These RTC GPIOs can be used to wake up the ESP32 from deep sleep when the Ultra Low Power (ULP) co-processor is running. The following GPIOs can be used as an external wake up source.

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

Strapping Pins

The ESP32 chip has the following strapping pins:

  • GPIO 0
  • GPIO 2
  • GPIO 4
  • GPIO 5 (must be HIGH during boot)
  • GPIO 12 (must be LOW during boot)
  • GPIO 15 (must be HIGH during boot)

These are used to put the ESP32 into bootloader or flashing mode. On most development boards with built-in USB/Serial, you don’t need to worry about the state of these pins. The board puts the pins in the right state for flashing or boot mode.

However, if you have peripherals connected to those pins, you may have trouble trying to upload new code, flashing the ESP32 with new firmware or resetting the board. If you have some peripherals connected to the strapping pins and you are getting trouble uploading code or flashing the ESP32, it may be because those peripherals are preventing the ESP32 to enter the right mode. After resetting, flashing, or booting, those pins work as expected.

Pins HIGH at Boot

Some GPIO’s change its state to HIGH or output PWM signals at boot or reset. This means that if you have outputs connected to these GPIOs you may get unexpected results when the ESP32 resets or boots.

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

GPIO current drawn

The absolute maximum current drawn per GPIO is 40mA according to the “Recommended Operating Conditions” section in the ESP32 datasheet.

ESP32 Built-In Hall Effect Sensor

The ESP32 also features a built-in hall effect sensor that detects changes in the magnetic field in its surroundings.

BEST PINS TO USE – ESP32

Additionally, there are pins with specific features that make them suitable or not for a specific project. The following table shows what pins are best to use as inputs, outputs and which ones you need to be cautious.

The pins highlighted in green are OK to use. The ones highlighted in yellow are OK to use, but you need to pay attention because they may have unexpected behavior mainly at boot. The pins highlighted in red are not recommended to 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
6 X X connected to the integrated SPI flash
7 X X connected to the integrated SPI flash
8 X X connected to the integrated SPI flash connected to the integrated SPI flash
9 X X connected to the integrated SPI flash
10 X X connected to the integrated SPI flash
11 X X connected to the integrated SPI flash
12OK OK  
13 OK OK outputs PWM signal at boot
14 OK OK outputs PWM signal at boot
15 OK OK  
16 OK OK  
17 OK OK  
18 OK OK  
19 OK OK  
20 OK OK  
21 OK OK  
22 OK OK  
23 OK OK  
24 OK OK  
25 OK OK  
26 OK OK  
27 OK OK  
28 OK OK  
29 OK OK  
30 OK OK  
31 OK OK  
32 OK OK  
33 OK OK  
34 OK   
35 OK   
36 OK  input only
37 OK  input only
38 OK  input only
39 OK  input only

Continue reading for a more detail and in-depth analysis of the ESP32 GPIOs and its functions.

Overview

The ESP32 Microcontroller is one of the most versatile boards on the market today and that’s why we decided to focus on it in this guide. This guide displays most of its capabilities, but there are also more advanced options which we did not go into in this post.

The important thing to know when you choose a board for your project is its capabilities and limitations. It’s also important to understand the different communication protocols that the board uses. Of course, you don’t need to remember all of this information, you can always go back to this post and read the relevant information for you (this is a good time to bookmark this Blog btw).

Download

Download the ESP32 Reference sheet for free!

Reference:

Espressif, Technical specifications for the ESP32, https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf   Espressif , Technical specifications for the ESP32, https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf  RandomNerdTutorials, ESP32 Pinout Reference,Which GPIO pins should you use, https://randomnerdtutorials.com/esp32-pinout-reference-gpios

Scroll to Top