Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use ESP 32 CAM: Examples, Pinouts, and Specs

Image of ESP 32 CAMDesign with ESP 32 CAM in Cirkit Designer

Introduction

The ESP 32 CAM is a low-cost development board that features a camera module and Wi-Fi/Bluetooth capabilities. It is based on the ESP32 chip, which provides robust processing power and wireless connectivity. This board is ideal for IoT projects that require image capture, video streaming, or remote monitoring. Its compact size and versatility make it a popular choice for developers working on smart home devices, security systems, and AI-based image recognition applications.

Explore Projects Built with ESP 32 CAM

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!

Common Applications:

Technical Specifications

The ESP 32 CAM combines the ESP32 microcontroller with a camera module and other essential components. Below are its key specifications:

General Specifications:

Feature Specification
Microcontroller ESP32-D0WD
Wireless Connectivity Wi-Fi 802.11 b/g/n, Bluetooth 4.2
Camera Module OV2640 (default)
Flash Memory 4 MB (PSRAM)
Storage MicroSD card slot (up to 4 GB)
Operating Voltage 3.3V
Power Supply 5V via micro-USB or external source
GPIO Pins 9 (configurable for various functions)
Dimensions 27 mm x 40.5 mm

Pin Configuration:

The ESP 32 CAM has a total of 16 pins. Below is the pinout description:

Pin Name Function Description
GND Ground Connect to ground of the power supply
3.3V Power Supply Provides 3.3V output
5V Power Supply Input for 5V power
GPIO0 Boot Mode Selection Used for programming (connect to GND to flash)
GPIO1 UART TX Serial communication (transmit)
GPIO3 UART RX Serial communication (receive)
GPIO16 General Purpose I/O Configurable GPIO
GPIO17 General Purpose I/O Configurable GPIO
GPIO33 General Purpose I/O Configurable GPIO
GPIO34 General Purpose I/O (Input only) Input-only GPIO
GPIO35 General Purpose I/O (Input only) Input-only GPIO
GPIO36 General Purpose I/O (Input only) Input-only GPIO
GPIO39 General Purpose I/O (Input only) Input-only GPIO
SD_CMD SD Card Command Line Used for microSD card communication
SD_CLK SD Card Clock Line Used for microSD card communication
SD_DATA0 SD Card Data Line Used for microSD card communication

Usage Instructions

How to Use the ESP 32 CAM in a Circuit:

  1. Powering the Board:

    • Supply 5V to the 5V pin or use a micro-USB cable to power the board.
    • Ensure the power source can provide at least 500mA of current.
  2. Programming the Board:

    • Connect the ESP 32 CAM to a USB-to-TTL converter (e.g., FTDI module).
    • Connect the GND pin of the ESP 32 CAM to the GND of the FTDI module.
    • Connect the 5V pin of the ESP 32 CAM to the VCC of the FTDI module.
    • Connect UART TX (GPIO1) to the RX pin of the FTDI module and UART RX (GPIO3) to the TX pin.
    • Pull GPIO0 to GND to enable programming mode.
    • Use the Arduino IDE or other compatible software to upload code.
  3. Connecting Peripherals:

    • Use the GPIO pins to connect sensors, actuators, or other peripherals.
    • For camera functionality, ensure the OV2640 module is securely connected to the board.
  4. MicroSD Card Usage:

    • Insert a formatted microSD card into the slot.
    • Use the SD card pins (SD_CMD, SD_CLK, SD_DATA0) for data storage or retrieval.

Important Considerations:

Example Code for Arduino IDE:

Below is an example of how to set up the ESP 32 CAM for basic camera streaming:

#include <WiFi.h>
#include <esp_camera.h>

// Replace with your Wi-Fi credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";

void startCameraServer();

void setup() {
  Serial.begin(115200);

  // Configure Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Initialize the camera
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = 5;
  config.pin_d1 = 18;
  config.pin_d2 = 19;
  config.pin_d3 = 21;
  config.pin_d4 = 36;
  config.pin_d5 = 39;
  config.pin_d6 = 34;
  config.pin_d7 = 35;
  config.pin_xclk = 0;
  config.pin_pclk = 22;
  config.pin_vsync = 25;
  config.pin_href = 23;
  config.pin_sscb_sda = 26;
  config.pin_sscb_scl = 27;
  config.pin_pwdn = -1;
  config.pin_reset = -1;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;

  if (!esp_camera_init(&config)) {
    Serial.println("Camera init failed");
    return;
  }

  // Start the camera server
  startCameraServer();
}

void loop() {
  // Main loop does nothing; camera server handles requests
}

Troubleshooting and FAQs

Common Issues:

  1. The ESP 32 CAM is not detected by the computer:

    • Ensure the FTDI module is connected correctly.
    • Check that GPIO0 is pulled to GND during programming.
    • Verify the correct COM port is selected in the Arduino IDE.
  2. Wi-Fi connection fails:

    • Double-check the SSID and password in the code.
    • Ensure the Wi-Fi network is within range and operational.
  3. Camera initialization fails:

    • Verify that the OV2640 module is securely connected.
    • Ensure the camera pins are correctly configured in the code.
  4. Board resets unexpectedly:

    • Use a stable power supply capable of providing at least 500mA.
    • Avoid overloading the GPIO pins with high-current peripherals.

FAQs: