Basics Project 084d AI-Thinker ESP32-CAM Pinout Guide


Basics: Project 084d

Project name:  AI-Thinker ESP32-CAM Pinout Guide

Tags: Arduino, Arduino Uno, Ai-Thinker, ESP32-CAM, Development Board with camera, OV2640, OV7670, Pinout Guide, how to use pins of ESP32-CAM development board

Attachments: sketch

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. ESP32-CAM Development Board with camera 1 set

esp32-cam

2. Arduino IDE ( you can download it from here  )

3. USB to TTL/Serial adaptor/converter 1 pc

USB to TTL converters
USB TO TTL converters

4. Jumper cables F-F

5. Micro SD card and SD card adapter 1 pc

6. WiFi AntennaCompact Internal WiFi Antenna with U.FL connector and 5.9 inch cable 1 pc (optional)

7. External 5V power supply for ESP32-CAM 1 pc (optional)

General

We will learn in this project we will learn how to use the ESP32-CAM GPIOs.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the ESP32-CAM Development Board with camera

The ESP32-CAM has a very competitive small-size camera module that can operate independently as a minimum system with a footprint of only 27*40.5*4.5mm and a deep sleep current of up to 6mA.

ESP32-CAM can be widely used in various IoT applications. It is suitable for home smart devices, industrial wireless control, wireless monitoring, QR wireless identification, wireless positioning system signals and other IoT applications. It is an ideal solution for IoT applications.

ESP32-CAM adopts DIP package and can be directly inserted into the backplane to realize rapid production of products, providing customers with high-reliability connection mode, which is convenient for application in various IoT hardware terminals.

The ESP32-CAM Development Board with camera doesn’t come with a USB connector, so you need an USB to TTL/Serial adaptor/converter to upload code through the  serial pins (U0R and U0T pins).

Features:

  • The smallest 802.11b/g/n Wi-Fi BT SoC Module
  • Low power 32-bit CPU,can also serve the application processor
  • Up to 160MHz clock speed,Summary computing power up to 600 DMIPS
  • Built-in 520 KB SRAM, external 4MPSRAM
  • Supports UART/SPI/I2C/PWM/ADC/DAC
  • Support OV2640 and OV7670 cameras,Built-in Flash lamp.
  • Support image WiFI upload
  • Support TF card
  • Supports multiple sleep modes.
  • Embedded Lwip and FreeRTOS
  • Supports STA/AP/STA+AP operation mode
  • Support Smart Config/AirKiss technology
  • Support for serial port local and remote firmware upgrades (FOTA)

Specifications:

  • Dimensions 40.5mm x27mm x4.5mm
  • Weight G.W 20g
  • Battery Exclude
  • Package DIP-16
  • SPI Flash Default 32Mbit
  • RAM 520KB SRAM +4M PSRAM
  • Bluetooth Bluetooth 4.2 BR/EDR and BLE standards
  • Wi-Fi 802.11 b/g/n/
  • Support interface UART,SPI,I2C,PWM
  • Support TF card Maximum support 4G
  • IO port 9
  • UART Baudrate Default 115200 bps
  • Image Output Format JPEG( OV2640 support only ), BMP,GRAYSCALE
  • Spectrum Range 2412 ~2484MHz
  • Antenna Onboard PCB antenna, gain 2dBi
  • Transmit Power 802.11b: 17±2 dBm (@11Mbps); 802.11g: 14±2 dBm (@54Mbps); 802.11n: 13±2 dBm (@MCS7)
  • Receiving Sensitivity CCK, 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 Dissipation Turn off the flash lamp:180mA@5V; Turn on the  flash lamp and turn on the brightness to the maximum:310mA@5V; Deep-sleep: Minimum power consumption can be achieved 6mA@5V; Moderm-sleep: Minimum up to 20mA@5V; Light-sleep: Minimum up to 6.7mA@5V
  • Security WPA/WPA2/WPA2-Enterprise/WPS
  • Power Supply Range 5V
  • Operating Temperature -20 ℃ ~ 85 ℃
  • Storage Environment -40 ℃ ~ 90 ℃ , < 90%RH

In the package you will get 1 x ESP32-CAM Development Board, 1x camera Module-OV2640-FPC-24P-0.5mm-21mm- 2 Megapixel and 2x headers-2.54mm-1x8pin.  

On-Board vs IPEX Antenna

ESP32-CAM Development Board with camera can be with the antenna jumper set for an external antenna or for the on-board antenna. You can see the two different settings below:

If you have a low frame rate or poor reception this might be the problem. You can either move the jumper with a bit of very careful soldering or buy an IPEX WiFi antenna which will improve the signal.

Applications:

  • We can easily build a simple camera with this board and save the photos in an SD card using the embedded SD card slot the board offers.
  • We can then modify this project to detect humans and save an image when one is detected.
  • We can recognize human faces and act accordingly.
  • We can build a surveillance camera with the ESP32 Cam board.
  • We can also stream video using this board.

You can find the ESP32-CAM schematic below:

https://github.com/AcoptexCom/ESP32CAM_Projects/blob/master/ESP32CAM_GPIOS/ESP32_CAM_V1.6.pdf

Signals and connections of the ESP32-CAM Development Board with camera

ESP32-CAM pinout:

Power Pins

