The ESP32-CAM is a low-cost development board that combines the powerful ESP32 microcontroller with integrated Wi-Fi and Bluetooth capabilities, along with a camera module. This compact and versatile board is ideal for IoT applications, enabling image capture, video streaming, and wireless communication. Its small form factor and rich feature set make it a popular choice for projects such as home automation, surveillance systems, and AI-powered image recognition.
The ESP32-CAM has a total of 16 pins. Below is the pinout and description:
Pin | Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | 5V | Power input (5V) |
3 | 3.3V | Power output (3.3V) |
4 | GPIO0 | General-purpose I/O pin; used for boot mode selection |
5 | GPIO1 (U0TXD) | UART0 TX pin; used for serial communication |
6 | GPIO3 (U0RXD) | UART0 RX pin; used for serial communication |
7 | GPIO16 | General-purpose I/O pin |
8 | GPIO17 | General-purpose I/O pin |
9 | GPIO12 | General-purpose I/O pin; connected to the microSD card interface (DATA2) |
10 | GPIO13 | General-purpose I/O pin; connected to the microSD card interface (DATA3) |
11 | GPIO14 | General-purpose I/O pin; connected to the microSD card interface (CLK) |
12 | GPIO15 | General-purpose I/O pin; connected to the microSD card interface (CMD) |
13 | GPIO2 | General-purpose I/O pin; connected to the onboard LED |
14 | GPIO4 | General-purpose I/O pin; connected to the camera module |
15 | GPIO5 | General-purpose I/O pin; connected to the camera module |
16 | RESET | Reset pin; used to restart the ESP32-CAM |
Powering the Board:
5V
pin or via the micro-USB port. Ensure the power source can provide at least 500 mA.GND
pin to the ground of your circuit.Programming the ESP32-CAM:
TX
→ ESP32-CAM U0RXD
(GPIO3)RX
→ ESP32-CAM U0TXD
(GPIO1)GND
→ ESP32-CAM GND
5V
→ ESP32-CAM 5V
Uploading Code:
Connecting Peripherals:
Below is an example of how to use the ESP32-CAM to capture and stream video:
#include <WiFi.h>
#include <esp_camera.h>
// Replace with your network credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";
// Camera configuration
#define PWDN_GPIO_NUM -1
#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
void startCameraServer();
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
// Wait for Wi-Fi connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected");
// Camera initialization
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_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
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;
}
startCameraServer();
}
void loop() {
// Main loop does nothing; camera server handles requests
}
ESP32-CAM Not Detected by the Computer:
Frequent Resets or Instability:
Camera Initialization Failed:
Wi-Fi Connection Issues:
Can I use the ESP32-CAM without a camera module?
Yes, the ESP32-CAM can function as a standard ESP32 development board without the camera.
What is the maximum resolution supported by the camera?
The OV2640 camera module supports up to 1600x1200 (UXGA) resolution.
Can I use an external antenna?
Yes, you can connect an