A Comprehensive to ESP32 Pinout Diagram

Published:2024-07-02

Prof. David Reynolds stands as a luminary in the field of electrical engineering, renowned for his expertise in integrated circuits. Holding a distinguished position as a Professor of Electrical Engineering, Prof. Reynolds earned his acclaim through decades of research, teaching, and industry collaboration.

The ESP32 is a versatile system on a chip (SoC) that has been integrated into numerous IoT applications due to its dual-core processor, low power consumption, and robust connectivity options. Notably, it features built-in Wi-Fi and Bluetooth capabilities, a wide range of GPIOs, and support for various communication protocols, including I2C, SPI, and UART. It operates at a core frequency of up to 240 MHz and is highly admired for its ability to support a wide range of peripherals.

ESP32-based boards vary in design, each featuring distinct shapes, sizes, and pin configurations. Not every pin on an ESP32 Microcontroller SoC is accessible on a development board, as certain pins may be exclusively assigned specific functions.

A common instance involves Flash Memory; typically, all ESP32 boards are equipped with 4 MB of Flash Memory for storing programs. Consequently, about six GPIO Pins are linked to the SPI Flash IC, rendering these pins unusable for general GPIO tasks.

 

 

Understanding the pinout of commonly used ESP32 boards is crucial. The pinout configuration is essential for connecting and interacting with various peripherals and sensors, which is pivotal for both designing and troubleshooting electronic circuits. Familiarity with the pinout can aid in:

  • Efficient Circuit Design: Identifying the correct pins for particular functions can streamline the development phase, saving time and minimizing mistakes.
  • Enhancing Performance: Certain pins are better suited for specific operations, and their proper utilization can improve both the performance and reliability of your application.
  • Avoiding Damage: Misusing pins, particularly concerning voltage and current specifications, can cause irreversible damage to the ESP32. Understanding the pinout is, therefore, vital to safeguard your investment and extend the lifespan of your project.

This knowledge will clarify which pins are at your disposal for various projects. In this comprehensive guide, we will delve into the pinout information of ESP32; we'll also explore key peripherals of the ESP32 Microcontroller along with their corresponding pins and determine which GPIO pins you can utilize in your project.

 

ESP32 Peripherals

The ESP32 includes a variety of peripherals:

  • 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 and DAC features are assigned to specific static pins. However, you can configure which pins serve as UART, I2C, SPI, PWM, and other functions through the code, thanks to the ESP32 chip's multiplexing capability.

While you can define the pin properties in software, some pins have default assignments, as shown in the following example for the ESP32 DEVKIT V1 DOIT board with 36 pins (pin locations may vary by manufacturer).

Moreover, certain pins have unique features that make them more or less suitable for specific projects. The table below indicates the best pins to use as inputs and outputs and highlights which ones require caution.

  • Green: Safe to use
  • Yellow: Usable but may have unexpected behavior, especially at boot
  • Red: Not recommended for use as inputs or outputs

 

 

Understand ESP32 Pinout

 

 

GPIO Pins

General-Purpose Input/Output (GPIO) pins are versatile and can be configured as either input or output. They can be used for a variety of digital and analog functions, such as reading sensor data or controlling LEDs.

 

Power Pins

Power pins provide the necessary voltage and ground connections to power the ESP32 and any connected peripherals. The primary power pins include VCC (3.3V) and GND (ground).

 

Communication Pins

The communication pins facilitate serial communication between the ESP32 and other devices. Key communication protocols supported by the ESP32 include:

  • UART (Universal Asynchronous Receiver-Transmitter): Used for serial communication with other devices.
  • SPI (Serial Peripheral Interface): Enables high-speed communication with peripherals like sensors and displays.
  • I2C (Inter-Integrated Circuit): Allows communication with multiple devices using only two pins.

 

Special Function Pins

Special function pins offer additional capabilities beyond basic input/output. These include:

  • PWM (Pulse Width Modulation) Pins: Used for controlling devices like motors and LEDs with precise timing.
  • Touch Sensor Pins: Enable capacitive touch sensing for creating touch-sensitive interfaces.
  • RTC (Real-Time Clock) Pins: Provide time-keeping functionality for applications requiring accurate time tracking.

 

ESP32 GPIO Pins

