Esp32 Devkit 4
Esp32 Devkit 4
com/esp32-pinout-reference-gpios/
randomnerdtutorials.com
The ESP32 chip comes with 48 pins with multiple functions. Not all
pins are exposed in all ESP32 development boards, and some pins
cannot be used.
There are many questions on how to use the ESP32 GPIOs. What
pins should you use? What pins should you avoid using in your
projects? This post aims to be a simple and easy-to-follow
reference guide for the ESP32 GPIOs.
Note: not all GPIOs are accessible in all development boards, but
each specific GPIO works in the same way regardless of the
development board you’re using. If you’re just getting started with
the ESP32, we recommend reading our guide: Getting Started with
the ESP32 Development Board.
ESP32 Peripherals
1 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
3 SPI interfaces
3 UART interfaces
2 I2C interfaces
2 I2S interfaces
Although you can define the pins properties on the software, there
are pins assigned by default as shown in the following figure (this is
an example for the ESP32 DEVKIT V1 DOIT board with 36 pins –
the pin location can change depending on the manufacturer).
Additionally, there are pins with specific features that make them
suitable or not for a particular project. The following table shows
what pins are best to use as inputs, outputs and which ones you
need to be cautious.
2 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have
internal pull-up or pull-down resistors. They can’t be used as
outputs, so use these pins only as inputs:
GPIO 34
GPIO 35
GPIO 36
GPIO 39
3 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
GPIO 6 (SCK/CLK)
GPIO 7 (SDO/SD0)
GPIO 8 (SDI/SD1)
GPIO 9 (SHD/SD2)
GPIO 10 (SWP/SD3)
GPIO 11 (CSC/CMD)
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)
Learn how to use the touch pins with Arduino IDE: ESP32
Touch Pins with Arduino IDE
4 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
ADC2_CH0 (GPIO 4)
ADC2_CH1 (GPIO 0)
ADC2_CH2 (GPIO 2)
Note: ADC2 pins cannot be used when Wi-Fi is used. So, if you’re
using Wi-Fi and you’re having trouble getting the value from an
ADC2 GPIO, you may consider using an ADC1 GPIO instead. That
should solve your problem.
The ADC input channels have a 12-bit resolution. This means that
you can get analog readings ranging from 0 to 4095, in which 0
corresponds to 0V and 4095 to 3.3V. You can also set the
resolution of your channels on the code and the ADC range.
The ESP32 ADC pins don’t have a linear behavior. You’ll probably
won’t be able to distinguish between 0 and 0.1V, or between 3.2
and 3.3V. You need to keep that in mind when using the ADC pins.
You’ll get a behavior similar to the one shown in the following figure.
DAC1 (GPIO25)
DAC2 (GPIO26)
RTC GPIOs
5 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
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)
Learn how to use the RTC GPIOs to wake up the ESP32 from
deep sleep: ESP32 Deep Sleep with Arduino IDE and Wake Up
Sources
PWM
Signal’s frequency;
Duty cycle;
PWM channel;
Learn how to use ESP32 PWM with Arduino IDE: ESP32 PWM
with Arduino IDE
6 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
I2C
The ESP32 has two I2C channels and any pin can be set as SDA
or SCL. When using the ESP32 with the Arduino IDE, the default
I2C pins are:
GPIO 21 (SDA)
GPIO 22 (SCL)
If you want to use other pins when using the wire library, you just
need to call:
Wire.begin(SDA, SCL);
SPI
Interrupts
Strapping Pins
GPIO 0
GPIO 2
GPIO 4
These are used to put the ESP32 into bootloader or flashing mode.
On most development boards with built-in USB/Serial, you don’t
need to worry about the state of these pins. The board puts the pins
in the right state for flashing or boot mode. More information on the
ESP32 Boot Mode Selection can be found here.
7 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
GPIO 1
GPIO 3
GPIO 5
GPIO 14
GPIO 15
Enable (EN)
Enable (EN) is the 3.3V regulator’s enable pin. It’s pulled up, so
connect to ground to disable the 3.3V regulator. This means that
you can use this pin connected to a pushbutton to restart your
ESP32, for example.
The ESP32 also features a built-in hall effect sensor that detects
changes in the magnetic field in its surroundings.
Wrapping Up
We hope you’ve found this reference guide for the ESP32 GPIOs
useful. If you have more tips about the ESP32 GPIOs, please share
by writing a comment down below.
If you’re just getting started with the ESP32, we have some great
content to get started:
8 of 9 3/23/2022, 12:02 PM
ESP32 Pinout Reference: Which GPIO pins should you use? about:reader?url=https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
9 of 9 3/23/2022, 12:02 PM