HomeLinuxESP32 Pinout Reference – A Full Information

ESP32 Pinout Reference – A Full Information


ESP32 is a microcontroller board that has numerous GPIO pins for a number of functions. Every of those pins is designed for particular capabilities. ESP32 includes a higher variety of pins when in comparison with Arduino UNO or ESP8266 boards. To start out working with ESP32 enough information of its pin is important. The purpose of this information is to debate all of the accessible pins on the board and their related options.

This pinout information to ESP32 comprises the next content material:

1: Introduction to ESP32

2: ESP32 GPIO Pins

3: ESP32 ADC Pins

4: DAC Pins

5: PWM Pins  

6: SPI Pins in ESP32 

7: I2C Pins

8: I2S Pins

9: UART

10: Capacitive Contact Pins

11: ESP32 Strapping Pins

12: Pins Excessive at BOOT

13: Allow (EN) PIN

14: ESP32 Energy Pins

15: ESP32 Corridor Impact Sensor

Earlier than we transfer ahead right here, we summarized a quick introduction to the ESP32 IoT board.

1: Introduction to ESP32

    • ESP32 is a very fashionable IoT-based microcontroller board.
    • Foremost a part of this microcontroller board is a Tensilica Xtensa LX6 chip designed by Espressif Programs.
    • It comprises a dual-core processor and every of those cores could be managed individually.
    • Complete of 48 pins are current within the ESP32 chip nevertheless not all of those pins are uncovered to customers.
    • ESP32 is available in two totally different variations: 30 pins and 36 pins.
    • ESP32 can go as much as a frequency ranging from 80 MHz to 240 MHz.
    • It comprises a particular ULP (Extremely Low Energy Co-Processor) that saves a considerable amount of energy utilizing very much less energy whereas the principle processor is OFF.
    • It comprises onboard WiFi and a twin Bluetooth module.
    • ESP32 is cheaper than different microcontrollers.

1.1: ESP32 Pinout

A number of variants of ESP32 can be found available in the market, in the present day we’ll cowl the detailed pinout of the 30 pin variant that comes with the ESP32-WROOM-32 microcontroller generally additionally known as WROOM32.

Complete of 48 pins can be found in ESP32 chips amongst which 30 pins are uncovered to the consumer whereas others are built-in contained in the microcontroller; some boards additionally comprise six additional SPI flash built-in pins which sum up the whole pin to 36.

1.2: ESP32 30 Pin Model Board

The beneath picture represents the detailed pinout of the ESP32 30 pin variant containing all its peripherals which we focus on one after the other intimately.


Some predominant peripherals inside ESP32 are:

    • Complete 48 pins*
    • 18 12-bit ADC pins
    • Two 8-bit DAC pins
    • 16 PWM channel
    • 10 Capacitive Contact Pins
    • 3 UART
    • 2 I2C
    • 1 CAN
    • 2 I2S
    • 3SPI

*ESP32 chip comprises a complete of 48 pins out of which solely 30 pins can be found for exterior interfacing (in some boards 36 which embody 6 additional SPI pins) remaining 18 pins are built-in contained in the chip for communication functions.

1.3: ESP32 36 Pin Model Board

Right here is a picture of an ESP32 board having a complete of 36 pins.

1.4: Distinction between ESP32 30 Pin Model and ESP32 36 Pin Model

Each ESP32 boards share the identical specification the one main distinction right here is 6 additional pins which might be uncovered in ESP32 (36 Pins) board are SPI flash built-in pins and secondly the GPIO 0 is changed with a GND pin in ESP32 (30 Pins) board which ends up in lacking of Contact 1 and ADC2 CH1 pin.

2: ESP32 GPIO Pins

As talked about earlier ESP32 has a complete of 48 pins out of which solely 30 pins are accessible to customers. Every of those 30 Normal function enter output pins has a particular perform and could be configured utilizing a particular register. There are totally different GPIO pins like UART, PWM, ADC, and DAC.


Out of those 30 pins, some are energy whereas some could be configured as each enter and output whereas sure pins are enter solely.

2.1: Enter/Output Pins

Nearly all GPIO pins could be configured as enter and output besides the 6 Serial peripheral interfaces (SPI) flash pins that can’t be configured for enter or output functions. These 6 SPI pins can be found on the 36 pins model board.


The desk given beneath explains the standing of ESP32 GPIO pins that can be utilized as enter and output:

Right here OK means the corresponding pin can be utilized as enter or output.

