ESP32

The ESP32 is a series microcontrollers manufactured by a company named Espressif. that include Wi-Fi and Bluetooth wireless capabilities and dual-core processor. The SP32 is capable of functioning reliably in industrial environments, with an operating temperature ranging from –40°C to +125°C. ESP32 have a very low power consumption and hence are suitable for wearable electronics and other IoT applications.

The ESP32 has in-built WiFi and Bluetooth (Classic and BLE) communication capability.

We will be using the ESP32 in projects that need to exchange data with an MQTT broker over WiFi or with the mobile app over BLE. The physical board and its pinout diagram are shown below, followed by an explanation of all pins.

ESP32
ESP32 Pinout

The pins on the ESP32 are explained below. Note that several pins offer multiple functions including acting as a GPIO and a communication pin for UART, SPI, and I2C. One set of pins is the default for a communication protocol while the others can be configured for use in the program. All GPIOs can be configured as interrupts for use with Interrupt Service Requests (ISRs).

The ESP32 comes in multiple variations, with differnt pin layouts. There is a 38-pin board which is shown above, and there is the more commonly used 30-pin board. The table below lists the pins that are common across both and sufficent for using either variant of the board.

Board PinFunctionTypeRecommended Usage
ENEnabledThis requires to be set to HIGH when uploading a program. Has a physical button.
VPGPIO(36)This is an input only pin. Can also be used for Analog input.
VNGPIO (39)This is an input only pin. Can also be used for Analog input.
34GPIOThis is an input only pin. Can also be used for Analog input.
35GPIOThis is an input only pin. Can also be used for Analog input.
32GPIOThis is an input only pin. Can also be used for Analog input.
33GPIOThis is an input only pin. Can also be used for Analog input.
25GPIO
26GPIO
27GPIO
14SPI-CLKGPIOUse for SPI communication.
12SPI-CIPOGPIOUse for SPI communication.
13SPI-COPIGPIOUse for SPI communication.
15SPI-CSGPIOUse for SPI communication.
2GPIO
4GPIO
16GPIO
17GPIO
5SPI-CSGPIOUse for SPI communication.
18SPI-CLKGPIOUse for SPI communication.
19SPI-CIPOGPIOUse for SPI communication.
21I2C-SDAGPIOWhile any GPIO pin can be configured as I2C SDA and SCL this is commonly used by convention.
RXUART-RXKeep free for code upload and serial communication with the computer.
TXUART-TXKeep free for code upload and serial communication with the computer.
22I2C-SCLGPIOWhile any GPIO pin can be configured as I2C SDA and SCL this is commonly used by convention.
23SPI-COPIGPIOUse for SPI communication.

Recommended Pin Usage

Arduino Nano Pinout