top of page
Image by Sahand Babali

ESP32 Dev. Kit v1 Pinout

Writer: eMbed WorkshopeMbed Workshop

Updated: Jun 9, 2023


ESP32 Dev. Kit v1 Pinout

The ESP32 is a powerful, low-cost Wi-Fi SoC (System on a Chip) that can be used to create a wide variety of connected devices. It has a number of advantages over its predecessor, the ESP8266, including:

· More GPIOs (General Purpose Input/Output)

· Faster processor

· More memory

· Built-in Bluetooth

· Support for dual-mode Wi-Fi (802.11b/g/n and 802.11ac)


One of the most significant advantages of the ESP32 is that it has 34 GPIOs, which is significantly more than the ESP8266, which only has 17 GPIOs. This means that you have more flexibility when designing your projects, as you won't have to juggle or multiplex your IO pins. However, it is important to note that not all of GPIOs are created equal. Some of the GPIOs are used for specific purposes, such as the power button, the reset button, and the touch sensors. It is important to read the pinout carefully before you start using the GPIOs.

The ESP32 is a powerful and versatile SoC that can be used to create a wide variety of connected devices. It is a great choice for developers who are looking for a powerful and affordable Wi-Fi SoC with a lot of GPIOs.


ESP32 Peripherals


Despite the fact that the ESP32 has 48 GPIO pins in total, only 25 of them are connected to the pin headers on both sides of the development board. These pins can be allocated to a number of peripheral functions, such as:



ESP32 pins
ESP32 pins


Because of the ESP32's pin multiplexing functionality, many devices can share a single GPIO pin. A single GPIO pin, for example, can function as an ADC input, DAC output, or touchpad.


ESP32 Pinout


The ESP32 DevKit V1 development board includes a total of 30 pins. Pins with comparable functionality are grouped together for convenience. The figure below is the detailed pinout of the ESP32 30-pin model, which includes all of its peripherals, which we will go through one by one.



ESP32 pinout


GPIO Pins


The ESP32 development board features 25 GPIO pins that may be programmed to perform various activities. There are several types of GPIOs, such as digital-only, analog-enabled, capacitive-touch-enabled, and so on. Analog and capacitive-touch GPIOs may both be set as digital GPIOs. Most of these digital GPIOs may be tuned to high impedance or customized with internal pull-up or pull-down.

As previously stated, the ESP32 has a total of 48 pins, of which only 30 are accessible to users. Each of these 30 General purpose input output pins has a distinct purpose and may be programmed using a specific register. There are several GPIO pins such as UART, PWM, ADC, and DAC.



ESP32 gpio pin

Some of these 30 pins are power, while others may be set as both input and output, while yet others are input only.


Input/Output Pins


Almost all GPIO pins may be set as input and output, with the exception of six Serial peripheral interfaces (SPI) flash pins, which cannot be configured as input or output. The 36-pin version board has these 6 SPI pins.

The table below describes the state of the ESP32 GPIO pins that can be used as input and output:

OK indicates that the associated pin can be used as an input or output.




ESP32 gpio pins


ESP32 gpio pins


Which ESP32 GPIOs are safe to use ?


Although the ESP32 contains a large number of pins with varied functionalities, some of them may be incompatible with your designs. The table below illustrates which pins are safe to use and which should be avoided.



ESP32 pins safe to use


ESP32 pin safe to use

The graphic below illustrates which GPIO pins are safe to utilize


ESP32 pins

Input Only GPIOs


Because GPIO pins 34–39 are intended for input, they cannot be set as output. Because there is no internal pull-up or pull-down resistor, it can only be used as an input.

In addition, GPIO 36(VP) and GPIO 39(VN) are utilized in the ESP32 ADC for ultra-low noise preamplifiers.

To recap, the ESP32's input-only pins are as follows:

· GPIO 34

· GPIO 35

· GPIO 36

· GPIO 39


ESP32 input only pins


Interrupt Pins


All GPIO pins in ESP32 can take external interrupts. This helps to monitor change at a specific interrupt instead of continuously monitoring. Interrupts can be a powerful tool for improving the responsiveness of your ESP32 application. By using interrupts, you can free up the main processor to perform other tasks while the ISR handles any events that occur on the interrupt pins.



ESP32 interrupt pins


RTC GPIO Pins


The ESP32 has a set of GPIO pins that can be used to wake it up from deep sleep mode. These pins are called RTC GPIOs, and they are routed to the RTC low-power subsystem. When the ESP32 is in deep sleep mode, the ULP co-processor can monitor these pins for changes. If any of the pins change state, the ULP co-processor will wake up the main processor.

The following GPIOs can be used as RTC GPIOs:


RTC GPIOs can be used to wake the ESP32 from deep sleep mode to perform a variety of tasks, such as reading sensor data, sending a message, or controlling a device. By using RTC GPIOs, you can extend the battery life of your ESP32 projects.

ESP32 RTC pins


ADC Pins


The ESP32 board features two integrated 12-bit SAR ADCs, enabling the measurement of analog input from various sensors. It provides support for 15 analog-enabled channels, which are divided into two categories: channel 1 and channel 2. Not all pins within these channels are always available for ADC input. With a resolution of 12 bits, the ADC can detect 4096 discrete analog levels, converting input voltages ranging from 0 to 3.3V into integer values from 0 to 4095. The ADC resolution and channel range can be dynamically set through programmable configuration.

Examine your board and identify the ADC pins as noted in the figure below :



ESP32 ADC pins



ESP32 warning



ESP32 pins

How to Use ESP32 ADC


The ESP32 ADC functions similarly to the Arduino ADC, with the exception that it features a 12-bit ADC. As a result, the ESP32 board converts analog voltage values from 0 to 4095 into digital discrete values.


ESP32 ADC

· If the voltage applied to the ESP32 ADC is 0, the digital value of the ADC channel will be zero.

· If the highest voltage applied to the ADC is 3.3V, the output digital value will be 4095.

· The voltage divider method may be used to measure greater voltages.



NOTE :

The ESP32 ADC is set to 12-bit by default, although it may be configured to 0-bit, 10-bit, or 11-bit. The 12-bit default ADC can measure values up to 4096 and has an analog voltage range of 0V to 3.3V.


ESP32 ADC Limitation


Here are some of the ESP32 ADC's limitations:

· The ESP32 ADC cannot directly measure voltages above 3.3V.

· ADC2 cannot be utilized while Wi-Fi drivers are activated. ADC1 may only be utilized with 8 channels.

· The ESP32 ADC is not particularly linear; it exhibits non-linearity and cannot differentiate between 3.2V and 3.3V. However, the ESP32 ADC may be calibrated.


On the serial monitor of the Arduino IDE, the nonlinear behavior of the ESP32 may be noticed.


ESP32 voltage graph

DAC Pins


The ESP32 has two 8-bit DAC (Digital to Analog converter) onboard. Any digital signal may be converted to analog using the ESP32 DAC pins. Voltage and PWM control are two applications for DAC pins. It can be used as a “Digital Potentiometer” to control analog devices.

The two DAC pins on the ESP32 board are shown below.


ESP32 DAC pins

Because these DACs have an 8-bit resolution, values ranging from 0 to 256 are converted to analog voltages ranging from 0 to 3.3V.


ESP32 warning


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 ESP32 board contains 16 independent pulse width modulation (PWM) channels that can output different PWM signals. Almost all GPIOs can generate a PWM signal however the input-only pins 34,35,36,39 cannot be used as PWM pins as they cannot output a signal.



ESP32 pwm pins

PWM timers, the PWM operator, and a specialized capturing sub-module comprise the PWM controller. Each timer provides synchronous or independent timing, and each PWM operator produces a waveform for a single PWM channel. The dedicated capture sub-module can capture events with external time properly.


NOTE :

Onboard 6 SPI flash integrated pins (GPIO 6, 7, 8, 9, 10, 11) on the 36-pin ESP32 cannot be utilized as PWM.


I2C Pins


The ESP32 board has a single I2C bus that can support up to 120 I2C devices. SDA and SCL SPI pins are defined by default at GPIO 21 and 22, respectively. We may, however, configure any GPIO as an I2C interface using the command wire.begin(SDA, SCL).

The following two GPIO pins are by default set for I2C:

· GPIO21 – SDA (Data pin)

· GPIO22 – SCL (Clock Synchronization pin)



ESP32 i2c pins

I2S Pins


I2S (Inter-IC Sound) is a synchronous communication protocol used to send audio signals serially between two digital audio devices. The ESP32 includes two I2S peripherals, each of which runs in half-duplex mode but can be combined to operate in full-duplex mode.

Normally, the ESP32's two DAC pins are utilized for I2S audio communication. The ESP32's I2S pins are as follows :


· Serial Clock (SCK) GPIO 26

· Word Select (WS) GPIO 25

We can configure any GPIO pin for I2S Serial Data (SD) pins.



SPI Pins


The ESP32 microcontroller includes four SPI peripherals :


· SPI0: Cannot be used externally; can only be used internally.

· SPI1: Cannot be utilized with SPI devices externally. Only for communication within the internal memory

· SPI2: SPI2 and HSPI are both capable of communicating with external devices and sensors. It features three distinct bus signals, each of which can operate three slave devices.

· SPI3 or VSPI: These interfaces can communicate with external devices and sensors. It features three distinct bus signals, each of which can operate three slave devices.