GPIO PIN INPUT OUTPUT Description
GPIO 0 Pulled up OK PWM output at boot
GPIO 1 Tx Pin OK Output debug at Boot
GPIO 2 OK OK On board LED
GPIO 3 OK Rx Pin Excessive at Boot
GPIO 4 OK OK
GPIO 5 OK OK PWM output at boot
GPIO 6 SPI Flash Pin
GPIO 7 SPI Flash Pin
GPIO 8 SPI Flash Pin
GPIO 9 SPI Flash Pin
GPIO 10 SPI Flash Pin
GPIO 11 SPI Flash Pin
GPIO 12 OK OK Boot fail at Excessive pull
GPIO 13 OK OK
GPIO 14 OK OK PWM output at boot
GPIO 15 OK OK PWM output at boot
GPIO 16 OK OK
GPIO 17 OK OK
GPIO 18 OK OK
GPIO 19 OK OK
GPIO 21 OK OK
GPIO 22 OK OK
GPIO 23 OK OK
GPIO 25 OK OK
GPIO 26 OK OK
GPIO 27 OK OK
GPIO 32 OK OK
GPIO 33 OK OK
GPIO 34 OK Enter Solely
GPIO 35 OK Enter Solely
GPIO 36 OK Enter Solely
GPIO 39 OK Enter Solely

2.2: Enter Solely Pins

GPIO pins 34 to 39 can’t be configured as output as these are just for enter functions. That is as a result of lack of an inside pull-up or pull-down resistor therefore can solely be used as enter.

Additionally, GPIO 36(VP) and GPIO 39(VN) are used for ultra-low noise preamplifiers in ESP32 ADC.

To summarize following are the input-only pins in ESP32:

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

2.3: Interrupt Pins

All GPIO pins in ESP32 can take exterior interrupts. This helps to observe change at a particular interrupt as an alternative of repeatedly monitoring.

2.4: RTC Pins

ESP32 additionally has some RTC GPIO pins. These RTC pins permit ESP32 to work in Deep Sleep mode. When ESP32 is contained in the deep sleep mode whereas working an Extremely Low Energy (ULP) co-processor these RTC pins can get up ESP32 from deep sleep saving a big proportion of energy.


These RTC GPIO pins can act as an exterior excitation supply to get up ESP32 from a deep sleep at a specific time or interrupt. RTC GPIO pins embody:

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

3: ESP32 ADC Pins

The ESP32 board has two built-in 12-bit ADCs also called SAR (Successive Approximation Registers) ADCs. The ESP32 board ADCs assist 18 totally different analog enter channels which implies we are able to join 18 totally different analog sensors to take enter from them.

However this isn’t the case right here; these analog channels are divided into two classes channel 1 and channel 2, each these channels have some pins that aren’t all the time accessible for ADC enter. Let’s see what these ADC pins are together with others.

3.1: ESP32 ADC Pinout

As talked about earlier the ESP32 board has 18 ADC channels. Out of 18, solely 15 can be found within the DEVKIT V1 DOIT board having a complete of 30 GPIOs.

Check out your board and determine the ADC pins as we highlighted them within the picture beneath:

3.2: Channel 1 ADC Pin

Following is the given pin mapping of the ESP32 DEVKIT DOIT board. ADC1 in ESP32 has 8 channels nevertheless the DOIT DEVKIT board solely helps 6 channels. However I assure these are nonetheless greater than sufficient.

ADC1 GPIO PIN ESP32
CH0 36
CH1 37* (NA)
CH2 38* (NA)
CH3 39
CH4 32
CH5 33
CH6 34
CH7 35

*These pins aren’t accessible for exterior interfacing; these are built-in inside ESP32 chips.

The next picture reveals ESP32 ADC1 channels:

3.3: Channel 2 ADC Pin

DEVKIT DOIT boards have 10 analog channels in ADC2. Though ADC2 has 10 analog channels to learn analog information, these channels aren’t all the time accessible to make use of. ADC2 is shared with onboard WiFi drivers, which implies on the time the board is utilizing WIFI these ADC2 is not going to be accessible. The answer to this downside is to make use of ADC2 solely when the Wi-Fi driver is off.

ADC2 GPIO PIN ESP32
CH0 4
CH1 0 (NA in 30 pin model ESP32-Devkit DOIT)
CH2 2
CH3 15
CH4 13
CH5 12
CH6 14
CH7 27
CH8 25
CH9 26

Under given picture reveals the pin mapping of the ADC2 channel.

3.4: Learn how to Use ESP32 ADC

ESP32 ADC works equally to Arduino solely distinction right here is it has 12-bit ADC. So, the ESP32 board maps the analog voltage values starting from 0 to 4095 in digital discrete values.

    • If the voltage given to ESP32 ADC is zero in an ADC channel the digital worth shall be zero.
    • If the voltage given to ADC is most means 3.3V the output digital worth shall be equal to 4095.
    • To measure greater voltage, we are able to use the voltage divider methodology.

Word: ESP32 ADC is by default set at 12-bits, nevertheless, it’s doable to configure it into 0-bit,10-bit, and 11-bit. The 12-bit default ADC can measure worth 2^12=4096 and the analog voltage ranges from 0V to three.3V.

