ESP32-CAM Pinout: Camera, SD Card, and Free GPIO Pins

ESP32-CAM board with OV2640 camera module and pin headers. Caption: ESP32-CAM board with OV2640 camera module. Description: Front view of the ESP32-CAM board used in this pinout guide.

ESP32-CAM Pinout: Camera, SD Card, and Free GPIO Pins

Answer in brief: The ESP32-CAM uses most of its GPIO pins for the camera and the microSD card. Only a small set of pins stays free for sensors and outputs. This guide maps the camera pins, the SD card pins, and the free pins. It also covers power, boot mode, and safe wiring.

Quick Facts

Item Detail Source
Board AI-Thinker ESP32-CAM Espressif ESP32 Series Datasheet
Logic voltage 3.3 volts Espressif ESP32 Series Datasheet
USB port None on board ESP32-CAM camera driver pin map
Programming pins GPIO1 TX and GPIO3 RX ESP32-CAM camera driver pin map
Flash mode pin GPIO0 held low at reset ESP32-CAM camera driver pin map
Camera pins used 15 pins ESP32-CAM camera driver pin map
SD card pins in 4-bit mode 6 pins ESP32-CAM camera driver pin map
SD card pins in 1-bit mode 3 pins ESP32-CAM camera driver pin map
Free pins with no SD card 6 pins ESP32-CAM camera driver pin map

ESP32-CAM Pinout Table

This table is an original pinout table built from the source data listed below. It is not a copied image. Check the board print against this table before you wire anything. Some boards print VCC on one header and 5V on the other header.

Header pin label GPIO Function Notes
5V Power 5 volt input Use a stable 5 volt supply
GND Power Ground Common ground for all wiring
GPIO12 GPIO12 SD DATA2, ADC, touch Free only when SD card is not used
GPIO13 GPIO13 SD DATA3, ADC, touch Free only when SD card is not used
GPIO15 GPIO15 SD CMD, ADC, touch, strapping Free only when SD card is not used
GPIO14 GPIO14 SD CLK, ADC, touch Free only when SD card is not used
GPIO2 GPIO2 SD DATA0, ADC, touch, strapping Free only when SD card is not used
GPIO4 GPIO4 SD DATA1, ADC, touch Free only when SD card is not used
3V3 Power 3.3 volt output Do not use as a 5 volt input
GPIO16 GPIO16 PSRAM chip select Do not use for other wiring
GPIO0 GPIO0 Camera XCLK, strapping, boot Hold low at reset for flash mode
GND Power Ground Common ground for all wiring
VCC Power 5 volt input Same 5 volt rail as the 5V pin
U0R GPIO3 UART receive Connect to adapter TX for programming
U0T GPIO1 UART transmit Connect to adapter RX for programming
GND Power Ground Common ground for all wiring

Power Pins

The board takes 5 volts through the 5V pin or the VCC pin. Both pins sit on the same 5 volt rail on this board. Use one 5 volt input at a time. Do not feed 5 volts into the 3V3 pin. That mistake can damage the board.

Strapping and Boot Pins

GPIO0 controls flash mode. Hold GPIO0 low at reset to enter flash mode. Release it after programming starts. Normal run mode needs GPIO0 high or floating at reset. A jumper wire to ground works for this step. Remove the jumper after the upload.

GPIO0 also carries the camera clock, XCLK. That dual role is normal on this board. Do not add a permanent pull-down to GPIO0. A permanent pull-down would force flash mode at every reset. Use a temporary jumper only during programming.

GPIO2 and GPIO15 are also strapping pins. They share SD card duties on this board. Keep them free of strong pull-downs at boot when the SD card is in use. Check the Espressif ESP32 Series Datasheet for the full strapping table before you add boot-time wiring.

Camera Pins

The camera uses 15 pins on this board. Those pins are fixed. Do not reassign them to other parts. The list below is the camera driver pin map for the AI-Thinker board.