Most ESP32 boards include pre-assigned SPI pins for SPI2 and SPI3. However, if SPI pins are not assigned, we can always assign them in code. The following are the pre-assigned SPI pins present on most ESP32 boards :


ESP32 communication


ESP32 communication pins

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 functional SPI interfaces, and the embedded flash memory chip uses the third SPI bus. In standard libraries, VSPI pins are commonly used.


ESP32 warning

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 features three UART connections by default: UART0, UART1, and UART2. Both UART0 and UART2 can be used externally, but UART1 cannot be used for external interfacing or communication because it is internally coupled to integrated SPI flash memory



ESP32 uart pins

· UART0 is enabled by default on ESP32's GPIO1 (TX0) and GPIO3 (RX0). This pin is attached to the USB-to-Serial converter internally and is used by the ESP32 for serial communication via the USB port. We will be unable to interface with the PC if we use UART0 pins. As a result, using UART0 pins externally is not recommended.


· UART2 on the other hand is not internally attached to the USB-to-Serial converter, therefore it can be used for external interfacing for UART communication between devices and sensors.


· Because UART1 is internally coupled with flash memory, do not use GPIO pins 9 and 10 for external UART connection.


NOTE :

The ESP32 chip supports multiplexing, which means that different pins can be used for communications. For example, we can configure any GPIO pin in the ESP32 for UART1 connection by declaring it inside the Arduino code.


Following is the UART pins of ESP32 :


ESP32 uart pins


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


Capacitive Touch Pins


The ESP32 includes 10 GPIO pins with capacitive touch sensor capability. Any change in electrical charge can be detected using these pins. These pins function as a touch pad, detecting input from a human finger or any other touch interrupt.

We can also use these pins to create an external wakeup source for the ESP32 from deep sleep state.

Following are the touch sensor pins in ESP32 board :


ESP32 touch pins

Touch_1 pin is missing in this version of ESP32 (30 pin) board. Touch_1 pin is at (GPIO0) which is present in the 36-pin ESP32.


You can construct a touch pad by connecting these pins with any conducting substance, such as aluminum foil, conductive cloth, conductive paint, and so on. Because of the circuit's low-noise design and great sensitivity, relatively compact pads may be created.





Strapping Pins


The ESP32 includes strapping pins that let it to enter various modes such as bootloader or flashing mode. Most boards with built-in USB-Serial don't require us to care about these pins because the board itself places the ESP32 in the appropriate mode, either flashing or booting.

However, if these pins are in use, uploading fresh code, changing firmware, or resetting the ESP32 board may be difficult.


Below are the ESP32 strapping pins available:


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



ESP32 pins

If you connect peripherals to these pins, you may have problems uploading new code or flashing the ESP32 with new firmware because the peripherals prohibit the ESP32 from entering the right mode.


Pins High at BOOT


When outputs are attached to some GPIO pins, they exhibit unexpected behavior because these pins show a HIGH state or create a PWM signal when the ESP32 board is booted or reset.

These pins are:

· GPIO 1

· GPIO 3

· GPIO 5

· GPIO 6 to GPIO 11 (interfaced with ESP32 internal SPI flash– Do Not use these pins for any other purpose).

· GPIO 14

· GPIO 15


Enable (EN) Pins


This pin is used to turn the ESP32 board on. We may use this to regulate the ESP32 voltage regulator. When this pin is pulled HIGH, the chip is enabled, and when it is pulled LOW, the ESP32 operates at low power



ESP32 enable pins

By connecting the EN (enable) pin to GND, we deactivate the 3.3V on-board voltage regulator. The EN pin is also connected to a pushbutton switch that can pull the pin LOW and trigger a reset.

Power Pins

The ESP32 supports several power input sources. The VIN (Vin) pin and the 3V3 (3.3V) pin are the two main powering pins for the ESP32. The USB cable is the primary source of power for the ESP32. The other two sources required a regulated external supply.


ESP32 voltage pins



The ESP32 includes an on-board voltage regulator with an output voltage of 3.3V that accepts input from two sources: USB and the VN pin, and then transforms the input voltage (5V) to 3.3V to allow the ESP32 to function.


The three power sources for the ESP32 are as follows:

· USB Port: Can only provide power to the ESP32.

· VIN PIN: It has dual input and output capabilities.

· 3V3 PIN: Works as both an input and an output.



NOTE :

Because the ESP32's 3V3 pin is not connected to the on-board voltage regulator, using it for power input is not recommended because a minor increase in voltage may result in higher current flowing from the output terminal of the LDO regulator (AMS1117) to the input, resulting in permanent damage to the ESP32 voltage regulator.


However, if you have constant 3.3V supply then it can be used.

Secondly, do not give more than 9V to the VN pin as ESP32 only needs 3.3V for working; all remaining voltages will be dissipated as heat.



Article by Raveen Pabasara

eMbed Workshop

Comments


bottom of page