Back to Advanced Projects

📹 ESP32-CAM Security Camera

Stream live MJPEG video from your own Wi-Fi security camera for under $10.

📋 Overview

The ESP32-CAM is a tiny $6 module that packs an OV2640 2MP camera, an ESP32 chip, and a MicroSD card slot into one board. It can stream MJPEG video over Wi-Fi at up to 800x600 resolution, making it the most cost-effective DIY security camera on the market.

What you'll learn: Configuring the ESP32-CAM camera driver, setting up an asynchronous MJPEG streaming server, motion detection via frame difference analysis, and saving snapshot JPEGs to MicroSD.

Estimated time: 1.5–2 hours. Difficulty: ⭐⭐⭐ Intermediate.

🧩 Components Needed

ComponentSpecificationQtyNotes
ESP32-CAM ModuleAI-Thinker, OV26401With MicroSD slot
FTDI USB-TTL Adapter3.3V/5V1For programming (no USB on board)
MicroSD Card8–32 GB, FAT321For snapshot storage
Jumper WiresFemale-to-Female6For FTDI connection
External 5V Supply1A minimum1Camera draws 270mA peak

📖 Step-by-Step Tutorial

1

Connect FTDI Programmer

Wire FTDI GND → ESP32-CAM GND, FTDI TX → GPIO U0R, FTDI RX → GPIO U0T. Connect 5V to 5V. Short GPIO0 to GND to enter flash mode.
2

Install ESP32 Board Support

In Arduino IDE, add https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json to board manager URLs and install esp32 by Espressif.
3

Select Board & Upload

Select AI Thinker ESP32-CAM from the board list. Open File → Examples → ESP32 → Camera → CameraWebServer. Enter your WiFi credentials and upload.
4

Open Stream in Browser

After upload, disconnect GPIO0 from GND, press the reset button, and open the Serial Monitor at 115200 baud to get the IP address. Visit the IP in a browser.
5

Enable Motion Snapshot

Extend the sketch to compare consecutive frame buffers. If pixel difference exceeds a threshold, call esp_camera_fb_get() and write the JPEG to SD.
💡
The ESP32-CAM is notoriously power-hungry. A weak power supply causes random resets and blurry frames. Always use a dedicated 5V/1A+ adapter — never power it from the FTDI 3.3V pin.

💻 Code / Configuration

esp32_cam_surveillance.ino
INO
// ESP32-CAM Surveillance - Volt X
// Uses ESP32 Arduino CameraWebServer example as base
#include "esp_camera.h"
#include <WiFi.h>
#include "esp_http_server.h"

const char* ssid     = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";

// AI-Thinker ESP32-CAM pinout
#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

Reviews & Ratings

0 reviews
5★
0
4★
0
3★
0
2★
0
1★
0
...

Loading reviews...