Camera signal GPIO Notes
Data D0 GPIO5 Camera data line
Data D1 GPIO18 Camera data line
Data D2 GPIO19 Camera data line
Data D3 GPIO21 Camera data line
Data D4 GPIO36 Camera data line, input only
Data D5 GPIO39 Camera data line, input only
Data D6 GPIO34 Camera data line, input only
Data D7 GPIO35 Camera data line, input only
XCLK GPIO0 Camera clock, also boot pin
PCLK GPIO22 Camera pixel clock
VSYNC GPIO25 Camera vertical sync
HREF GPIO23 Camera horizontal reference
SDA GPIO26 Camera control bus data
SCL GPIO27 Camera control bus clock
PWDN GPIO32 Camera power down control

SD Card Pins

The microSD slot uses 6 pins in 4-bit mode. That mode gives the fastest SD writes on this board. The 6 pins are GPIO14, GPIO15, GPIO2, GPIO4, GPIO12, and GPIO13. All 6 pins are then busy. No free GPIO remains from that set while 4-bit mode runs.

SD signal GPIO Mode
CLK GPIO14 4-bit and 1-bit
CMD GPIO15 4-bit and 1-bit
DATA0 GPIO2 4-bit and 1-bit
DATA1 GPIO4 4-bit only
DATA2 GPIO12 4-bit only
DATA3 GPIO13 4-bit only

Free GPIO Pins

Free pins depend on SD card use. With no SD card, 6 pins are free. Those pins are GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15. With 1-bit SD mode, 3 pins are free. Those pins are GPIO4, GPIO12, and GPIO13. With 4-bit SD mode, none of those 6 pins are free.

GPIO33 is the red LED pin. You can blink it in code. It is not a good general output for a load. GPIO16 is the PSRAM chip select. Leave GPIO16 alone. GPIO32 is the camera power-down pin. Leave it under camera driver control.

ADC, Touch, and PWM

GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15 all support ADC input. They also support touch input on the ESP32 chip. That overlap is useful. It is also a limit. A pin in SD use cannot serve as an ADC input at the same time.

I2C, SPI, and UART

The camera control bus uses GPIO26 for SDA and GPIO27 for SCL. Those pins are busy. Do not add a second I2C device on the same two pins without checking the camera driver first. A shared bus can clash with camera control.

USB and Programming

This board has no USB port. Program it with a 3.3 volt USB-to-serial adapter. Set the adapter to 3.3 volts. A 5 volt adapter setting can damage the 3.3 volt logic. Check the adapter jumper before every upload.

Connect adapter TX to board U0R, which is GPIO3. Connect adapter RX to board U0T, which is GPIO1. Connect ground to ground. Connect adapter 3.3 volt output only if the adapter can supply enough current. A separate 5 volt supply on the 5V pin is often more stable.

