Wednesday, 17 February 2021

ESP32 Pinout | ESP-WROOM-32 Pinout

In this tutorial, we will learn about the pinout information of ESP32. The 30-pin ESP32 Development Board will be used to demonstrate the ESP32 Pinout. We will also learn about some important peripherals of ESP32 Microcontroller and their associated pins, what GPIO pins can be used in your project.

ESP32-Development-Board

Why do we need to learn ESP32 Pinout?

ESP32 based boards come in a variety of shapes and sizes and pinout of each board is different to other. Also, not all pins of the ESP32 Microcontroller SoC will be available on a development board as some pins might be permanently tied to a dedicated function.

One such case is the Flash Memory. We know that all ESP32 boards come with 4 MB of Flash Memory to store the programs. So, some of the GPIO Pins (6 to be specific) are connected to SPI Flash IC and those pins cannot be used as regular GPIO Pins.

Hence, it is important to understand the pinout of popular ESP32 boards so that you will know what pins are available for use in projects.

Introduction to ESP32 Pin Layout

The ESP32 Microcontroller IC is available in a 48-pin QFN package. Since it is a QFN (Quad Flat No Leads) package, it is difficult solder the IC on to the PCB, if you are interested in making an ESP32 Board by yourself.

ESP32-Pin-Layout

So, what Espressif Systems (the developers of ESP32) did is, they took the ESP32 IC and made a small module board with edge castellations. One popular version of such module board is called ESP-WROOM-32.

In addition to the ESP32 IC, the ESP-WROOM-32 also contain a 4 MB SPI Flash IC, a 40 MHz Crystal Oscillator, PCB Antenna and some discrete passive components to make a working system.

ESP-WROOM-32

 

You can use this board in your hardware design (as it takes care of the complex RF section of the PCB) and make a development board or a breakout board or even a commercial product.

This is what third-party module manufacturers do. They take the ESP-WROOM-32 Module, design a break-out board based on this module with user friendly pins, USB Port, RESET and BOOT switches etc.

Getting-Started-with-ESP32

ESP-WROOM-32 Pinout

Let us start exploring the ESP32 Pinout by taking a look at the ESP WROOM 32 Pinout. The following image show the pinout of a typical ESP-WROOM-32 Module. It consists of 38-pin (14 pins on each long edge and 10 on bottom short edge).

ESP-WROOM-32-Pinout

The other short edge is left for PCB Antenna. If you notice the previous ESP-WROOM-32 image, then the Microcontroller and other components are not visible as they placed under the RF Shield.

Use this pinout of ESP-WROOM-32 module as a reference if you are using such module in your hardware design.

ESP32 Pinout

One popular ESP32 Development Board available today is the 30-pin version shown in the above image. It consists of ESP-WROOM-32 as the baseboard and additionally few pins and components to easily interact with ESP32.

The following image shows the pinout of a 30-pin ESP32 DevKit Development Board.

ESP32-Pinout

As you can see from the image, each pin has more than one possible functionality and while using a pin for particular task, double check its alternative functions.

Another version of ESP32 DevKit Board comes with 36-pins. This version is not as popular as the 30-pin version. But if you happen to have a 36-pin ESP32 board, the following pinout will be very helpful.

Note that the pinout of both the 30-pin and the 36-pin versions of ESP32 Development Boards are very identical except for some pins at the bottom. In the 36-Pin version, 6 GPIO pins (GPIO6 to GPIO11) are used for SPI Flash IC. So, they shouldn’t be used for other purposes. Finally, you just get one extra pin (GPIO0 – Pin 23).

ESP32-36-Pin-Pinout

Important ESP32 Peripherals

Now that we have seen a little bit about ESP32 Pinout. Let us now focus on some of the important peripherals of ESP32 and their associated pins. ESP32 Microcontroller has:

  • 34 Programmable GPIOs
  • 18 12-bit ADC Channels
  • 2 8-bit DAC Channels
  • 16 PWM Channels
  • 3 UART Interfaces
  • 3 SPI Interfaces
  • 2 I2C Interfaces
  • 2 I2S Interfaces
  • 10 Capacitive Touch Sensing GPIOs
  • 16 RTC GPIOs

GPIO

The most commonly used peripheral is the GPIO. ESP32 has 34 GPIO pins with each pin carrying out more than one function (only one will be active). You can configure a pin as either a GPIO or an ADC or an UART in the program.

ADC and DAC pins are predefined and you have to use the manufacturer specified pins. But other functions like PWM, SPI, UART, I2C etc. can be assigned to any GPIO pin through program.

RTC GPIO

ESP32 has 16 RTC GPIOs, which are part of the RTC Low-Power subsystem. These pins can be used to wake ESP32 from deep sleep as external wake-up source.

The RTC GPIOs and their corresponding GPIO Pins are mentioned below.

  • 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

ADC

ESP32 has two 12-bit SAR Analog to Digital Converter Modules with 8-channels and 10-channels each. So, ADC1 and ADC2 blocks combined together have 18 channels of 12-bit ADC.

The following is the GPIO Pins associated with both ADC blocks (ADC1 and ADC2).

  • ADC1_CH0 — GPIO36
  • ADC1_CH1 — GPIO37
  • ADC1_CH2 — GPIO38
  • ADC1_CH3 — GPIO39
  • ADC1_CH4 — GPIO32
  • ADC1_CH5 — GPIO33
  • ADC1_CH6 — GPIO34
  • ADC1_CH7 — GPIO35
  • ADC2_CH0 — GPIO4
  • ADC2_CH1 — GPIO0
  • ADC2_CH2 — GPIO2
  • ADC2_CH3 — GPIO15
  • ADC2_CH4 — GPIO13
  • ADC2_CH5 — GPIO12
  • ADC2_CH6 — GPIO14
  • ADC2_CH7 — GPIO27
  • ADC2_CH8 — GPIO25
  • ADC2_CH9 — GPIO26

With 12-bit resolution, the output Digital values will be in the range of 0 – 4093.

DAC

ESP32 Microcontroller has two independent 8-bit Digital to Analog Converter channels to convert digital values to analog voltage signals. The DAC has internal resistor network and uses power supply as input reference voltage.

The following two GPIO Pins are associated with DAC functionalities.

  • DAC1 — GPIO25
  • DAC2 — GPIO26

Capacitive Touch GPIOs

The ESP32 SoC has 10 capacitive-sensing GPIOs, which can detect variations in capacitance on a pin due to touching or approaching the GPIO Pin with a finger or stylus. These Touch GPIOs can be used in implementing capacitive touch pads, without any additional hardware.

Touch GPIOs and their corresponding GPIO pins are mentioned below.

  • Touch0 — GPIO4
  • Touch1 — GPIO0
  • Touch2 — GPIO2
  • Touch3 — GPIO15
  • Touch4 — GPIO13
  • Touch5 — GPIO12
  • Touch6 — GPIO14
  • Touch7 — GPIO27
  • Touch8 — GPIO33
  • Touch9 — GPIO32

SPI

The ESP32 Wi-Fi chip features three SPI blocks (SPI, HSPI and VSPI) in both master and slave modes. SPI is used to interface with Flash Memory. So, you have two SPI interfaces. The GPIO Pins of SPI block are mentioned below.

  • HSPICS – GPIO15
  • HSPICLK – GPIO14
  • HSPIMOSI – GPIO13
  • HSPIMISO – GPIO12
  • VSPICS – GPIO5
  • VSPICLK – GPIO18
  • VSPIMOSI – GPIO23
  • VSPIMISO – GPIO19

I2C

There are two I2C interfaces in ESP32 with complete flexibility on assigning pins i.e., SCL and SDA pins for both I2C interfaces can be assigned in the program by the user.

If you are using Arduino IDE, then the default I2C pins are:

  • SDA – GPIO21
  • SCL – GPIO22

PWM

The PWM Controller in ESP32 have 16 independent PWM waveform channels with configurable frequency and duty cycle. The PWM waveform can be used to drive motors and LEDs. You can configure the PWM signal frequency, channel, GPIO pin and also the duty cycle.

What GPIO Pins to use?

Let us now take a look at a table which specifies the GPIO pins and their input / output capabilities.

GPIO Pin

Input Output Additional Information
0 Pulled Up YES (*)

PWM Output at boot

1

TX PIN YES (*) Debug Output at boot
2 YES YES

Connected to on-board LED

3

YES (*) RX PIN HIGH at boot
4 YES YES

5

YES YES PWM Output at boot
6 NO NO

Connected to SPI Flash IC

7

NO NO Connected to SPI Flash IC
8 NO NO

Connected to SPI Flash IC

9

NO NO Connected to SPI Flash IC
10 NO NO

Connected to SPI Flash IC

11

NO NO Connected to SPI Flash IC
12 YES (*) YES

Boot fails if pulled HIGH

13

YES YES
14 YES YES

PWM Output at boot

15

YES YES PWM Output at boot
16 YES

YES

17

YES YES
18 YES

YES

19

YES YES
21 YES

YES

22

YES YES
23 YES

YES

25

YES YES
26 YES

YES

27

YES YES
32 YES

YES

33

YES YES
34 YES NO

Input Only

35

YES NO Input Only
36 YES NO

Input Only

39

YES NO

Input Only

GPIOs Connected to SPI Flash IC

If you take a look at the schematic of ESP-WROOM-32 Module, then you will see that GPIO6 to GPIO11 are connected to SPI Flash Memory IC. Even if these GPIO pins are accessible (which are not in 30-pin ESP32 Board), do not use them for any other purpose.

Input only GPIO

There are 4 GPIO pins which are capable of acting as Digital Input only pins. They are GPIO34, GPIO35, GPIO36 and GPIO39.

Interrupts

All GPIO pins are capable of interrupts.

Boot Strapping Pins

ESP32 SoC has 5 boot strapping pins. They are:

  • GPIO0
  • GPIO2
  • GPIO5 (must be HIGH during BOOT)
  • GPIO12 (must be LOW during BOOT)
  • GPIO15 (must be HIGH during BOOT)

These pins are used to put the microcontroller in to flashing mode or bootloader mode.

Logic HIGH Pins at Boot

There are 5 GPIO pins which are either HIGH at boot time or output PWM signal. So, if you are using these GPIO pins for peripheral control (like a relay, for example), then you need to be careful during the boot time or when ESP32 is Reset as you might get unexpected results.

  • GPIO1
  • GPIO3
  • GPIO5
  • GPIO14
  • GPIO15

Conclusion

This is a complete guide on ESP32 Pinout. You learned about pinout of ESP-WROOM-32 Module, ESP32 DevKit Development Board and some important peripherals of EP32. You also learned what GPIOs to use and what GPIO Pins not to use in your design

The post ESP32 Pinout | ESP-WROOM-32 Pinout appeared first on Electronics Hub.



No comments:

Post a Comment