Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

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

Image of ESP-CAM
Cirkit Designer LogoDesign with ESP-CAM in Cirkit Designer

Introduction

The ESP-CAM, manufactured by ESP32 (Part ID: ESPCAM), is a low-cost, compact camera module that integrates an ESP32 microcontroller with a camera. This module is designed for wireless image capture and streaming, making it an excellent choice for IoT projects requiring surveillance, remote monitoring, or image processing capabilities. Its built-in Wi-Fi and Bluetooth functionality, combined with its small form factor, make it a versatile solution for a wide range of applications.

Explore Projects Built with ESP-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!

Explore Projects Built with ESP-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

  • Home security and surveillance systems
  • Remote monitoring for industrial or agricultural use
  • Smart doorbells and intercom systems
  • Image recognition and processing projects
  • DIY robotics and drones with vision capabilities

Technical Specifications

Key Technical Details

Parameter Specification
Microcontroller ESP32
Camera Sensor OV2640 (2MP)
Wireless Connectivity Wi-Fi 802.11 b/g/n, Bluetooth 4.2
Flash Memory 4 MB (PSRAM)
Operating Voltage 3.3V
Power Consumption ~160 mA (active), ~10 µA (deep sleep)
Image Resolution Up to 1600x1200 (UXGA)
Interfaces UART, SPI, I2C, PWM
Dimensions 27mm x 40.5mm

Pin Configuration and Descriptions

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

Pin Number Pin Name Description
1 GND Ground connection
2 3.3V Power supply input (3.3V)
3 IO0 GPIO0, used for boot mode selection (connect to GND for programming mode)
4 IO2 GPIO2, used for general-purpose I/O or camera reset
5 IO4 GPIO4, general-purpose I/O
6 IO5 GPIO5, general-purpose I/O
7 IO12 GPIO12, general-purpose I/O
8 IO13 GPIO13, general-purpose I/O
9 IO14 GPIO14, general-purpose I/O
10 IO15 GPIO15, general-purpose I/O
11 IO16 GPIO16, general-purpose I/O
12 IO17 GPIO17, general-purpose I/O
13 RXD UART RX (serial communication input)
14 TXD UART TX (serial communication output)
15 RST Reset pin
16 EN Enable pin (active high, used to enable the module)

Usage Instructions

How to Use the ESP-CAM in a Circuit

  1. Power Supply: Connect the 3.3V pin to a stable 3.3V power source and GND to ground.
  2. Programming Mode: To upload code, connect GPIO0 to GND and reset the module. After programming, disconnect GPIO0 from GND.
  3. Camera Connection: The OV2640 camera module is pre-attached to the ESP-CAM. Ensure the ribbon cable is securely connected.
  4. Serial Communication: Use the RXD and TXD pins to communicate with a computer or microcontroller via a USB-to-serial adapter.
  5. Wi-Fi Configuration: Configure the Wi-Fi settings in your code to enable wireless communication.

Important Considerations and Best Practices

  • Power Requirements: Ensure a stable 3.3V power supply. Using higher voltages can damage the module.
  • Heat Management: The ESP-CAM can get warm during operation. Ensure proper ventilation to avoid overheating.
  • Antenna Placement: For optimal Wi-Fi performance, avoid placing the module near metal objects or inside enclosures that block signals.
  • Programming: Use the Arduino IDE or ESP-IDF for programming. Install the necessary ESP32 board support package before uploading code.

Example Code for Arduino UNO

Below is an example of how to use the ESP-CAM to capture and stream video over Wi-Fi:

#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);

  // Initialize Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWi-Fi connected");
  Serial.print("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 initialized successfully");
  } else {
    Serial.println("Camera initialization failed");
    return;
  }

  // Start the camera server
  startCameraServer();
}

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

Troubleshooting and FAQs

Common Issues and Solutions

  1. Wi-Fi Connection Fails:

    • Ensure the correct SSID and password are entered in the code.
    • Check if the router is within range and functioning properly.
  2. Camera Initialization Fails:

    • Verify that the ribbon cable connecting the camera is securely attached.
    • Ensure the power supply is stable and sufficient.
  3. Module Overheats:

    • Provide adequate ventilation or use a heatsink if necessary.
    • Avoid running the module at maximum performance for extended periods.
  4. No Serial Output:

    • Check the RXD and TXD connections to the USB-to-serial adapter.
    • Ensure the correct baud rate (115200) is selected in the serial monitor.

FAQs

Q: Can the ESP-CAM be powered with 5V?
A: No, the ESP-CAM requires a 3.3V power supply. Using 5V can damage the module.

Q: How do I reset the ESP-CAM?
A: Press the RST pin or momentarily disconnect the power supply to reset the module.

Q: Can I use the ESP-CAM without Wi-Fi?
A: Yes, the ESP-CAM can operate in standalone mode for image processing or local storage, but Wi-Fi is required for streaming.

Q: What is the maximum image resolution?
A: The ESP-CAM supports resolutions up to 1600x1200 (UXGA).