ESP32 Pinout reference

Introduction:


The ESP32 is a highly popular choice for adding wireless connectivity to embedded projects or building IoT devices. It offers a dual-core option for handling processor-intensive tasks, along with built-in WiFi and Bluetooth capabilities, making it an ideal choice for various applications. Additionally, its ample I/O, memory, and interoperability cater to the needs of most projects.

Espressif, the company behind the ESP32 chip, manufactures modules and development boards. If you plan to design a custom PCB with an ESP32, opting for the ESP32-WROOM-32 module is advantageous. Unlike using the bare chip, the module is already FCC-approved, eliminating the need for additional measures to achieve FCC compliance. This simplifies the manufacturing process significantly.

Understanding the pinout of the ESP32-WROOM-32 module is essential for custom PCB design. This article provides a comprehensive overview of the ESP32-WROOM-32 pinout, detailing each pin’s function and usage.

GPIO pin

The ESP32-WROOM-32 module features 32 GPIO pins, each capable of being assigned various functions through appropriate register programming. These GPIOs come in different types, including digital-only, analog-enabled, and capacitive-touch-enabled, among others. Most digital GPIOs can be configured with internal pull-up or pull-down resistors or set to high impedance.

Which GPIOs are safe to use?

While the ESP32 module offers numerous pins with various functions, some may not be ideal for your projects. Below is a breakdown of which pins are safe to use and which ones require 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.

PinPin LabelGPIOSafe to useReason
4SENSOR_VPGPIO36⚠️Input only GPIO, cannot be configured as output
5SENSOR_VNGPIO39⚠️Input only GPIO, cannot be configured as output
6IO34GPIO34⚠️Input only GPIO, cannot be configured as output
7IO35GPIO35⚠️Input only GPIO, cannot be configured as output
8IO32GPIO32✔️Safe to use
9IO33GPIO33✔️Safe to use
10IO25GPIO25✔️Safe to use
11IO26GPIO26✔️Safe to use
12IO27GPIO27✔️Safe to use
13IO14GPIO14✔️Safe to use
14IO12GPIO12⚠️Must be LOW during boot
16IO13GPIO13✔️Safe to use
17SHD/SD2GPIO9Connected to Flash memory
18SWP/SD3GPIO10Connected to Flash memory
19SCS/CMDGPIO11Connected to Flash memory
20SCK/CLKGPIO6Connected to Flash memory
21SDO/SD0GPIO7Connected to Flash memory
22SDI/SD1GPIO8Connected to Flash memory
23IO15GPIO15⚠️Must be HIGH during boot, prevents startup log if pulled LOW
24IO2GPIO2⚠️Must be LOW during boot and also connected to the onboard LED
25IO0GPIO0⚠️Must be HIGH during boot and LOW for programming
26IO4GPIO4✔️Safe to use
27IO16GPIO16✔️Safe to use
28IO17GPIO17✔️Safe to use
29IO5GPIO5⚠️Must be HIGH during boot
30IO18GPIO18✔️Safe to use
31IO19GPIO19✔️Safe to use
33IO21GPIO21✔️Safe to use
34RXD0GPIO3Rx pin, used for flashing and debugging
35TXD0GPIO1Tx pin, used for flashing and debugging
36IO22GPIO22✔️Safe to use
37IO23GPIO23✔️Safe to use

Input-Only GPIOs

GPIO pins 4, 5, 6, and 7 are designated as input-only pins, meaning they cannot be configured as outputs. These pins are primarily used for digital or analog input functions, or for other specific purposes. Unlike other GPIO pins, they do not have internal pull-up or pull-down resistors.


Interrupts in ESP32

Interrupts are a way for the ESP32 to respond to events while still running its main program. There are two types of interrupts in ESP32: hardware and software.

Hardware Interrupts: These occur in response to an external event, like pressing a key or detecting touch.

Software Interrupts: These are triggered by a software instruction, like a timer or watchdog timer.

ESP32 GPIO Interrupt: We can define a function called an Interrupt Service Routine (ISR) that gets called when a GPIO pin changes.

Attaching an Interrupt: Using the attachInterrupt() function in Arduino IDE, we can set an interrupt on a specific GPIO pin. We provide the pin, ISR function, and trigger mode (e.g., LOW, HIGH, CHANGE, FALLING, RISING).

Detaching an Interrupt: When we no longer want ESP32 to monitor a pin, we use the detachInterrupt() function.

Interrupt Service Routine (ISR): This function is called whenever an interrupt occurs on the GPIO pin. It should be short, fast, and marked with the IRAM_ATTR attribute.

Overall, interrupts are a useful tool for making the ESP32 responsive to external events without interrupting its main program flow.


ADC Pins on ESP32

The ESP32-WROOM-32 module features two ADC (Analog to Digital Converter) blocks: ADC1 and ADC2. Each block has multiple channels:

ADC1: This block contains 6 channels, labeled as ADC1_CH0 and ADC1_CH3 to ADC1_CH7. ADC2: Here, you’ll find 10 channels, labeled as ADC2_CH0 to ADC2_CH9.

The ADCs on the ESP32 can be configured with a resolution of up to 12 bits. This means they can detect 4096 discrete analog levels. With an operating voltage of 3.3 V, this translates to a resolution of 0.0008 volts (or 0.8 mV) per unit.

Note: When Wi-Fi is in use, ADC2 pins are not available for utilization. If you encounter difficulties retrieving values from an ADC2 GPIO while using Wi-Fi, opting for an ADC1 GPIO instead is recommended. This switch should address the issue you’re facing.

DAC Pins

The ESP32-WROOM-32 module features two Digital-to-Analog Converters (DACs), which are essential for converting digital signals into analog voltages. These DACs are particularly useful for tasks that require precise control over analog outputs, such as audio applications or sensor interfacing.

Touch Pins

The ESP32-WROOM-32 module comes equipped with ten capacitive touch-enabled GPIOs, providing the ability to detect touch or proximity. These touch pins are versatile and can be utilized for various applications, ranging from simple touch buttons to more complex gesture recognition systems. They offer a convenient way to implement user interaction features in projects, enhancing the overall user experience.

I2C Pins

The ESP32-WROOM-32 module includes two I2C (Inter-Integrated Circuit) bus interfaces, which enable communication with a wide range of peripheral devices. These pins allow for flexible assignment, meaning any GPIO pin can be configured as the I2C SDA (data line) or SCL (clock line).

This flexibility simplifies hardware design and allows for easy integration of I2C-compatible sensors, displays, and other devices into ESP32-based projects.

If you wish to utilize different pins with the Wire library, you simply need to initialize it by calling:

Wire.begin(SDA, SCL);

ESP32 PWM Pin

Almost all GPIO pins on the ESP32-WROOM-32 module can be configured to generate Pulse Width Modulation (PWM) signals. PWM signals are widely used for controlling the speed of motors, the brightness of LEDs, and other applications that require precise control over output voltage or current. The ESP32’s ability to generate PWM signals with high resolution and adjustable frequency makes it suitable for a wide range of projects, from robotics to LED lighting systems.

When establishing a PWM signal, you must specify the following parameters within your code:

  1. Frequency of the signal
  2. Duty cycle
  3. PWM channel
  4. GPIO to which the signal should be directed.

SPI Pins

The ESP32-WROOM-32 module provides three Serial Peripheral Interface (SPI) interfaces, each offering high-speed communication with external devices such as sensors, displays, and memory chips. These SPI pins offer flexibility in GPIO assignment, allowing developers to choose suitable pins based on their specific project requirements. SPI communication is widely used in IoT applications for data transfer between microcontrollers and peripheral devices, making these pins essential for many projects.

SPI Pin mapping.
The default pin mapping for SPI on the ESP32 is as follows:

For VSPI:

  • MOSI: GPIO 23
  • MISO: GPIO 19
  • CLK: GPIO 18
  • CS: GPIO 5

For HSPI:

  • MOSI: GPIO 13
  • MISO: GPIO 12
  • CLK: GPIO 14
  • CS: GPIO 15

NOTE: Interrupts can be configured for all GPIOs.

UART Pins

The ESP32-WROOM-32 module features three Universal Asynchronous Receiver-Transmitter (UART) interfaces, which facilitate serial communication with various peripherals, such as GPS modules, Bluetooth modules, and serial sensors. These UART pins provide a convenient way to interface with external devices and enable communication for debugging and logging purposes. However, developers should note that UART1 pins are reserved for SPI flash memory, limiting their availability for other purposes.

RTC GPIO Pins

Some GPIO pins on the ESP32-WROOM-32 module are routed to the Real-Time Clock (RTC) subsystem, allowing them to be used for functions such as waking the device from deep sleep. These RTC GPIO pins offer additional functionality beyond standard GPIO pins, making them useful for power-saving features and timing-sensitive applications.

Strapping Pins

The ESP32-WROOM-32 module includes five strapping pins that determine the boot mode of the device upon power-up. Developers should exercise caution when connecting peripherals to these pins to avoid issues during firmware flashing. Proper management of these pins is essential to ensure smooth operation and reliable booting of the ESP32 module.

Power Pins

The power pins on the ESP32-WROOM-32 module provide the necessary voltage for its operation. The 3V3 pin supplies the main voltage, while the GND pin serves as the ground connection. Proper connection and management of these power pins are crucial for ensuring stable and reliable operation of the ESP32 module in various applications.

ENABLE Pin


The Enable (EN) pin serves as the enable control for the 3.3V regulator. Being pulled up, connecting it to ground disables the 3.3V regulator. This configuration allows the use of the EN pin with a pushbutton, for instance, to restart the ESP32.

Regarding GPIO current consumption, each GPIO has an absolute maximum current draw of 40mA, as specified in the “Recommended Operating Conditions” section of the ESP32 datasheet.

Additionally, the ESP32 is equipped with a built-in hall effect sensor designed to detect variations in the magnetic field of its surroundings.

Comment (1)

Leave a Reply

Your email address will not be published.

Need Help?