The ESP32-CAM is a low-cost development board manufactured by Ai Thinker. It features a built-in camera module and Wi-Fi capabilities, making it ideal for IoT applications that require video streaming, image capture, or remote monitoring. The board is based on the powerful ESP32 chip, which integrates Wi-Fi and Bluetooth functionality, along with a dual-core processor.
The ESP32-CAM is a compact and versatile module with the following key specifications:
Parameter | Value |
---|---|
Microcontroller | ESP32-D0WDQ6 (dual-core processor) |
Camera Module | OV2640 (2MP resolution) |
Flash Memory | 4 MB (PSRAM: 8 MB) |
Wi-Fi | 802.11 b/g/n |
Bluetooth | BLE and Bluetooth 4.2 |
Operating Voltage | 3.3V |
Input Voltage Range | 5V (via external power supply or USB-to-TTL module) |
GPIO Pins | 9 GPIO pins available for user applications |
Interfaces | UART, SPI, I2C, PWM, ADC |
Dimensions | 27mm x 40.5mm |
Power Consumption | Deep Sleep: ~6mA, Active Mode: ~160mA |
Camera Features | Support for JPEG, BMP, and grayscale image formats |
Operating Temperature | -20°C to 85°C |
The ESP32-CAM has a total of 16 pins. Below is the pinout and description:
Pin Name | Pin Number | Description |
---|---|---|
GND | 1 | Ground connection |
3.3V | 2 | 3.3V power supply output |
5V | 3 | 5V power supply input |
U0R | 4 | UART0 RX pin (used for programming and debugging) |
U0T | 5 | UART0 TX pin (used for programming and debugging) |
GPIO0 | 6 | GPIO pin 0 (used for boot mode selection) |
GPIO1 | 7 | GPIO pin 1 (used for general-purpose I/O) |
GPIO2 | 8 | GPIO pin 2 (used for LED flash control) |
GPIO3 | 9 | GPIO pin 3 (used for general-purpose I/O) |
GPIO4 | 10 | GPIO pin 4 (used for general-purpose I/O) |
GPIO12 | 11 | GPIO pin 12 (used for SD card data line) |
GPIO13 | 12 | GPIO pin 13 (used for SD card data line) |
GPIO14 | 13 | GPIO pin 14 (used for SD card clock line) |
GPIO15 | 14 | GPIO pin 15 (used for SD card command line) |
GPIO16 | 15 | GPIO pin 16 (used for general-purpose I/O) |
RESET | 16 | Reset pin (active low) |
Below is an example of how to use the ESP32-CAM with the Arduino IDE to capture and stream video:
#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);
// Connect to 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;
// Initialize the camera
if (esp_camera_init(&config) != ESP_OK) {
Serial.println("Camera init failed");
return;
}
// Start the camera server
startCameraServer();
}
void loop() {
// Main loop does nothing; the camera server handles everything
}
ESP32-CAM Not Booting:
Camera Initialization Failed:
Wi-Fi Connection Issues:
Overheating:
Can I use the ESP32-CAM without an external antenna? Yes, the onboard antenna is sufficient for most applications, but an external antenna can improve range.
What is the maximum resolution of the camera? The OV2640 camera supports up to 1600x1200 (UXGA) resolution.
Can I use the ESP32-CAM with a battery? Yes, you can use a 3.7V LiPo battery with a step-up converter to provide 5V input.
Does the ESP32-CAM support deep sleep mode? Yes, the ESP32-CAM supports deep sleep mode to conserve power.