Hold GPIO0 low. Press reset. Start the upload. Release GPIO0 after the upload starts. Remove the GPIO0 jumper after the upload ends. Press reset once more to run the new code. For a full setup walkthrough, see the live post How to Start with ESP32-CAM for WiFi Camera Projects (live post #15173). For the flash steps in detail, see the live post ESP32-CAM Flashing and First Camera Stream: From Unboxing to WiFi Video (live post #22720).

How to flash the ESP32-CAM

The ESP32-CAM has no USB port, so every flash goes through its UART pins, GPIO1 (U0T) and GPIO3 (U0R). The board enters download mode only when GPIO0 is held low at reset.

Method 1: ESP32-CAM-MB programmer (easiest)

The ESP32-CAM-MB is a carrier board with the same footprint as the ESP32-CAM. It carries a CH340G USB-to-UART chip and two buttons, IO0 and RST. Seat the ESP32-CAM on the MB, connect it to your computer with a USB cable, and flash from the Arduino IDE as normal. No jumper wires are needed.

Hold IO0, press and release RST, then release IO0 to enter download mode. Start the upload, then press RST once to run the new code. If the upload works without the button sequence, skip it; some MB boards enter download mode on their own.

Two MB facts to know. First, the MB 5V pin sometimes cannot supply enough current for a flash, so power the board from a separate 5V supply if an upload fails partway. Second, the MB can hold GPIO0 low through the CH340 DTR line, so remove the ESP32-CAM from the MB and power it from a 5V supply to run it.

Method 2: USB-to-serial adapter (FTDI, CH340, or CP2102)

A USB-to-serial adapter works with any ESP32-CAM that has no MB. Set the adapter to 3.3 volts first; a 5 volt setting can damage the 3.3 volt pins.

Adapter pin ESP32-CAM pin Notes
TX U0R (GPIO3) Adapter TX to board RX
RX U0T (GPIO1) Adapter RX to board TX
GND GND Common ground
3.3V Leave unconnected Power the board from a separate 5V supply

Connect a jumper from GPIO0 to GND. Press the reset button on the board, or power-cycle it, with the jumper in place. Start the upload. Remove the GPIO0 jumper after the upload starts, then press reset once more to run the new code. If the upload fails, lower the upload speed to 115200 baud and check that the driver for your chip (FTDI, CH340, or CP2102) is installed.

Method 3: esptool.py from the command line

esptool.py is Espressif’s official flashing tool, and the Arduino IDE uses it under the hood. Use it to flash a prebuilt binary or erase the flash. Install it with pip install esptool, then put the board in download mode with the GPIO0 jumper method above.

Check the connection first. esptool.py --port COM3 flash_id (use your own port, such as /dev/ttyUSB0 on Linux) prints the flash size and confirms the board answers. Erase with esptool.py --chip esp32 --port COM3 erase_flash. Erasing is the fix when a board holds a bad sketch that keeps crashing at boot.

Flash a full build with one command. The classic ESP32 addresses are bootloader 0x1000, partitions 0x8000, boot_app0 0xe000, app 0x10000:

esptool.py -p COM3 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/app.bin

Flash only the app: esptool.py -p COM3 -b 460800 --chip esp32 write_flash --flash_mode dio --flash_size detect 0x10000 build/app.bin. A merged or factory binary already contains all four parts, so flash it at 0x0. Flashing it at 0x10000 makes it overflow the end of the flash.

Arduino IDE settings for the ESP32-CAM

These settings apply to every Arduino IDE flash. Install the ESP32 board package from the Boards Manager with the URL https://espressif.github.io/arduino-esp32/package_esp32_index.json, then set the following under Tools.

Setting Value Why
Board AI Thinker ESP32-CAM Selects the AI-Thinker pin map and PSRAM
Port Your USB-serial port The MB or adapter port, not a Bluetooth port
Upload Speed 921600 Fast uploads; drop to 115200 if uploads fail
Partition Scheme Huge APP (3MB No OTA/1MB SPIFFS) CameraWebServer is too big for the default 1.2MB app slot
Flash Size 4MB Matches the ESP32-CAM flash chip
PSRAM Enabled The camera frame buffer lives in PSRAM

The partition scheme is the setting that catches most people. The default scheme gives the app about 1.2 MB, and CameraWebServer is larger than that, so the IDE stops with “Sketch too big”. Huge APP gives the app about 3 MB and drops OTA updates. Set it once and leave it.

Flash errors and what they mean

A failed upload usually means the board never entered download mode, the power dipped, or the app does not fit.

Message Meaning Fix
Failed to connect to ESP32: Timed out waiting for packet header The board never entered download mode (esptool may report boot mode 0x13) Hold GPIO0 low at reset, check the cable is a data cable, install the CH340 or CP2102 driver, try a lower upload speed
Sketch too big The app is larger than the partition scheme allows Set Partition Scheme to Huge APP (3MB No OTA/1MB SPIFFS)
Camera init failed The flash worked but the camera did not start See the troubleshooting post
Brownout detector was triggered The power supply dipped during WiFi or camera start Use a stable 5V supply rated at 2A or more

Camera init failures and brownouts after a good flash are covered here: https://qualityrcparts.com/esp32-cam-troubleshooting-brownout-camera-init-failed/

Pins to Avoid

Avoid GPIO16 for any new wiring. It is the PSRAM chip select. Avoid GPIO32 for general use. It controls camera power down. Avoid GPIO0 as a permanent output. It is the boot pin and the camera clock.

Avoid GPIO36, GPIO39, GPIO34, and GPIO35 as outputs. They are input-only pins. Avoid GPIO6 through GPIO11. Those pins connect to the on-board flash memory. They do not appear on the headers. Do not try to use them.

Avoid 5 volt logic on any GPIO pin. This board uses 3.3 volt logic. A 5 volt signal needs a level shifter. A direct 5 volt input can damage the pin.

Max Current and Logic Voltage

Logic voltage is 3.3 volts on every GPIO pin. That value comes from the Espressif ESP32 Series Datasheet. Treat 3.3 volts as the high level. Treat 0 volts as the low level. Keep sensor outputs at 3.3 volts or below.

At the strongest drive setting, a GPIO pin sources about 40 mA (IOH) and sinks about 28 mA (IOL), per Table 5-4 of the Espressif ESP32 Series Datasheet v5.3. Those are drive-strength values at 3.3 volts, not a recommended continuous load. Cumulative IO output current for the chip is 1200 mA at absolute maximum, per section 5.1 of the same datasheet. Treat a small LED through a resistor as the practical per-pin load, not 40 mA.

Use a transistor or a driver for any load above a small LED. Keep LED current low with a series resistor. A 220 ohm resistor is a common bench value for a 3.3 volt LED test. Check the LED datasheet for its own forward voltage before you pick a resistor.

Wiring and Power Warnings

Power the board before you connect a 5 volt sensor. Keep the USB-to-serial adapter at 3.3 volts. Double-check the adapter jumper. A wrong jumper is a fast way to damage the board.

Keep wires short. Use a cable under 3 feet for bench tests when you can. Long wires pick up noise. Noise causes SD errors and camera glitches. Twist power and ground wires together when the run is long.

Pin Test Sketch

Language: Arduino. Library: Arduino ESP32 core version 2.0.14, with the built-in esp_camera driver. No extra library install is needed for this test. Code status: COMPILED with PlatformIO 6.2.0 (espressif32, board esp32cam) on 2026-11-22, SUCCESS in 30.18 seconds (RAM 10.4%, Flash 11.7%).

// ESP32-CAM pin test sketch
// Board: AI-Thinker ESP32-CAM
// Arduino ESP32 core version 2.0.14
// Code status: COMPILED with PlatformIO 6.2.0, esp32cam, 30.18 seconds

#include "esp_camera.h"

// Camera pin map for the AI-Thinker board.
#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

// Free pin test uses GPIO4 when no SD card is fitted.
// GPIO4 is SD DATA1 in 4-bit mode, so remove the card first.
const int testPin = 4;

void setup() {
  // Start serial at 115200 baud for debug output.
  Serial.begin(115200);
  delay(1000); // Wait 1 second for the monitor to open.

  // Set the test pin as an output and blink the red LED pin.
  pinMode(testPin, OUTPUT);
  pinMode(33, OUTPUT);

  // Start the camera with a small frame size for the test.
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sccb_sda = SIOD_GPIO_NUM;
  config.pin_sccb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000; // 20 megahertz camera clock.
  config.pixel_format = PIXFORMAT_JPEG;
  config.frame_size = FRAMESIZE_QVGA; // Small size for a fast test.
  config.jpeg_quality = 12; // Lower number means higher quality.
  config.fb_count = 1;

  // Report the camera start result on serial.
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed, error 0x%x\n", err);
    return;
  }
  Serial.println("Camera init OK");
}

void loop() {
  // Blink the test pin and the red LED pin in turn.
  digitalWrite(testPin, HIGH);
  digitalWrite(33, LOW);
  delay(500); // Wait 500 milliseconds.
  digitalWrite(testPin, LOW);
  digitalWrite(33, HIGH);
  delay(500); // Wait 500 milliseconds.
  Serial.println("Pin test tick");
}

Expected result: the serial monitor shows “Camera init OK” and then a tick line each 1 second. The red LED blinks in turn with the test pin. If camera init fails, check the ribbon cable seating first. Then check the 5 volt supply.

Frequently Asked Questions

How many free GPIO pins does the ESP32-CAM have?

It has 6 free pins with no SD card. The pins are GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15. The count drops to 3 pins in 1-bit SD mode. It drops to 0 pins from that set in 4-bit SD mode.

Can I use GPIO0 as a normal output?

No, not as a normal output. GPIO0 is the boot pin and the camera clock. It must be high at reset for normal run mode. Use a free pin from the SD set instead.

Why does my ESP32-CAM reset when WiFi starts?

A weak 5 volt supply is the most common cause. WiFi draws a current spike at start. Use a stable 5 volt supply rated at 1 ampere or more. Keep wires short and check the ground.

Does the ESP32-CAM have a USB port?

No, it has no USB port. Program it with a 3.3 volt USB-to-serial adapter. Connect adapter TX to U0R and adapter RX to U0T. Hold GPIO0 low at reset for flash mode.

How do I flash the ESP32-CAM with the ESP32-CAM-MB?

Seat the ESP32-CAM on the MB, connect it to your computer, and upload from the Arduino IDE. Hold IO0, press and release RST, then release IO0 to enter download mode. Press RST once after the upload to run the code. If the board will not run while seated in the MB, remove it and power it from a 5V supply.

Which USB-to-serial adapter works with the ESP32-CAM?

Any FTDI, CH340, or CP2102 adapter works, as long as you set it to 3.3 volts and wire TX to U0R (GPIO3), RX to U0T (GPIO1), and GND to GND. Power the board from a separate 5V supply. Hold GPIO0 low at reset to enter download mode, and remove the jumper after the upload starts.

Why does the Arduino IDE say “Sketch too big” for CameraWebServer?

The default partition scheme gives the app about 1.2 MB, and CameraWebServer is larger than that. Set Tools, Partition Scheme to Huge APP (3MB No OTA/1MB SPIFFS). That gives the app about 3 MB and drops OTA updates, which a first flash does not need.

What flash addresses does esptool use for the ESP32-CAM?

Bootloader at 0x1000, partition table at 0x8000, boot_app0 at 0xe000, and the app at 0x10000. A merged or factory binary already contains all four parts, so flash it at 0x0. Flashing a merged binary at 0x10000 makes it overflow the end of the flash.

Why does my ESP32-CAM stay in download mode after flashing?

GPIO0 is still held low. Remove the GPIO0 to GND jumper, or remove the board from the MB carrier, then press reset once. The board boots normally when GPIO0 is high or floating at reset.

Boards That Match This Pinout

These boards use the pinout in this guide. Check the product page for current stock before you order. Stock changes over time.

Related reading: compare this board with the wider ESP32 family in the staged pillar ESP32 vs ESP32-S3 vs ESP32-C3 vs ESP32-C6 (row 22, staged). For sibling pinouts, see How to Use the ESP32 DevKit V1 Board for WiFi Projects and XIAO ESP32S3 Pinout.

Parts used in this guide

Related guides: flashing walkthrough https://qualityrcparts.com/esp32-cam-flashing-first-camera-stream/, troubleshooting https://qualityrcparts.com/esp32-cam-troubleshooting-brownout-camera-init-failed/, CAM vs S3-CAM comparison https://qualityrcparts.com/esp32-cam-s3-cam-camera-projects-guide/, pillar https://qualityrcparts.com/which-esp32-should-i-buy/, DevKit V1 pinout https://qualityrcparts.com/esp32-devkit-v1-pinout/, S3 DevKitC-1 pinout https://qualityrcparts.com/esp32-s3-devkitc-1-pinout/

Sources

  • Espressif ESP32 Series Datasheet v5.3, https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
  • ESP32-CAM camera driver pin map, Espressif Arduino ESP32 core, https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h

Last updated 2026-11-22.