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.
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 Pin | Function | Type | Recommended Usage |
---|---|---|---|
EN | Enabled | This requires to be set to HIGH when uploading a program. Has a physical button. | |
VP | GPIO(36) | This is an input only pin. Can also be used for Analog input. | |
VN | GPIO (39) | This is an input only pin. Can also be used for Analog input. | |
34 | GPIO | This is an input only pin. Can also be used for Analog input. | |
35 | GPIO | This is an input only pin. Can also be used for Analog input. | |
32 | GPIO | This is an input only pin. Can also be used for Analog input. | |
33 | GPIO | This is an input only pin. Can also be used for Analog input. | |
25 | GPIO | ||
26 | GPIO | ||
27 | GPIO | ||
14 | SPI-CLK | GPIO | Use for SPI communication. |
12 | SPI-CIPO | GPIO | Use for SPI communication. |
13 | SPI-COPI | GPIO | Use for SPI communication. |
15 | SPI-CS | GPIO | Use for SPI communication. |
2 | GPIO | ||
4 | GPIO | ||
16 | GPIO | ||
17 | GPIO | ||
5 | SPI-CS | GPIO | Use for SPI communication. |
18 | SPI-CLK | GPIO | Use for SPI communication. |
19 | SPI-CIPO | GPIO | Use for SPI communication. |
21 | I2C-SDA | GPIO | While any GPIO pin can be configured as I2C SDA and SCL this is commonly used by convention. |
RX | UART-RX | Keep free for code upload and serial communication with the computer. | |
TX | UART-TX | Keep free for code upload and serial communication with the computer. | |
22 | I2C-SCL | GPIO | While any GPIO pin can be configured as I2C SDA and SCL this is commonly used by convention. |
23 | SPI-COPI | GPIO | Use for SPI communication. |