3.5: ADC Limitation on ESP32

Listed below are some limitations of ESP32 ADC:

    • ESP32 ADC can’t instantly measure voltage higher than 3.3V.
    • When Wi-Fi drivers are enabled ADC2 can’t be used. Solely 8 channels of ADC1 can be utilized.
    • The ESP32 ADC shouldn’t be very linear; it reveals non-linearity habits and can’t distinguish between 3.2V and three.3V. Nevertheless, it’s doable to calibrate ESP32 ADC. Right here is an article that can information you to calibrate ESP32 ADC nonlinearity habits.

The nonlinearity habits of ESP32 could be seen on the serial monitor of Arduino IDE.

4: DAC Pins

ESP32 options two onboard 8-bit DAC (Digital to Analog converter). Utilizing ESP32 DAC pins any digital sign could be remodeled into analog. DAC pins software consists of voltage and PWM management.

Following are the 2 DAC pins within the ESP32 board.

    • DAC_1 (GPIO25)
    • DAC_2 (GPIO26)

5: PWM Pins

The ESP32 board comprises 16 unbiased pulse width modulation (PWM) channels that may output totally different PWM alerts. Nearly all GPIOs can generate a PWM sign nevertheless the input-only pins 34,35,36,39 can’t be used as PWM pins as they can’t output a sign.

Word: In 36 pin ESP32, onboard 6 SPI flash built-in pins (GPIO 6, 7, 8, 9, 10, 11) can’t be used as PWM.


Learn right here for an entire newbie’s information for controlling ESP32 PWM pins utilizing Arduino IDE.

6: SPI Pins in ESP32

ESP32 has 4 SPI peripherals built-in into its microcontroller:

    • SPI0: Can’t be used externally just for inside communication
    • SPI1: Can’t be used externally with SPI gadgets. Just for inside reminiscence communication
    • SPI2: SPI2 or HSPI can talk with exterior gadgets and sensors. It has unbiased bus alerts with every bus potential to regulate 3 slave gadgets.
    • SPI3: SPI3 or VSPI can talk with exterior gadgets and sensors. It has unbiased bus alerts with every bus potential to regulate 3 slave gadgets.

Most ESP32 boards include preassigned SPI pins for each the SPI2 and SPI3. Nevertheless, if not assigned we are able to all the time assign SPI pins in code. Following are the SPI pins present in many of the ESP32 boards that are preassigned:

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


Above talked about SPI pins can fluctuate relying on the board kind. Now we’ll write a code to examine ESP32 SPI pins utilizing Arduino IDE.

For a whole tutorial on Serial Peripheral Interface click on right here.

7: I2C Pins

ESP32 board comes with a single I2C bus that helps as much as 120 I2C gadgets. By default, two SPI pins for SDA and SCL are outlined at GPIO 21 and 22 respectively. Nevertheless, utilizing the command wire.start(SDA, SCL) we are able to configure any GPIO as an I2C interface.

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

    • GPIO21 – SDA (Information pin)
    • GPIO22 – SCL (Clock Synchronization pin)

8: I2S Pins

I2S (Inter-IC Sound) is a synchronous communication protocol that transmits audio alerts between two digital audio gadgets serially.

ESP32 has two I2S peripherals, and every of them operates in half duplex communication mode. Nevertheless, we are able to additionally mix them to function in full duplex mode.

Usually the 2 DAC pins in ESP32 are used for I2S audio communication. Following are the I2S pins in ESP32:

    • GPIO 26 – Serial Clock (SCK)
    • GPIO 25 – Phrase Choose (WS)

For I2S Serial Information (SD) pins we are able to configure any GPIO pin.


For extra detailed documentation on ESP32 I2S communication protocol go to Espressif System ESP32 official I2S Documentation.

9: UART

By default, ESP32 has three UART interfaces which might be UART0, UART1, and UART2. Each UART0 and UART2 are externally usable nevertheless the UART1 shouldn’t be accessible for exterior interfacing and communication as a result of it’s internally linked to built-in SPI flash reminiscence.

    • UART0 is by default on the GPIO1(TX0) and GPIO3(RX0) of ESP32. This pin is internally linked to the USB-to-Serial converter and is utilized by ESP32 for serial communication through USB port. In case we use UART0 pins we shall be unable to speak with the PC. Subsequently, it’s not advisable to make use of UART0 pins externally.
    • UART2 however shouldn’t be linked internally to a USB-to-Serial converter which implies we are able to use it for exterior interfacing for UART communication between gadgets and sensors.
    • UART1 as talked about earlier is internally linked with flash reminiscence so don’t use GPIO pins 9 and 10 for exterior UART communication.

Word: ESP32 chip has a multiplexing functionality which implies totally different pins can be used for communications resembling we are able to configure any GPIO pin in ESP32 for UART1 communication by defining it contained in the Arduino code.