The ESP32 development board features 25 GPIO pins, which can be assigned various functions by programming the appropriate registers. These GPIOs include several types: digital-only, analog-enabled, and capacitive-touch-enabled. Analog-enabled and capacitive-touch-enabled GPIOs can also be configured as digital GPIOs. Most of these digital GPIOs can be set with internal pull-up or pull-down resistors or configured to high impedance.

 

ESP-WROOM-32 pinout

 

Input Only GPIOs

GPIOs 34 to 39 are input-only pins (GPIs). These pins lack internal pull-up or pull-down resistors and cannot be used as outputs. Therefore, they should be used exclusively as inputs:

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

 

SPI flash integrated on the ESP-WROOM-32

GPIO 6 to GPIO 11 are available on some ESP32 development boards, but they are connected to the integrated SPI flash on the ESP-WROOM-32 chip. Therefore, these pins are not recommended for other uses and should be avoided 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)

 

ESP32 Interrupt Pins

The ESP32 supports up to 32 interrupt slots for each core, with each interrupt having a specific priority level and falling into two categories.

  1. Hardware interrupts: These are triggered by external events, such as a GPIO interrupt when a button is pressed or a touch interrupt when a touch is detected.
  2. Software interrupts: These are triggered by software instructions, like a timer interrupt or a watchdog timer interrupt when a timer expires.

On the ESP32, we can define an interrupt service routine function that executes when a GPIO pin changes its logic level.

All GPIO pins on an ESP32 board can be configured to function as inputs for interrupt requests.

 

Capacitive touch GPIOs

The ESP32 features 10 internal capacitive touch sensors that can detect changes in capacitance, such as those caused by human skin contact. These sensors can sense variations induced when touching the GPIOs with a finger. They are versatile for integrating into capacitive pads and replacing mechanical buttons. Moreover, these capacitive touch pins are capable of waking up the ESP32 from deep sleep.

Here are the GPIO connections for these internal touch sensors:

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

 

ESP32 Analog to Digital Converter (ADC)  Pins

The ESP32 features 18 ADC input channels, each capable of 12-bit resolution, a significant upgrade from the ESP8266's single 10-bit ADC channel. These GPIOs serve as ADC inputs with 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)

The ADC input channels of the ESP32 feature a 12-bit resolution, allowing analog readings from 0 to 4095. Here, 0 corresponds to 0V, and 4095 corresponds to 3.3V. You can adjust the resolution and ADC range in your code as needed.

It's important to note that the ADC pins on the ESP32 do not exhibit linear behavior. Small voltage differences, such as between 0 and 0.1V or between 3.2V and 3.3V, may not be distinguishable. This characteristic should be considered when utilizing the ADC pins, as illustrated in the figure below.

 

 

ESP32 Digital to Analog Converter Pins

The ESP32 features two 8-bit DAC channels that convert digital signals into analog voltage outputs. These channels are designated as follows:

  • DAC1 (GPIO25)
  • DAC2 (GPIO26)

 

ESP32 Touch Pins

The ESP32 features 9 GPIOs equipped with capacitive touch sensing. These GPIOs can detect changes in capacitance when a capacitive load, like a human finger, approaches the GPIO.

 

 

You can create a touchpad by connecting various conductive materials to these pins, such as aluminum foil, conductive cloth, or conductive paint. Due to the circuit's high sensitivity and low-noise design, even small touch pads can be effectively implemented.

Moreover, these capacitive touch pins can serve the function of waking the ESP32 from deep sleep mode.

 

ESP32 I2C Pins

The ESP32 provides two I2C channels, and you can assign any pin as either SDA or SCL. When programming the ESP32 with the Arduino IDE, the default pins for I2C communication are:

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

If you prefer to use different pins with the wire library, you simply need to initialize them by calling:

Wire.begin(SDA, SCL);

 

ESP32 SPI Pins

The default pin mapping for SPI is as follows:

SPI MOSI MISO CLK CS
VSPI GPIO 23 GPIO 19 GPIO 18 GPIO 5
HSPI GPIO 13 GPIO 12 GPIO 14 GPIO 15

 

ESP32 UART Pins

The ESP32 development board features three UART interfaces: UART0, UART1, and UART2, supporting asynchronous communication (RS232 and RS485) and IrDA at speeds up to 5 Mbps.

  • UART0's pins are dedicated to the USB-to-Serial converter and are primarily used for flashing and debugging purposes, making them less suitable for general use.
  • UART1's pins are specifically allocated for the integrated flash memory chip.
  • UART2, however, is ideal for interfacing with UART-compatible devices such as GPS modules, fingerprint sensors, distance sensors, and others.

Additionally, UART provides hardware management for CTS and RTS signals, as well as software flow control using XON and XOFF protocols.

 

ESP32 PWM Pins

The ESP32 LED PWM controller features 16 independent channels capable of generating PWM signals with various configurations. All GPIO pins configured as outputs can serve as PWM pins, except for GPIOs 34 to 39.

To configure a PWM signal, you must specify these parameters in your code:

  • Signal frequency
  • Duty cycle
  • PWM channel
  • GPIO where the signal should be output

 

ESP32 RTC GPIO Pins

 

 

The ESP32 includes support for RTC GPIOs. These GPIOs are connected to the RTC (Real-Time Clock) low-power subsystem, enabling their use during deep sleep modes. RTC GPIOs can function as wake-up sources for the ESP32, particularly when the Ultra Low Power (ULP) co-processor is active. The following GPIOs can serve as external wake-up sources:

  • 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 Strapping Pins

The ESP32 chip includes specific strapping pins:

  • GPIO 0 (must be LOW to enter boot mode)
  • GPIO 2 (must be floating or LOW during boot)
  • GPIO 4
  • GPIO 5 (must be HIGH during boot)
  • GPIO 12 (must be LOW during boot)
  • GPIO 15 (must be HIGH during boot)

These pins are essential for putting the ESP32 into bootloader or flashing mode. Most development boards equipped with built-in USB/Serial manage these pins automatically for flashing or boot operations. More details on ESP32 Boot Mode Selection can be found here.

However, if external peripherals are connected to these pins, it can hinder uploading new code or flashing firmware to the ESP32 or even cause issues with board resets. If you encounter difficulties uploading code or flashing the ESP32 and have peripherals connected to these strapping pins, these peripherals are likely preventing the ESP32 from entering the correct mode.

 

Pins HIGH at Boot

Certain GPIOs change their state to HIGH or output PWM signals during boot or reset. If you have connected outputs to these GPIOs, you may experience unexpected behavior when the ESP32 resets or boots.

These GPIOs include:

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

 

ESP32 Power Pins

The ESP32 features two power pins: the VIN pin and the 3V3 pin. You can use the VIN pin to directly supply power to the ESP32 and its peripherals with a regulated 5V source. The 3V3 pin serves as the output from the built-in voltage regulator, capable of delivering up to 600mA. Additionally, GND serves as the ground pin.

 

ESP32 Enable Pin

The Enable (EN) pin controls the 3.3V regulator. It is configured with a pull-up resistor, so linking it to the ground will deactivate the 3.3V regulator. Consequently, you could connect this pin to a pushbutton to reset your ESP32, as an example.

 

GPIO Current Drawn

According to the "Recommended Operating Conditions" detailed in the ESP32 datasheet, the maximum current that each GPIO can draw is capped at 40mA.

 

Which GPIO Pins Should You Use?

While the ESP32 features numerous pins that serve a variety of functions, not all of them may be appropriate for your projects. The table below categorizes the pins into three groups for your reference:

  • Pins that are completely safe for use should be your first choice.
  • Some pins require careful consideration as their behavior, especially during boot, may be inconsistent. Employ these only when crucial.
  • It is advisable to steer clear of using certain pins.

The diagram presented below identifies the GPIO pins that are safe for use.

 

 

Pinout Diagram Variations

 

ESP32 DevKit

The ESP32 DevKit is one of the most popular development boards for the ESP32 microcontroller. It offers a comprehensive pinout diagram that includes:

  • Power Pins: VCC (3.3V) and GND for power supply.
  • GPIO Pins: General-purpose input/output pins that can be used for various digital and analog functions.
  • Communication Pins: Includes UART, SPI, and I2C pins for serial communication.
  • Analog Pins: ADC (Analog-to-Digital Converter) pins for reading analog signals.
  • Special Function Pins: PWM (Pulse Width Modulation), touch sensor, and RTC (Real-Time Clock) pins.

 

ESP32-WROOM-32

The ESP32-WROOM-32 module is another widely used variant known for its compact size and robust functionality. Its pinout diagram includes the following:

  • Power Pins: Similar to the DevKit, with VCC (3.3V) and GND.
  • GPIO Pins: A variety of GPIO pins are available for digital and analog functions.
  • Communication Pins: UART, SPI, and I2C pins for seamless serial communication.
  • Analog Pins: Multiple ADC pins for precise analog input reading.
  • Special Function Pins: Additional features like PWM, touch sensors, and RTC pins.

 

Other ESP32 Variants

There are several other ESP32 variants, each with its unique pinout configuration. Some of these include:

  • ESP32-S2: Offers more secure features and additional pins for extended functionalities.
  • ESP32-C3: Known for its lower power consumption and RISC-V architecture.
  • ESP32-S3: Provides enhanced AI capabilities and more GPIO pins.
  • ESP32-PICO-D4: A compact module integrating the ESP32 with essential peripherals.

 

Each variant has its specific pinout diagram, designed to cater to different applications and project requirements. Understanding the pinout variations helps in selecting the right ESP32 model for your specific needs.

 

ESP32 Built-In Hall Effect Sensor

The ESP32 microcontroller stands out for its diverse range of functionalities, one of which includes a built-in Hall effect sensor. This sensor is particularly useful for detecting changes in the magnetic field surrounding the device. The Hall effect sensor operates by outputting a voltage in response to magnetic fields. When a magnetic object comes into proximity to the sensor, it disrupts the local magnetic field, and the sensor modulates its output voltage accordingly. This feature can be applied in various practical applications, including:

 

  1. Position Sensing: The Hall effect sensor can help in determining the position of a magnet relative to the sensor, which is useful in creating non-contact switches and position markers in various applications like robotic arm positioning or automated door mechanisms.
  2. Speed Detection: By measuring the frequency of the voltage changes caused by a magnetic field, it's possible to determine the speed of a rotating object equipped with magnets. This is commonly used in automotive speedometers and fitness equipment to track revolutions per minute (RPM).
  3. Current Sensing: Another significant application is in current measurement devices. Since a current flowing through a conductor creates a magnetic field, the Hall effect sensor can be used to non-invasively measure the current without direct electrical contact, enhancing safety and convenience in electrical testing and monitoring systems.
  4. Security Systems: The Hall effect sensor in the ESP32 can be utilized to develop security and safety systems, such as door and window sensors in home security systems. It can detect the presence or absence of a magnetic field created by small magnets placed in door frames, which helps in monitoring access points.
  5. Consumer Electronics: In consumer electronics, such as smartphones and tablets, Hall effect sensors help in detecting the closing and opening of flip covers, turning certain functions on or off based on the cover's position.

 

 

Integrating the ESP32 with its Hall effect sensor into your projects is facilitated by the ESP-IDF (Espressif IoT Development Framework) or the Arduino platform, which provides libraries and functions to read values from the sensor easily. This capability allows developers and hobbyists to innovate with magnetic field detection in their projects, expanding the possibilities of what they can build with the ESP32.

 

Practical Applications and Projects

 

Setting Up Your ESP32

Basic Setup and Configuration

  • Power Supply: Connect the ESP32 to a power source, typically via a USB cable connected to your computer.
  • Driver Installation: Install the necessary drivers for your operating system to recognize the ESP32.
  • Development Environment: Set up your Integrated Development Environment (IDE), such as Arduino IDE or ESP-IDF (Espressif IoT Development Framework).
  • Programming the ESP32: Write and upload your first program, often starting with a simple "Hello, World!" or LED blink program.

 

Essential Tools and Software

  • USB Cable: To connect the ESP32 to your computer for programming and power.
  • Breadboard and Jumper Wires: For prototyping and testing circuits.
  • Sensors and Actuators: Depending on your project needs, these include temperature sensors, LEDs, motors, etc.
  • IDE and Libraries: Install the necessary IDE (e.g., Arduino IDE) and libraries specific to the ESP32 to streamline development.

 

 

Common ESP32 Projects

Home Automation

  • Smart Lighting: Control lights remotely using Wi-Fi or Bluetooth.
  • Security Systems: Set up motion detectors and cameras to monitor your home.
  • Appliance Control: Automate household appliances like fans, air conditioners, and coffee makers.

 

IoT Devices

  • Environmental Monitoring: Use sensors to track temperature, humidity, air quality, etc.
  • Smart Agriculture: Implement soil moisture sensors and automated irrigation systems.
  • Connected Wearables: Develop devices that can monitor health metrics and connect to smartphones.

 

Wearable Technology

  • Fitness Trackers: Measure steps, heart rate, and other fitness-related data.
  • Health Monitoring: Devices that track vital signs like blood pressure and glucose levels.
  • Smart Clothing: Integrate sensors into clothing for various applications, from health monitoring to interactive fashion.

 

Final Words

Exploring the ESP32 pinout diagram opens up a world of possibilities in electronics and IoT development. Whether you're a hobbyist or a professional, mastering the pinout configuration allows you to:

  • Create Innovative Projects: Build home automation systems, IoT devices, wearable technology, and more.
  • Optimize Performance: Proper pin configuration enhances the efficiency and reliability of your ESP32-based applications.

Continue to experiment with different configurations, explore new projects, and leverage the versatility of the ESP32 microcontroller. Stay updated with the latest developments in ESP32 variants and expand your skills in electronics and embedded systems.

By applying your pinout knowledge creatively, you can unlock endless possibilities for innovation and problem-solving in the field of electronics and beyond.

 

Read More

Get Instant Online Quote

FAQ

  • What are the input pins of ESP32?

    The ESP32 chip is equipped with 34 physical GPIO pins, labeled GPIO0 through GPIO19, GPIO21 through GPIO23, GPIO25 through GPIO27, and GPIO32 through GPIO39. Each of these pins can function as a general-purpose input/output, or they can be linked to an internal peripheral signal.

  • What are the analog pins of ESP32?

    The ESP32 features multiple pins designated as ADC (Analog-to-Digital Converter) pins. These include pins 0, 2, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, and 39, all of which can function as analog inputs.

  • How do you power ESP32 with pins?

    To power the ESP32, connect a power source to the Vin pin; this setup will be functional. You have the option to hook up a battery, such as an 18650 cell, to the same pin. Ensure the power supply delivers a steady 5V to the ESP32's Vin pin, from which the ESP32 will draw the necessary current. Typically, the ESP32 boards require a minimum of 1A, as their current consumption can range from 0.250A to 0.750A at peak levels.

  • Can the ESP32 pin only be input?

    On the ESP32, GPIO34, 35, 36, and 39 are designated solely for input functions and do not support output operations. The ESP32 features an integrated GPIO Matrix, allowing various peripheral interfaces to be connected to any available pins. This flexibility means that in hardware designs, specific functions do not necessarily have to be assigned to particular pins.

  • How many pins does the ESP32 Wroom have?

    The ESP32 Wroom 30-pin microcontroller features nine touch-sensitive pins. These are labeled from Touch 0 to Touch 9, with the exception of Touch 1, which is absent in this 30-pin model.

  • How can I safely test pin configurations on an ESP32?

    To safely test pin configurations on an ESP32:

    • Use a Multimeter: Verify pin output voltages and continuity to ensure connections are correct before powering up the system.
    • Start with a Blink Test: Program the ESP32 to toggle a GPIO pin and use this to test connectivity and response.
    • Incremental Build-Up: Add components one at a time and test each stage rather than setting up the entire circuit at once.
    • Utilize Pull-Up/Pull-Down Resistors: These can help stabilize pin states during testing.
    • Isolation and Protection: Consider using optocouplers or similar devices to protect the ESP32 from potential shorts or voltage spikes during experiments.

  • What is the maximum current rating for ESP32 GPIO pins?

    3.3V.

  • Are there any community resources or tools to help with ESP32 development?

    Numerous community resources and tools exist for ESP32 development: ESP-IDF, Arduino Core for ESP32, GitHub, the ESP32.com forum, and Reddit offer vast community support, etc.

Still, need help? Contact Us: [email protected]

You need to log in to reply. Sign In | Sign Up

Please enter your content

Subscribe to our communication service and stay in real-time sync with the latest updates on our website