Introduction to ESP32
Introduction
The ESP32 family is a general-purpose, feature-rich, and versatile SoC solution that you can use in many different types of IoT projects where you require Wi-Fi connectivity. Let\’s have a quick look at the main features:
- CPU and memory: 32-bit Xtensa® LX6 microprocessor with a clock frequency of up to 240 MHz/600 MIPS. Single- or dual-core variants. 448 KB ROM, 520 KB SRAM, and 16 KB RTC memory. Support for external SPI flash and SPI RAM for module variants. DMA for peripherals.
- Connectivity: Wi-Fi 802.11 n (2.4 GHz) up to 150 Mbps and Bluetooth-compliant with Bluetooth v4.2 and BLE specifications.
- Peripheral interfaces: GPIOs, ADC, DAC, SPI, I2C, I2S, UART, SD (chip variants), CAN, IR, PWM, touch sensor, and hall sensor.
- Security: Cryptographic hardware acceleration (random number, hash, AES, RSA, and ECC), 1024-bit OTP, secure boot, and flash encryption.
- Power modes: Different power modes with the help of an Ultra-Low-Power (ULP) co-processor and a Real-Time Clock (RTC). 100 μA power consumption in deep-sleep mode (ULP active).
ESP-32 Microcontroller Pinout
Pin No. | Name | Type | Function |
1 | VDDA | Power | Analog power supply (2.3 V ∼ 3.6 V) |
2 | LNA_IN | Input / Output | RF input and output |
3 | VDD3P3 | Power | Analog power supply (2.3 V ∼ 3.6 V) |
4 | VDD3P3 | Power | Analog power supply (2.3 V ∼ 3.6 V) |
5 | SENSOR_VP | Input | GPIO36, ADC1_CH0, RTC_GPIO0 |
6 | SENSOR_CAPP | Input | GPIO37, ADC1_CH1, RTC_GPIO1 |
7 | SENSOR_CAPN | Input | GPIO38, ADC1_CH2, RTC_GPIO2 |
8 | SENSOR_VN | Input | GPIO39, ADC1_CH3, RTC_GPIO3 |
9 | CHIP_PU | Input | High: On; enables the chip Low: Off; the chip powers off Note: Do not leave the CHIP_PU pin floating. |
10 | VDET_1 | Input | GPIO34, ADC1_CH6, RTC_GPIO4 |
11 | VDET_2 | Input | GPIO35, ADC1_CH7, RTC_GPIO5 |
12 | 32K_XP | Input / Output | GPIO32, ADC1_CH4, RTC_GPIO9, TOUCH9, 32K_XP (32.768 kHz crystal oscillator input) |
13 | 32K_XN | Input / Output | GPIO33, ADC1_CH5, RTC_GPIO8, TOUCH8, 32K_XN (32.768 kHz crystal oscillator output) |
14 | GPIO25 | Input / Output | ADC2_CH8, RTC_GPIO6, DAC_1, EMAC_RXD0 |
15 | GPIO26 | Input / Output | ADC2_CH9, RTC_GPIO7, DAC_2, EMAC_RXD1 |
16 | GPIO27 | Input / Output | ADC2_CH7, RTC_GPIO17, TOUCH7, EMAC_RX_DV |
17 | MTMS | Input / Output | GPIO14, ADC2_CH6, RTC_GPIO16, TOUCH6, EMAC_TXD2, HSPICLK, HS2_CLK, SD_CLK, |
18 | MTDI | Input / Output | GPIO12, ADC2_CH5, RTC_GPIO15, TOUCH5, EMAC_TXD3, HSPIQ, HS2_DATA2, SD_DATA2, |
19 | VDD3P3_RTC | Power | Input power supply for RTC IO (2.3 V ∼ 3.6 V) |
20 | MTCK | Input / Output | GPIO13, ADC2_CH4, RTC_GPIO14, TOUCH4, EMAC_RX_ER, HSPID, HS2_DATA3, SD_DATA3, |
21 | MTDO | Input / Output | GPIO15, ADC2_CH3, RTC_GPIO13, TOUCH3, EMAC_RXD3, HSPICS0, HS2_CMD, SD_CMD, |
22 | GPIO2 | Input / Output | ADC2_CH2, RTC_GPIO12, TOUCH2, HSPIWP, HS2_DATA0, SD_DATA0 |
23 | GPIO0 | Input / Output | ADC2_CH1, RTC_GPIO11, TOUCH1, EMAC_TX_CLK, CLK_OUT1 |
24 | GPIO4 | Input / Output | ADC2_CH0, RTC_GPIO10, TOUCH0, EMAC_TX_ER, HSPIHD, HS2_DATA1, SD_DATA1 |
25 | GPIO16 | Input / Output | HS1_DATA4, U2RXD, EMAC_CLK_OUT |
26 | VDD_SDIO | Power | Output power supply: 1.8 V or the same voltage as VDD3P3_RTC |
27 | GPIO17 | Input / Output | HS1_DATA5, U2TXD, EMAC_CLK_OUT_180 |
28 | SD_DATA_2 | Input / Output | GPIO9, HS1_DATA2, U1RXD, SPIHD |
29 | SD_DATA_3 | Input / Output | GPIO10, HS1_DATA3, U1TXD, SPIWP |
30 | SD_CMD | Input / Output | GPIO11, HS1_CMD, U1RTS, SPICS0 |
31 | SD_CLK | Input / Output | GPIO6, HS1_CLK, U1CTS, SPICLK |
32 | SD_DATA_0 | Input / Output | GPIO7, HS1_DATA0, U2RTS, SPIQ |
33 | SD_DATA_1 | Input / Output | GPIO8,, U2CTS, HS1_DATA1, SPID |
34 | GPIO5 | Input / Output | HS1_DATA6, VSPICS0, EMAC_RX_CLK |
35 | GPIO18 | Input / Output | HS1_DATA7, VSPICLK |
36 | GPIO23 | Input / Output | HS1_STROBE, VSPID |
37 | VDD3P3_CPU | Power | Input power supply for CPU IO (1.8 V ∼ 3.6 V) |
38 | GPIO19 | Input / Output | U0CTS, VSPIQ, EMAC_TXD0 |
39 | GPIO22 | Input / Output | U0RTS, VSPIWP, EMAC_TXD1 |
40 | U0RXD | Input / Output | GPIO3, CLK_OUT2 |
41 | U0TXD | Input / Output | GPIO1, CLK_OUT3, EMAC_RXD2 |
42 | GPIO21 | Input / Output | VSPIHD, EMAC_TX_EN |
43 | VDDA | Power | Analog power supply (2.3 V ∼ 3.6 V) |
44 | XTAL_N | Output | External crystal output |
45 | XTAL_P | Input | External crystal input |
46 | VDDA | Power | Analog power supply (2.3 V ∼ 3.6 V) |
47 | CAP2 | Input | Connects to a 3.3 nF (10%) capacitor and 20 kΩ resistors in parallel to CAP1 |
48 | CAP1 | Input | Connects to a 10 nF series capacitor to ground |
49 | GND | Power | Ground |
ESP-32 WROOM 32 Module
ESP32-WROOM-32 is a powerful, generic Wi-Fi+BT+BLE MCU module that targets a wide variety of applications, ranging from low-power sensor networks to the most demanding tasks, such as voice encoding, music streaming and MP3 decoding.
The chip embedded is designed to be scalable and adaptive. There are two CPU cores that can be individually controlled, and the CPU clock frequency is adjustable from 80 MHz to 240 MHz. The chip also has a low-power co-processor that can be used instead of the CPU to save power while performing tasks that do not require much computing power, such as monitoring of peripherals. ESP32 integrates a rich set of peripherals, ranging from capacitive touch sensors, Hall sensors, SD card interface, Ethernet, high-speed SPI, UART, I²S, and I²C.
Pin No. | Name | Type | Function |
GND | Power | Ground | |
3V3 | Power | Power supply | |
9 | EN | Input | Module-enable signal. Active high. |
5 | SENSOR_VP | Input | ADC1_CH0, RTC_GPIO0 |
8 | SENSOR_VN | Input | ADC1_CH3, RTC_GPIO3 |
10 | GPIO34 | Input | ADC1_CH6, RTC_GPIO4 |
11 | GPIO35 | Input | ADC1_CH7, RTC_GPIO5 |
12 | GPIO32 | Input / Output | XTAL_32K_P (32.768 kHz crystal oscillator input), ADC1_CH4, TOUCH9, RTC_GPIO9 |
13 | GPIO33 | Input / Output | XTAL_32K_N (32.768 kHz crystal oscillator output), ADC1_CH5, TOUCH8, RTC_GPIO8 |
14 | GPIO25 | Input / Output | DAC_1, ADC2_CH8, RTC_GPIO6, EMAC_RXD0 |
15 | GPIO26 | Input / Output | DAC_2, ADC2_CH9, RTC_GPIO7, EMAC_RXD1 |
16 | GPIO27 | Input / Output | ADC2_CH7, TOUCH7, RTC_GPIO17, EMAC_RX_DV |
17 | GPIO14 | Input / Output | ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2 |
18 | GPIO12 | Input / Output | ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 |
GND | Power | Ground | |
20 | GPIO13 | Input / Output | ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER |
28 | SHD/SD2 | Input / Output | GPIO9, SD_DATA2, SPIHD, HS1_DATA2, U1RXD |
29 | SWP/SD3 | Input / Output | GPIO10, SD_DATA3, SPIWP, HS1_DATA3, U1TXD |
30 | SCS/CMD | Input / Output | GPIO11, SD_CMD, SPICS0, HS1_CMD, U1RTS |
31 | SCK/CLK | Input / Output | GPIO6, SD_CLK, SPICLK, HS1_CLK, U1CTS |
32 | SDO/SD0 | Input / Output | GPIO7, SD_DATA0, SPIQ, HS1_DATA0, U2RTS |
33 | SDI/SD1 | Input / Output | GPIO8, SD_DATA1, SPID, HS1_DATA1, U2CTS |
21 | GPIO15 | Input / Output | ADC2_CH3, TOUCH3, MTDO, HSPICS0, RTC_GPIO13, HS2_CMD, SD_CMD, EMAC_RXD3 |
22 | GPIO2 | Input / Output | ADC2_CH2, TOUCH2, RTC_GPIO12, HSPIWP, HS2_DATA0, SD_DATA0 |
23 | GPIO0 | Input / Output | ADC2_CH1, TOUCH1, RTC_GPIO11, CLK_OUT1, EMAC_TX_CLK |
24 | GPIO4 | Input / Output | ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER |
25 | GPIO16 | Input / Output | HS1_DATA4, U2RXD, EMAC_CLK_OUT |
27 | GPIO17 | Input / Output | HS1_DATA5, U2TXD, EMAC_CLK_OUT_180 |
34 | GPIO5 | Input / Output | VSPICS0, HS1_DATA6, EMAC_RX_CLK |
35 | GPIO18 | Input / Output | VSPICLK, HS1_DATA7 |
38 | GPIO19 | Input / Output | VSPIQ, U0CTS, EMAC_TXD0 |
– | NC | – | – |
42 | GPIO21 | Input / Output | VSPIHD, EMAC_TX_EN |
40 | RXD0 | Input / Output | GPIO3, U0RXD, CLK_OUT2 |
41 | TXD0 | Input / Output | GPIO1, U0TXD, CLK_OUT3, EMAC_RXD2 |
39 | GPIO22 | Input / Output | VSPIWP, U0RTS, EMAC_TXD1 |
36 | GPIO23 | Input / Output | VSPID, HS1_STROBE |
GND | Power | Ground |
ESP-32 WROOM 32 DEV-KIT
ESP32 Development board is based on the ESP WROOM32 WIFI + BLE Module. This is the latest generation of the ESP32 IoT development modules. This development board breaks out all ESP32 modules pins into a 0.1\” header and also provides a 3.3 Volt power regulator, Reset, and programming button.
Peripheral Configurations
Interface | Signal | Pin Number | Function |
ADC (Analog to Digital) | ADC1_CH0 ADC1_CH1 ADC1_CH2 ADC1_CH3 ADC1_CH4 ADC1_CH5 ADC1_CH6 ADC1_CH7 ADC2_CH0 ADC2_CH1 ADC2_CH2 ADC2_CH3 ADC2_CH4 ADC2_CH5 ADC2_CH6 ADC2_CH7 ADC2_CH8 ADC2_CH9 | SENSOR_VP SENSOR_CAPP SENSOR_CAPN SENSOR_VN 32K_XP 32K_XN VDET_1 VDET_2 GPIO4 GPIO0 GPIO2 MTDO MTCK MTDI MTMS GPIO27 GPIO25 GPIO26 | ESP32 integrates 12-bit SAR ADCs and supports measurements on 18 channels (analog-enabled pins). |
DAC (Digital to Analog) | DAC_1 DAC_2 | GPIO25 GPIO26 | Two 8-bit DAC channels can be used to convert two digital signals into two analog voltage signal outputs. The design structure is composed of integrated resistor strings and a buffer. This dual DAC supports the power supply as an input voltage reference. The two DAC channels can also support independent conversions. |
Touch Sensor | TOUCH0 TOUCH1 TOUCH2 TOUCH3 TOUCH4 TOUCH5 TOUCH6 TOUCH7 TOUCH8 TOUCH9 | GPIO4 GPIO0 GPIO2 MTDO MTCK MTDI MTMS GPIO27 32K_XN 32K_XP | ESP32 has 10 capacitive-sensing GPIOs, which detect variations induced by touching or approaching the GPIOs with a finger or other objects. The low-noise nature of the design and the high sensitivity of the circuit allows relatively small pads to be used. Arrays of pads can also be used so that a larger area or more points can be detected. |
JTAG | MTDI MTCK MTMS MTDO | MTDI MTCK MTMS MTDO | JTAG for software debugging |
SD/MMC Host Controller | HS2_CLK HS2_CMD HS2_DATA0 HS2_DATA1 HS2_DATA2 HS2_DATA3 | HS2_CLK HS2_CMD HS2_DATA0 HS2_DATA1 HS2_DATA2 HS2_DATA3 | An SD/SDIO/MMC host controller is available on ESP32, which supports the following features: • Secure Digital memory (SD mem Version 3.0 and Version 3.01) • Secure Digital I/O (SDIO Version 3.0) • Consumer Electronics Advanced Transport Architecture (CE-ATA Version 1.1) • Multimedia Cards (MMC Version 4.41, eMMC Version 4.5 and Version 4.51) The controller allows up to 80 MHz clock output in three different data-bus modes: 1-bit, 4-bit, and 8-bit. It supports two SD/SDIO/MMC4.41 cards in a 4-bit data-bus mode. It also supports one SD card operating at 1.8V. |
Motor PWM | PWM0_OUT0~2 PWM1_OUT_IN0~2 PWM0_FLT_IN0~2 PWM1_FLT_IN0~2 PWM0_CAP_IN0~2 PWM1_CAP_IN0~2 PWM0_SYNC_IN0~2 PWM1_SYNC_IN0~2 | Any GPIO Pins | Three channels of 16-bit timers generate PWM waveforms. Each channel has a pair of output signals, three fault detection signals, three event-capture signals, and three sync signals. |
SDIO/SPI Slave Controller | SD_CLK SD_CMD SD_DATA0 SD_DATA1 SD_DATA2 SD_DATA3 | MTMS MTDO GPIO2 GPIO4 MTDI MTCK | ESP32 integrates a SD device interface that conforms to the industry-standard SDIO Card Specification Version 2.0 and allows a host controller to access the SoC, using the SDIO bus interface and protocol. ESP32 acts as the slave on the SDIO bus. |
UART | U0RXD_in U0CTS_in U0DSR_in U0TXD_out U0RTS_out U0DTR_out U1RXD_in U1CTS_in U1TXD_out U1RTS_out U2RXD_in U2CTS_in U2TXD_out U2RTS_out | Any GPIO Pins | ESP32 has three UART interfaces, i.e., UART0, UART1, and UART2, which provide asynchronous communication (RS232 and RS485) and IrDA support, communicating at a speed of up to 5 Mbps. |
I2C | I2CEXT0_SCL_in I2CEXT0_SDA_in I2CEXT1_SCL_in I2CEXT1_SDA_in I2CEXT0_SCL_out I2CEXT0_SDA_out I2CEXT1_SCL_out I2CEXT1_SDA_out | Any GPIO Pins | ESP32 has two I2C bus interfaces which can serve as I2C master or slave, depending on the user’s configuration. The I2C interfaces support: • Standard mode (100 Kbit/s) • Fast mode (400 Kbit/s) • Up to 5 MHz, yet constrained by SDA pull-up strength • 7-bit/10-bit addressing mode • Dual addressing mode Users can program command registers to control I2C interfaces so that they have more flexibility. |
LED PWM | ledc_hs_sig_out0~7 ledc_ls_sig_out0~7 | Any GPIO Pins | The LED PWM controller can generate 16 independent channels of digital waveforms with configurable periods and duties. |
I2S | I2S0I_DATA_in0~15 I2S0O_BCK_in I2S0O_WS_in I2S0I_BCK_in I2S0I_WS_in I2S0I_H_SYNC I2S0I_V_SYNC I2S0I_H_ENABLE I2S0O_BCK_out I2S0O_WS_out I2S0I_BCK_out I2S0I_WS_out I2S0O_DATA_out0~23 I2S1I_DATA_in0~15 I2S1O_BCK_in I2S1O_WS_in I2S1I_BCK_in I2S1I_WS_in I2S1I_H_SYNC I2S1I_V_SYNC I2S1I_H_ENABLE I2S1O_BCK_out I2S1O_WS_out I2S1I_BCK_out I2S1I_WS_out I2S1O_DATA_out0~23 | Any GPIO Pins | Two standard I2S interfaces are available in ESP32. They can be operated in master or slave mode, in full-duplex and half-duplex communication modes, and can be configured to operate with an 8-/16-/32-/48-/64-bit resolution as input or output channels. BCK clock frequency, from 10 kHz up to 40 MHz, is supported. |
RMT (Infrared remote Controller) | RMT_SIG_IN0~7 RMT_SIG_OUT0~7 | Any GPIO Pins | The infrared remote controller supports eight channels of infrared remote transmission and receiving. By programming the pulse waveform, it supports various infrared protocols. Eight channels share a 512 x 32-bit block of memory to store the transmitting or receiving waveform. |
General Purpose SPI | HSPIQ_in/_out HSPID_in/_out HSPICLK_in/_out HSPI_CS0_in/_out HSPI_CS1_out HSPI_CS2_out VSPIQ_in/_out VSPID_in/_out VSPICLK_in/_out VSPI_CS0_in/_out VSPI_CS1_out VSPI_CS2_out | Any GPIO Pins | Standard SPI consists of clock, chip-select, MOSI and MISO. These SPIs can be connected to LCD and other external devices. They support the following features: • Both master and slave modes; • Four sub-modes of the SPI transfer format; • Configurable SPI frequency. |
Parallel QSPI | SPIHD SPIWP SPICS0 SPICLK SPIQ SPID HSPICLK HSPICS0 HSPIQ HSPID HSPIHD HSPIWP VSPICLK VSPICS0 VSPIQ VSPID VSPIHD VSPIWP | SD_DATA_2 SD_DATA_3 SD_CMD SD_CLK SD_DATA_0 SD_DATA_1 MTMS MTDO MTDI MTCK GPIO4 GPIO2 GPIO18 GPIO5 GPIO19 GPIO23 GPIO21 GPIO22 | Supports Standard SPI, Dual SPI, and Quad SPI that can be connected to the external flash and SRAM |
EMAC | EMAC_TX_CLK EMAC_RX_CLK EMAC_TX_EN EMAC_TXD0 EMAC_TXD1 EMAC_TXD2 EMAC_TXD3 EMAC_RX_ER EMAC_RX_DV EMAC_RXD0 EMAC_RXD1 EMAC_RXD2 EMAC_RXD3 EMAC_CLK_OUT EMAC_CLK_OUT_180 EMAC_TX_ER EMAC_MDC_out EMAC_MDI_in EMAC_MDO_out EMAC_CRS_out EMAC_COL_out | GPIO0 GPIO5 GPIO21 GPIO19 GPIO22 MTMS MTDI MTCK GPIO27 GPIO25 GPIO26 U0TXD MTDO GPIO16 GPIO17 GPIO4 Any GPIO Pins Any GPIO Pins Any GPIO Pins Any GPIO Pins Any GPIO Pins | An IEEE-802.3-2008-compliant Media Access Controller (MAC) is provided for Ethernet LAN communications. ESP32 requires an external physical interface device (PHY) to connect to the physical LAN bus (twisted-pair, fiber, etc.). |
Pulse Counter | pcnt_sig_ch0_in0 pcnt_sig_ch1_in0 pcnt_ctrl_ch0_in0 pcnt_ctrl_ch1_in0 pcnt_sig_ch0_in1 pcnt_sig_ch1_in1 pcnt_ctrl_ch0_in1 pcnt_ctrl_ch1_in1 pcnt_sig_ch0_in2 pcnt_sig_ch1_in2 pcnt_ctrl_ch0_in2 pcnt_ctrl_ch1_in2 pcnt_sig_ch0_in3 pcnt_sig_ch1_in3 pcnt_ctrl_ch0_in3 pcnt_ctrl_ch1_in3 pcnt_sig_ch0_in4 pcnt_sig_ch1_in4 pcnt_ctrl_ch0_in4 pcnt_ctrl_ch1_in4 pcnt_sig_ch0_in5 pcnt_sig_ch1_in5 pcnt_ctrl_ch0_in5 pcnt_ctrl_ch1_in5 pcnt_sig_ch0_in6 pcnt_sig_ch1_in6 pcnt_ctrl_ch0_in6 pcnt_ctrl_ch1_in6 pcnt_sig_ch0_in7 pcnt_sig_ch1_in7 pcnt_ctrl_ch0_in7 pcnt_ctrl_ch1_in7 | Any GPIO Pins | The pulse counter captures pulse and counts pulse edges through seven modes. It has eight channels, each of which captures four signals at a time. The four input signals include two pulse signals and two control signals. When the counter reaches a defined threshold, an interrupt is generated |
TWAI | twai_rx twai_tx twai_bus_off_on twai_clkout | Any GPIO Pins | Compatible with ISO 11898-1 protocol (CAN Specification 2.0) |
CONCLUSION
We have understood the basic diagrams and pin configurations of ESP-32, ESP-32 WROOM 32, and ESP-32 WROOM 32 DEV-KIT.
References
- https://www.researchgate.net/figure/ESP32-dual-core-IoT-ready-MCU-arhitecture-6_fig4_316173015
- https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
- https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf
- Developing IoT Projects with ESP-32 by Vedat Ozen Onar
Author: Kunal Gupta
Author