ESP32-CAM AI-Thinker Pinout Guide: GPIOs Usage Explained

The ESP32-CAM is a development board with an ESP32-S chip, an OV2640 camera, a microSD card slot, and several GPIOs to connect peripherals. In this guide, we’ll take a look at the ESP32-CAM GPIOs and how to use them.

Pinout Diagram

The following image shows the pinout diagram for the ESP32-CAM AI-Thinker.

ESP32-CAM AI Thinker module board Pinout diagram GPIOs name

Schematic Diagram

The following figure shows the schematic diagram for the ESP32-CAM.

Image Source

You can download a PDF file with better resolution on this GitHub repository.

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 the ESP32-CAM through the 3.3V or 5V pins. However, many people reported errors when powering the ESP32-CAM with 3.3V, so we always advise to power the ESP32-CAM through the 5V pin.

Power output pin

There’s also the pin labeled on the silkscreen as VCC (colored with a yellow rectangle). You should not use that pin to power the ESP32-CAM. That is an output power pin. It can either output 5V or 3.3V.

In our case, the ESP32-CAM outputs 3.3V whether it is powered with 5V or 3.3V. Next to the VCC pin, there are two pads. One labeled as 3.3V and other as 5V.

ESP32-CAM Camera AI Think Module VCC Power Pins

If you look closely, you should have a jumper on the 3.3V pads. If you want to have an output of 5V on the VCC pin, you need to unsolder that connection and solder the 5V pads.

Serial Pins

GPIO 1 and GPIO 3 are the serial pins (TX and RX, respectively). Because the ESP32-CAM doesn’t have a built-in programmer, you need to use these pins to communicate with the board and upload code.

The best way to upload code to the ESP32-CAM is using an FTDI programmer.

Learn how to upload code to the ESP32-CAM AI-Thinker.

You can use GPIO 1 and GPIO 3 to connect other peripherals like outputs or sensors after uploading the code. However, you won’t be able to open the Serial Monitor to check if everything is going well with your setup.

GPIO 0

GPIO 0 determines whether the ESP32 is in flashing mode or not. This GPIO is internally connected to a pull-up 10k Ohm resistor.

When GPIO 0 is connected to GND, the ESP32 goes into flashing mode and you can upload code to the board.

  • GPIO 0 connected to GND » ESP32-CAM in flashing mode

To make the ESP32 run “normally”, you just need to disconnect GPIO 0 from GND.

GPIO 16

GPIO 16 is connected to the internal PSRAM in many ESP32-CAM boards. If you want to use that pin to connect to peripherals while using the camera, make sure to disable PSRAM in your code.

MicroSD Card Connections

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

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

If you’re not using the microSD card, you can use these pins as regular inputs/outputs. You can take a look at the ESP32 pinout guide to see the features of these pins.

To free up some GPIOs, you can set the microSD card to run in 1-bit mode. In that case, you’ll free up GPIOs 12 and 13.

All these GPIOs are RTC and support ADC: GPIOs 2, 4, 12, 13, 14, and 15.

Flashlight (GPIO 4)

The ESP32-CAM has a bright built-in LED that can work as a flash when taking photos. That LED is internally connected to GPIO 4.

That GPIO is also connected to the microSD card slot, so you may have trouble when trying to use both at the same time. The flashlight will light up when using the microSD card.

Note: one of our readers shared that if you initialize the microSD card as follows, you won’t have this problem because the microSD card won’t use that data line.*

SD_MMC.begin("/sdcard", true)

* we found that this works and that the LED won’t make that flash effect. However, the LED remains on with low brightness – we’re not sure if we are missing something.

GPIO 33 – Built-in Red LED

Next to the RST button, there’s an on-board red LED. That LED is internally connected to GPIO 33. You can use this LED to indicate that something is happening. For example, turn on that red LED when the Wi-Fi is connected.

That LED works with inverted logic, so you send a LOW signal to turn it on and a HIGH signal to turn it off.

You can experiment by uploading the following snippet and see if you get that LED glowing.

void setup() { pinMode(33, OUTPUT); } void loop() { digitalWrite(33, LOW); }

Camera Connections

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

OV2640 CAMERAESP32Variable name in code
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

[eBook] Build ESP32-CAM Projects using Arduino IDE

Learn how to program and build 17 projects with the ESP32-CAM using Arduino IDE DOWNLOAD »

Learn how to program and build 17 projects with the ESP32-CAM using Arduino IDE DOWNLOAD »

Wrapping Up

We hope you’ve found this guide for the ESP32-CAM GPIOs useful. If you have any tips or more info about the ESP32-CAM GPIOs, write a comment below.

We have several projects with the ESP32-CAM that you may like:

  • Video Streaming, Face Detection and Face Recognition
  • ESP32 IP CAM – Video Streaming (Home Assistant and Node-RED)
  • PIR Motion Detector with Photo Capture
  • Take Photo, Save to SPIFFS and Display in Web Server
  • Best ESP32 Camera Development Board
  • Build ESP32-CAM Projects (eBook)
  • Read all our ESP32-CAM Projects, Tutorials and Guides

Thanks for reading.

Tag » How Does The Cam Pin Work