Following are the UART pins of ESP32:

UART Bus Rx Tx Description
UART0 GPIO 3 GPIO 1 Can be utilized however not advisable as a result of internally linked to USB-to-Serial converter
UART1 GPIO 9 GPIO 10 Don’t use linked to SPI inside ESP32 Flash reminiscence
UART2 GPIO 16 GPIO 17 Allowed to make use of

10: Capacitive Contact Pins

ESP32 has 10 GPIO pins which have in-built assist for capacitive contact sensors. Utilizing these pins any change in electrical cost could be detected. These pins act as a touchpad resembling sensing enter from a human finger or every other contact interrupt prompted.

Utilizing these pins, we are able to additionally design an exterior wakeup supply for ESP32 from deep sleep mode.

Contact pins embody:

    • Touch_0 (GPIO4)
    • Touch_1 (GPIO0)
    • Touch_2 (GPIO2)
    • Touch_3 (GPIO15)
    • Touch_4 (GPIO13)
    • Touch_5 (GPIO12)
    • Touch_6 (GPIO14)
    • Touch_7 (GPIO27)
    • Touch_8 (GPIO33)
    • Touch_9 (GPIO32)

Following are the contact sensor pins in ESP32 board:


Touch_1 pin is lacking on this model of ESP32 (30 pin) board. Touch_1 pin is at (GPIO0) which is current within the 36-pin ESP32.

Here’s a tutorial on ESP32 Capacitive Contact Sensor with Arduino IDE.

11: ESP32 Strapping Pins

ESP32 has strapping pins that may put ESP32 into totally different modes like bootloader or flashing mode. In most boards that function the built-in USB-Serial, we don’t have to fret about these pins because the board itself places ESP32 into the best mode both flashing or boot mode.

Nevertheless, in case these pins are below use, one could encounter issues in importing new code, flashing firmware, or resetting the ESP32 board.

Under are the ESP32 strapping pins accessible:

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

12: Pins Excessive at BOOT

Some GPIO pins present surprising habits when outputs are linked to those pins as a result of these pins present a HIGH state or generate a PWM sign as soon as the ESP32 board is booted or reset.

These pins are:

    • GPIO 1
    • GPIO 3
    • GPIO 5
    • GPIO 6 to GPIO 11 (interfaced with ESP32 inside SPI flash– Do Not use these pins for every other function).
    • GPIO 14
    • GPIO 15

13: Allow (EN) PIN

This pin is used to allow the ESP32 board. Utilizing this we are able to management the ESP32 voltage regulator. This pin permits the chip when pulled HIGH and when pulled LOW, ESP32 works at minimal energy.


By connecting the EN (allow) pin to GND the three.3V on-board voltage regulator disables this which means we are able to use an exterior pushbutton to restart ESP32 if wanted.

14: ESP32 Energy Pins

ESP32 has a number of energy enter sources. Primarily two pins can be utilized for powering ESP32 which embody the VIN (Vin) pin and the 3V3 (3.3V) pin. The primary supply of powering ESP32 is utilizing the USB cable. The opposite two sources required exterior regulated provide.


The ESP32 has an on board voltage regulator of output 3.3V which takes enter from two sources USB and the VN pin after that it converts the enter voltage (5V) to three.3V for ESP32 working.

Following are the three energy sources for ESP32:

    • USB Port: Can solely give enter energy to ESP32
    • VN PIN: Works twin means enter in addition to output
    • 3V3 PIN: Works twin means enter in addition to output

Word: 3V3 pin of ESP32 shouldn’t be linked to on board voltage regulator it’s not advisable to make use of this for energy enter as a result of the slight enhance in voltage will end in extra present move from the output terminal of the LDO regulator (AMS1117) to the enter leading to everlasting injury of ESP32 voltage regulator.

Nevertheless, when you have a relentless 3.3V provide then it may be used.

Secondly, don’t give greater than 9V to the VN pin as ESP32 solely wants 3.3V for working; all remaining voltages shall be dissipated as warmth.

For a extra detailed information on ESP32 energy sources and voltage necessities do examine this tutorial Learn how to Energy ESP32.

15: ESP32 Corridor Impact Sensor

ESP32 includes a built-in corridor impact sensor utilizing which we are able to detect adjustments in a magnetic subject and execute particular output accordingly.

Here’s a tutorial on Learn how to use ESP32 built-in Corridor Impact Sensor and print the learn information over the serial monitor.

Conclusion

Beginning with ESP32 has by no means been simple however utilizing this text on ESP32 pinout anybody can begin with an IoT-based board inside a couple of minutes. Right here this text covers all the main points relating to ESP32 pinout. Each ESP32 pin is mentioned in in depth element. For extra tutorials on particular pins examine different Tutorials on the ESP32 board.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments