100% found this document useful (2 votes)
483 views16 pages

ESP32 Pinout Guide for Developers

The document provides information about the pinout of the ESP32 microcontroller. It discusses the various GPIO pins and their functions, including digital I/O, analog input, touch sensing, PWM output, I2C, SPI, UART, and more. It explains which pins are safe to use versus ones that require more caution. Pins like the ADC2 and certain GPIOs have limitations on their use. The document provides a helpful reference for developers to understand the capabilities and connections of the ESP32's many pins.

Uploaded by

sarbini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
483 views16 pages

ESP32 Pinout Guide for Developers

The document provides information about the pinout of the ESP32 microcontroller. It discusses the various GPIO pins and their functions, including digital I/O, analog input, touch sensing, PWM output, I2C, SPI, UART, and more. It explains which pins are safe to use versus ones that require more caution. Pins like the ADC2 and certain GPIOs have limitations on their use. The document provides a helpful reference for developers to understand the capabilities and connections of the ESP32's many pins.

Uploaded by

sarbini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

ESP32 Pinout Reference

One of the advantages of the ESP32 is that it has a lot more GPIOs than the
ESP8266. You won’t have to juggle or multiplex your IO pins. However, there
are a few things to keep in mind, so please read the pinout carefully.

Note:

Please note that the following pinout reference is for the popular 30-pin ESP32
devkit v1 development board.

Not every ESP32 development board exposes every pin, but each pin works
exactly the same no matter which development board you use.

ESP32 Peripherals and I/O


Although the ESP32 has 48 GPIO pins in total, only 25 of them are broken out
to the pin headers on both sides of the development board. These pins can be
assigned a variety of peripheral duties, including:

15 channels of 12-bit SAR ADC with selectable ranges of


15 ADC channels
0-1V, 0-1.4V, 0-2V, or 0-4V

2 UART interfaces 2 UART interfaces with flow control and IrDA support

25 PWM pins to control things like motor speed or LED


25 PWM outputs
brightness

2 DAC channels Two 8-bit DACs to generate true analog voltages

Three SPI and one I2C interfaces for connecting various


SPI, I2C and I2S
sensors and peripherals, as well as two I2S interfaces for
interface
adding sound to your project

9 Touch Pads 9 GPIOs with capacitive touch sensing

Thanks to the ESP32’s pin multiplexing feature, which allows multiple


peripherals to share a single GPIO pin. For example, a single GPIO pin can act
as an ADC input, DAC output, or touch pad.

For extensive information about the ESP32, please refer to the datasheet.

ESP32 Datasheet

ESP32 Pinout
The ESP32 DevKit V1 development board has 30 pins in total. For convenience,
pins with similar functionality are grouped together. The pinout is as follows:
Let’s take a closer look at the ESP32 pins and their functions one by one.

GPIO Pins
The ESP32 development board has 25 GPIO pins that can be assigned different
functions by programming the appropriate registers. There are several kinds of
GPIOs: digital-only, analog-enabled, capacitive-touch-enabled, etc. Analog-
enabled GPIOs and Capacitive-touch-enabled GPIOs can be configured as
digital GPIOs. Most of these digital GPIOs can be configured with internal pull-
up or pull-down, or set to high impedance.
Which ESP32 GPIOs are safe to use?

Although the ESP32 has a lot of pins with various functions, some of them may
not be suitable for your projects. The table below shows which pins are safe to
use and which pins should be used with caution.

 – Your top priority pins. They are perfectly safe to use.


 – Pay close attention because their behavior, particularly during
boot, can be unpredictable. Use them only when absolutely necessary.
 – It is recommended that you avoid using these pins.

Label GPIO Safe to use? Reason

must be HIGH during boot and LOW for


D0 0
programming

TX0 1 Tx pin, used for flashing and debugging

must be LOW during boot and also connected to


D2 2
the on-board LED

RX0 3 Rx pin, used for flashing and debugging

D4 4
D5 5 must be HIGH during boot

D6 6 Connected to Flash memory

D7 7 Connected to Flash memory

D8 8 Connected to Flash memory

D9 9 Connected to Flash memory

D10 10 Connected to Flash memory

D11 11 Connected to Flash memory

D12 12 must be LOW during boot

D13 13

D14 14

must be HIGH during boot, prevents startup log if


D15 15
pulled LOW

RX2 16

TX2 17

D18 18

D19 19

D21 21

D22 22

D23 23

D25 25
D26 26

D27 27

D32 32

D33 33

D34 34 Input only GPIO, cannot be configured as output

D35 35 Input only GPIO, cannot be configured as output

VP 36 Input only GPIO, cannot be configured as output

VN 39 Input only GPIO, cannot be configured as output

The image below shows which GPIO pins can be used safely.

Input Only GPIOs


Pins GPIO34, GPIO35, GPIO36(VP) and GPIO39(VN) cannot be configured as
outputs. They can be used as digital or analog inputs, or for other purposes.
They also lack internal pull-up and pull-down resistors, unlike the other GPIO
pins.

ESP32 Interrupt Pins


All GPIOs can be configured as interrupts. For more information, please refer
to this tutorial.

Configuring & Handling ESP32 GPIO Interrupts In

Arduino IDE
Often in a project you want the ESP32 to perform its
normal program while continuously monitoring for some
kind of event. One widely adopted solution...

ADC Pins
ESP32 integrates two 12-bit SAR ADCs and supports measurements on 15
channels (analog-enabled pins).

The ESP32’s ADC is a 12-bit ADC, which means it can detect 4096 (2^12)
discrete analog levels. In other words, it will convert input voltages ranging
from 0 to 3.3V (operating voltage) into integer values ranging from 0 to 4095.
This results in a resolution of 3.3 volts / 4096 units, or 0.0008 volts (0.8 mV) per
unit.

Moreover, the ADC resolution and channel range can be set programmatically.

Warning:
The ADC2 pins cannot be used when Wi-Fi is enabled. If your project requires
Wi-Fi, consider using the ADC1 pins instead.

DAC Pins
The ESP32 includes two 8-bit DAC channels for converting digital signals to
true analog voltages. It can be used as a “digital potentiometer” to control
analog devices.

These DACs have an 8-bit resolution, which means that values ranging
from 0 to 256 will be converted to an analog voltage ranging from 0 to 3.3V.

The DAC’s 8-bit resolution may be insufficient for use in audio applications, in
which case an external DAC with a higher resolution (12-24 bits) is preferable.

Touch Pins
The ESP32 has 9 capacitive touch-sensing GPIOs. When a capacitive load (such
as a human finger) is in close proximity to the GPIO, the ESP32 detects the
change in capacitance.

You can make a touch pad by attaching any conductive object to these pins,
such as aluminum foil, conductive cloth, conductive paint, and so on. Because
of the low-noise design and high sensitivity of the circuit, relatively small pads
can be made.

Additionally, these capacitive touch pins can be used to wake the ESP32 from
deep sleep.

I2C Pins
The ESP32 has a single I2C bus that allows you to connect up to 112 sensors
and peripherals. The SDA and SCL pins are, by default, assigned to the
following pins. However, you can bit-bang the I2C protocol on any GPIO pins
with the wire.begin(SDA, SCL) command.
SPI Pins
ESP32 features three SPIs (SPI, HSPI, and VSPI) in slave and master modes.
These SPIs also support the general-purpose SPI features listed below:

 4 timing modes of the SPI format transfer

 Up to 80 MHz and the divided clocks of 80 MHz

 Up to 64-Byte FIFO
Only VSPI and HSPI are usable SPI interfaces, and the third SPI bus is used by
the integrated flash memory chip. VSPI pins are commonly used in standard
libraries.

HSPI vs. VSPI


HSPI is sometimes misinterpreted as “Hardware” SPI and VSPI as “Virtual or
Software” SPI. In reality, however, they are identical!

As with I2C, you can bit-bang the SPI protocol on any GPIO pins with
the bus.begin(CLK_PIN, MISO_PIN, MOSI_PIN, SS_PIN); command.

UART Pins
The ESP32 dev. board has three UART interfaces, UART0, UART1, and UART2,
that support asynchronous communication (RS232 and RS485) and IrDA at up
to 5 Mbps.

 UART0 pins are connected to the USB-to-Serial converter and are used
for flashing and debugging. Therefore, the UART0 pins are not
recommended for use.

 UART1 pins are reserved for the integrated flash memory chip.
 UART2, on the other hand, is a safe option for connecting to UART-
devices such as GPS, fingerprint sensor, distance sensor, and so on.

In addition, UART provides hardware management of the CTS and RTS signals
and software flow control (XON and XOFF) as well.

PWM Pins
The board has 21 channels (all GPIOs except input-only GPIOs) of PWM pins
controlled by a PWM controller. The PWM output can be used for driving
digital motors and LEDs.
The PWM controller consists of PWM timers, the PWM operator and a
dedicated capture sub-module. Each timer provides timing in synchronous or
independent form, and each PWM operator generates a waveform for one
PWM channel. The dedicated capture sub-module can accurately capture
events with external timing.

RTC GPIO Pins


Some GPIOs are routed to the RTC low-power subsystem and are referred to
as RTC GPIOs. These pins are used to wake the ESP32 from deep sleep when
the Ultra Low Power (ULP) co-processor is running. The GPIOs highlighted
below can be used as external wake up sources.
Strapping Pins
There are five strapping pins: GPIO0, GPIO2, GPIO5, GPIO12, and GPIO15.

These pins are used to put the ESP32 into BOOT mode (to run the program
stored in the flash memory) or FLASH mode (to upload the program to the
flash memory). Depending on the state of these pins, the ESP32 will enter
BOOT mode or FLASH mode at power on.
On most development boards with built-in USB/Serial, you don’t need to
worry about the state of these pins, as the board puts them in the correct state
for flashing or boot mode.

However, if peripherals are connected to these pins, you may encounter issues
when attempting to upload new code or flash the ESP32 with new firmware, as
these peripherals prevent the ESP32 from entering the correct mode.

The strapping pins function normally after reset release, but they should still
be used with caution.

Power Pins
There are two power pins: the VIN pin and the 3V3 pin. The VIN pin can be
used to directly power the ESP32 and its peripherals, if you have a regulated
5V power supply. The 3V3 pin is the output from the on-board voltage
regulator; you can get up to 600mA from it. GND is the ground pin.

Enable Pin
The EN pin is the enable pin for the ESP32, pulled high by default. When
pulled HIGH, the chip is enabled; when pulled LOW, the chip is disabled.
The EN pin is also connected to a pushbutton switch that can pull the pin LOW
and trigger a reset.

SHARE

Common questions

Powered by AI

The ESP32 incorporates 21 PWM channels that allow flexible control over PWM signal synthesis, which is useful for driving digital motors, controlling LED brightness, and producing audio signals . The RTC GPIO pins are part of the low-power subsystem, ideal for projects requiring minimal power consumption, as they enable the ESP32 to wake from deep sleep . Together, these features allow projects to have dynamic control over outputs while maintaining low energy usage during idle times, benefiting designs that prioritize both performance and energy efficiency.

The DAC pins on the ESP32 provide 8-bit resolution, converting digital signals into analog voltages ranging between 0 and 3.3V . This resolution may prove insufficient for applications requiring high-fidelity audio, which generally demand at least 12-bit or higher-resolution DACs to minimize distortion and improve sound quality. In such cases, external DACs should be employed. External DACs with higher resolution would be ideally suited for demanding audio processing tasks, ensuring superior sound reproduction in music players or communication devices .

The ESP32 ADC consists of two 12-bit SAR ADCs, supporting up to 15 channels. When utilizing the ADC pins, particularly for projects requiring Wi-Fi, it is crucial to note that ADC2 pins cannot be used because they become unavailable when Wi-Fi is active. Therefore, projects that simultaneously require Wi-Fi and ADC input should only use ADC1 pins to avoid conflicts . This limitation must be planned for in project designs to ensure correct functionality without disruptions from Wi-Fi operations.

When using UART interfaces on the ESP32, it is advisable to avoid UART0 and UART1 for general use because UART0 is linked to the USB-to-serial converter for flashing and debugging, and UART1 is reserved for the flash memory chip . As a result, UART2 is recommended for connecting external UART devices since it is a dedicated channel free for use without interference from system functions like flashing and debugging.

Strapping pins on the ESP32—specifically GPIO0, GPIO2, GPIO5, GPIO12, and GPIO15—are utilized to dictate whether the chip enters BOOT mode or FLASH mode during start-up . They should be used cautiously because their state at power-on influences the device's operation mode, and connecting peripherals to these pins could disrupt these modes, leading to unexpected behavior or preventing new code uploads . Consequently, it is essential to ensure these pins are appropriately configured or isolated when designing circuits.

When an ESP32 project requires ADC input along with Wi-Fi functionality, it is essential to avoid using ADC2 pins, as these pins become inaccessible when Wi-Fi is active . Instead, the design should leverage ADC1 pins, ensuring that all necessary analog inputs are routed through these pins to maintain uninterrupted operation. This involves careful schematic planning and resource allocation so that ADC2's limitations do not interfere with the broader requirements of the project.

HSPI and VSPI on the ESP32 are two of the three SPI interfaces available in both master and slave modes. One common misconception is the belief that HSPI means "Hardware" SPI and VSPI signifies "Virtual or Software" SPI. This is false because both HSPI and VSPI operate identically and offer the same capabilities; arguments for one over the other based on hardware/software reasoning are incorrect . Both interfaces support general SPI features with various timing modes and a capacity for up to 80 MHz clock speeds .

Capacitive touch sensing on the ESP32 is implemented through nine specialized GPIOs that detect changes in capacitance when a conductive object, such as a human finger, approaches the pad . This functionality can be effectively applied in projects requiring human-computer interaction, such as touch-sensitive control panels or interactive installations. Due to its ability to detect minimal capacitive changes, it suits projects where minimal user interface feedback is necessary for functionality. The high sensitivity and low noise of capacitive sensing enable the use of small touch pads, further broadening application possibilities .

Input-only GPIOs on the ESP32, namely GPIO34, GPIO35, GPIO36(VP), and GPIO39(VN), are unique in that they cannot be configured as outputs but can serve as digital or analog inputs . They lack internal pull-up and pull-down resistors, meaning any input circuitry must provide this externally if necessary. These pins are well-suited for sensing applications where output capabilities are unnecessary, allowing designers to reserve flexible GPIO pins for other purposes . This ensures optimal utilization of all available GPIOs, balancing input and output demands.

ESP32's GPIO pins support multiple peripheral functions through a feature called pin multiplexing, allowing a single GPIO pin to be assigned different roles, such as ADC input, DAC output, or as a capacitive touch pad . This capability provides flexibility in designing circuit layouts, enabling the same pin to be used interchangeably in different configurations; however, it also requires careful planning to avoid conflicts, particularly when multiple functions attempt to utilize the same pin .

You might also like