The ESP32-CAM comes with three GND pins (colored in black color) and two power pins (colored with red color): 3.3V and 5V. You can power your ESP32-CAM through the 3.3V or 5V pins. Many people report errors when they do power the ESP32-CAM development board with 3.3V, so we advise to power the ESP32-CAM development board through the 5V pin.

Power output pin

You can also see the pin labeled as VCC (colored with a yellow rectangle). We can not use that pin to power the ESP32-CAM development board as that is an output power pin. It can output 3.3V or 5V. In our case, the ESP32-CAM development board outputs 3.3V whether it is powered with 5V or 3.3V. There are two pads (one labeled as 3.3V and other as 5V) next to the VCC pin. If you look more closely, you will see that there is a jumper on the 3.3V pads. If you want to have an output of 5V on the VCC pin, you need to unsolder this connection and solder the 5V pads.

ESP32-CAM GPIOS

Serial Pins

GPIO1 (U0TXD) and GPIO3 (U0RXD) are the serial pins (TX and RX, respectively). As the ESP32-CAM development board doesn’t have a built-in programmer, we need to use these pins to communicate with the board and upload our code. The best way to upload code to the ESP32-CAM development board is using an FTDI programmer. You can use GPIO1 and GPIO3 to connect other peripherals like outputs or sensors after uploading the code. But you won’t be able to open the Serial Monitor and see if everything is good with your setup.

GPIO 0

GPIO0 determines whether the ESP32-CAM development board is in flashing mode or not. This GPIO is internally connected to a pull-up 10k Ohm resistor. When GPIO0 is connected to GND, the ESP32-CAM development board will be in flashing mode and you can upload code to it. To go back to normal operation you just need to disconnect GPIO0 from GND on the ESP32-CAM development board.

GPIO16

GPIO16 is , by default, an UART pin. You can use it as input or output – just define this in your code. As it is not used by the camera or by the microSD card, then it is one of the most suitable pins to connect peripherals (pushbutton, LED, relay module and so on). This is not an ADC pin, so it can not be used to read analog sensors, and it’s not a RTC GPIO, so it can not be used as an external wake-up source.

MicroSD Card

The following pins are used to interface with the microSD card when it is in use.

MicroSD cardESP32-CAM development board
CLKGPIO 14
CMDGPIO 15
DATA0GPIO 2
DATA1 / flashlightGPIO 4
DATA2GPIO 12
DATA3GPIO 13

If you are not using the microSD card, you can use these GPIO pins as normal inputs or outputs. All these pins are RTC and support ADC: GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15.

GPIO4 (Flashlight)

The ESP32-CAM development board has a very bright built-in LED that can work as a flash when taking pictures. This LED is internally connected to GPIO4. This pin is also connected to the microSD card slot, so you may have troubles when try to use both at the same time – the flashlight will light up when using the microSD card. Please note that you can initialize the microSD card as follows and you won’t have this problem as the microSD card won’t use that data line: SD_MMC.begin(“/sdcard”, true). It works and the LED will not make that flash effect. However, the LED remains on with low brightness.

GPIO33 (Built-in Red LED)

There is an on-board red LED close to the RST button. This red LED is internally connected to the GPIO33. You can use this LED for the indication that something is happening (for example, if the Wi-Fi is connected or not).

ESP32-CAM GPIOS

It works with inverted logic, so to turn it on (LOW signal) and to turn it off ( HIGH signal).

Camera Connections

The connections between the camera and the AI-Thinker ESP32-CAM are shown in the table below.

OV2640 cameraESP32-CAMVariable name
D0GPIO 5Y2_GPIO_NUM
D1GPIO 18Y3_GPIO_NUM
D2GPIO 19Y4_GPIO_NUM
D3GPIO 21Y5_GPIO_NUM
D4GPIO 36Y6_GPIO_NUM
D5GPIO 39Y7_GPIO_NUM
D6GPIO 34Y8_GPIO_NUM
D7GPIO 35Y9_GPIO_NUM
XCLKGPIO 0XCLK_GPIO_NUM
PCLKGPIO 22PCLK_GPIO_NUM
VSYNCGPIO 25VSYNC_GPIO_NUM
HREFGPIO 23HREF_GPIO_NUM
SDAGPIO 26SIOD_GPIO_NUM
SCLGPIO 27SIOC_GPIO_NUM
POWER PINGPIO 32PWDN_GPIO_NUM

So, the pin definition for the ESP32-CAM AI-Thinker on the Arduino IDE should be as follows:define PWDN_GPIO_NUM 32

  • #define RESET_GPIO_NUM -1
  • #define XCLK_GPIO_NUM 0
  • #define SIOD_GPIO_NUM 26
  • #define SIOC_GPIO_NUM 27
  • #define Y9_GPIO_NUM 35
  • #define Y8_GPIO_NUM 34
  • #define Y7_GPIO_NUM 39
  • #define Y6_GPIO_NUM 36
  • #define Y5_GPIO_NUM 21
  • #define Y4_GPIO_NUM 19
  • #define Y3_GPIO_NUM 18
  • #define Y2_GPIO_NUM 5
  • #define VSYNC_GPIO_NUM 25
  • #define HREF_GPIO_NUM 23
  • #define PCLK_GPIO_NUM 22

Summary

We have learnt in this project how to use the ESP32-CAM GPIOs. Thank you for reading and supporting us.

Libraries:

  • None

Project resources:

  • None

AcoptexCom

Leave a Reply

Your email address will not be published.