ESP32-CAM AI-Thinker Board – All about GPIO Pins

ESP32-CAM AI-Thinker Board - All about GPIO Pins
ESP32-CAM AI-Thinker development board Pinout, Pin configuration diagram, GPIO Pins, Features and How to Program with FTDI cable

This tutorial is a guide to AI thinker ESP32-CAM development board. We will discuss pinout, features, specifications and see how to get started with ESP32- CAM development board.

ESP32-CAM AI-Thinker Introduction

The world has been revolving around IoTs i.e., Internet of Things for quite a while now. From the hobbyists to the innovators, everyone is interested in Smart technology, designing different prototypes and products, and launching them in the market. ESP32 Series chips are one of the popular intelligent modules for IoTs. ESP32-CAM AI-Thinker is the advanced version of ESP8266-01 launched by Espressif with many features. The ultra-small, low-power module comes with two high-performance 32-bit LX6 CPUs with a 7-stage pipeline architecture.

Peripherals

ESP32-CAM has integrated with Wi-Fi, Bluetooth and can be used with OV2640 or OV7670 cameras. The ESP32 IC has high-resolution ADCs, SPI, I2C, and UART protocols for information communication. The module has an inbuilt Hall sensor, temperature sensor, and touch sensors, and watchdog timers. RTC can be operated in different modes. The module has a maximum clock frequency of 160 MHz that means the computing power up to 600 DMPIS. Furthermore, it is quite durable and reliable when it comes to internet connectivity.

Applications

ESP32-CAM AI-Thinker module has a never-ending list of applications like home automation, intelligent devices, positioning systems, security systems and perfect for IoT applications.

ESP32-CAM AI-Thinker Components

This development board is a 27*40.5*4.5 DIP style PCB Board. The following figure shows the components of the ESP32-CAM board from both top and bottom side.

ESP32-CAM AI-Thinker module consists of different parts. These areas described below:

  1. ESP32-S Chip: The module is a main chip contains two high-performance 32-bit LX6 CPUs with a 7-stage pipeline architecture and used for all the processing and functioning.
  2. IPEX block output: The printed IPEX connects GSM antennas to transmit signals.
  3. Tantalum capacitor: The tantalum capacitor is majorly used on small size modules. They are durable and provide power supply filtering for fine signal quantity.
  4. Reset button: When pressed, the reset button restarts the code executed on the module.
  5. Voltage regulator chip: The voltage regulator chip on the module maintains the output voltage despite the fluctuations in the input supply. It regulates the voltage to 3.3 volts.
  6. PSRAM: A low-power Pseudo-Random Access Memory of 4MB is incorporated in the module for fast processing of the instructions. It helps the camera to run smoothly.
  7. TF Card Holder: ESP32 series are embedded with a micro-SD card holder to store the data. All the transmission takes place through the Serial Peripheral Interface.
  8. FPC connector: To mount the camera, the ESP32 module contains a flexible printed circuit connector. Their fine pitch is responsible for signal reliability.
  9. Flash Light: The flash lamp produces electric pulses which work as a flash for the camera so that it can capture clear images.

Schematic Diagram

Image Credit

ESP32-CAM AI-Thinker Pinout

The following diagram shows the pinout of the ESP32-CAM AI-Thinker Module:

This section describes the pinout of the ESP32-CAM AI-Thinker Module. The ESP32-S chip has a total of 34 pins but only 16 pins are exposed to the pinout headers.

Power pins

The module has three ground pins and two positive power supply pins such as 5V and 3.3V pins. These pins can be used to power the ESP32-CAM AI-Thinker module. But it is recommended not to power this development bord with 3.3V pin, it does not provide stable power to board.

Power Output Pin

ESP32-CAM also provide one power output pin as shown in yellow color in the pinout diagram above. This is a VCC pin that can output either 5V or 3.3V. According to Jumper connection on ESP32-CAM, VCC pin provides 3.3V output.

GPIO33 – Built-in Red LED

AI-Thinker board also has one onboard RED LED. You can find this LED next to the reset button. This built-in red LED is connected with GPIO 33 in logic low active state. That means if we want to turn on LED, we drive GPIO 33 to logic low level. Similarly, to turn off LED, we drive GPIO 33 to active high state.

UART pins

Almost all the GPIO pins of ESP32-CAM are multi-purpose pins. GPIO1 and GPIO3 has alternate functions for the serial transmission and reception of the data for UART port, respectively. AI-Thinker board does not come with onboard programmer. Therefore, these UART pins are used to program and communicate with the PC to upload the code.

Pin NameFunction
GPIO1U0TXD (UART Transmission pin)
GPIO3UORXD (UART Reception pin)

We can use an FTDI cable to flash code to ESP32-CAM by using UART pins.

GPIO0 pin – Flash Mode Selection

This pin determines the mode of the module such as flash or normal mode. In flashing mode, GPIO0 is pulled low which means it should be connected to the ground. When GPIO0 is connected to ground, ESP32-CAM goes into flashing mode and we can flash the code. After flashing the code to board, we should disconnect the GPIO0 from the ground to run the module normally or we say it enters the normal mode.

  • GPIO0 connected to ground à ESP32-CAM in Flash Mode
  • GPIO0 not connected to ground à ESP32-CAM in normal program execution mode

SD Card pins

As discussed in the previous section, ES32-CAM board has built-in SD card connector which can used to connect an SD card. These GPIO pins use for connections with micro SD cards while reading and writing data to SD card. These GPIO pins can be used as typical I/O pins if the SD card is not in use.

Pin NameSD Card Connection
GPIO2Data0 pin(RTC & ADC supported)
GPIO4/Flash lampData1 pin(RTC & ADC supported)
GPIO12Data2 pin(RTC & ADC supported)
GPIO13Data3 pin(RTC & ADC supported)
GPIO14CLK(RTC & ADC supported)
GPIO15CMD(RTC & ADC supported)

Note: If you are not using SD card in your ESP32-CAM project, you can use these GPIO pins for other functions such as digital input, digital output, ADC, and RTC.

Flash LED pin

ESP32-CAM also has built-in high brightness flashlight. This flashlight can be used with a Camera while taking picture in darkness. GPIO4 is connected to an embedded flash lamp which (if programmed so) flashes when the camera captures the pictures. GPIO4 is also connected to the SD card, so it might cause difficulty accessing both at the same time. That means flashlight may glow unwanted while using SD card.

Learn more

If you want to stop the flashlight from lighting up when using SD card, you can instruct the program to do not use GPIO4 as a data line for SD card by using this line:

SD_MMC.begin("/sdcard", true)

Camera Connector Pins

The following table lists the GPIO pins connections with OV2640 Camera and their respective variable names that we will use in our program.

OV2640 CAMERAESP32Variable name in code
D0GPIO5Y2_GPIO_NUM
D1GPIO18Y3_GPIO_NUM
D2GPIO19Y4_GPIO_NUM
D3GPIO21Y5_GPIO_NUM
D4GPIO36Y6_GPIO_NUM
D5GPIO39Y7_GPIO_NUM
D6GPIO34Y8_GPIO_NUM
D7GPIO35Y9_GPIO_NUM
XCLKGPIO0XCLK_GPIO_NUM
PCLKGPIO22PCLK_GPIO_NUM
VSYNCGPIO25VSYNC_GPIO_NUM
HREFGPIO23HREF_GPIO_NUM
SDAGPIO 26SIOD_GPIO_NUM
SCLGPIO 27SIOC_GPIO_NUM
POWER PINGPIO 32PWDN_GPIO_NUM

ESP32-CAM Features and Specifications

The technical details and specifications of this extremely handy module are listed below:

FeatureAvailability
ModuleESP32-CAM AI-Thinker
Processor32-bit LX6
Architecture7-stage pipeline
SPI Flash32-bit
SRAM520 KB
PSRAM4MB
Operating Temperature-200C – 850C
Operating Voltage5 Volts
UART1
UART Baud Rate115200 bps
SPIYes
I2CYes
PWMYes
Wi-fi802.11 b/g/n
Power Transmission802.11 b: 17±2 dBm at 11Mbps 802.11 g: 14±2 dBm at 54Mbps 802.11 n: 13±2 dBm at MCS7
BluetoothBluetooth 4.2 BR/EDR with BLE standards
Support TF Card4G Maximum Support
SecurityWPA/WPA2/WPA2-Enterprise/WPS
Output Image FormatBMP, GRAYSCALE, JPEG(OV2640 support only)
Spectrum Range2412 MHz – 2484 MHz
On Board PCB Antenna Gain2dBi
Input/Output port9
Reception SensitivityCCK, 1 Mbps: -90dBm CCK, 11 Mbps: -85dBm 6 Mbps (1/2 BPSK): -88dBm 54 Mbps (3/4 64-QAM): -70dBm MCS7 (65 Mbps, 72.2 Mbps): -67dBm 
Power DissipationTurn off the flash: 180mA at 5V Turn on the flash with maximum brightness: 310mA      at 5V Deep-sleep mode: the lowest power consumption can reach 6mA@5V Modem-sleep mode: < 20mA at 5V Light-sleep mode: <6.7mA at 5V
Clock Frequency240 MHz (max)
Package TypeDIP-16
Package Size27*40.5*4.5(±0.2)mm

Detailed Features

Some the additional prominent features of this amazing module are described as under:

Learn more

  • Supports Smart Config/AirKiss Technology and has capacitive GPIO pins.
  • 18 high-resolution analog-to-digital converters.
  • 2 digital-to-analog converters with a resolution power of 8-bits.
  • Consumes power up to 600 DMIPS at 160 MHz of clock frequency.
  • The module has high-speed WiFi with a speed of 2.4 GHz.
  • ESP32 module contains 2 I2C, 3 SPI, and 3 UART for fast serial transmission.
  • It also has 16 PWM channels to output pulse-width modulated signals.
  • It has a TF holder and supports WiFi image upload.
  • ESP32 supports 4 different operating modes i.e s STA/AP/STA+AP
  • Embedded Lwip and FreeRTOS.
  • RTC supported to wake up the module from Deep-sleep mode.
  • A built-in flashlight is provided in the module to produce flashes to capture bright clear images.
  • A CMOS technology IC has an adjustable output power amplifier
  • ESP32 has a low duty cycle to reduce power consumption making it power efficient.

How to program ESP32-CAM AI-Thinker?

Unlike an ESP32 dev kit or other ESP32 development boards, the ESP32-CAM AI-Thinker board does not have any built-in programmer to burn the code to the ESP32-S chip. Therefore, to upload the code, we must use an external USB to UART Converter or an FTDI Programmer.

The following diagram shows the connection between ESP32-CAM and an FTDI cable. We use UART pins of ESP32-CAM to connect with an FTDI cable.

ESP32-CAMFTDI Cable
GNDGND
5VVCC (5V)
U0RX/GPIO3TX
U0TX/GPIO1RX
GPIO0GND

In next tutorial, we will see how to install ESP32-CAM add-on in Arduino IDE and how to upload sample example code to AI-Thinker board using FTDI cable.

In Summary, in this tutorial, we learned the followings:

Learn more

  • ESP32-CAM AI-Thinker Introduction, peripherals and applications
  • Pinout Diagram
  • Power pins and Power Output Pin
  • GPIO33 – Built-in Red LED
  • UART pins
  • GPIO0 pin – Flash Mode Selection
  • SD Card pins
  • Flash LED pin
  • Camera Connector Pins
  • How to program ESP32-CAM AI-Thinker?