A motion-triggered ESP32-CAM that captures images and alerts your phone.
Built and tested by Drisya K S · Industrial Robotics Institute
Arduino IDE, ESP32 board package, Blynk IoT app
A security camera for streets, parking areas and campuses. A PIR sensor detects movement, the ESP32-CAM captures an image, a buzzer and LED give a local warning, and an alert is sent to the Blynk app. IR LEDs can light the scene at night.
| Component | Qty |
|---|---|
| ESP32-CAM (AI-Thinker) | 1 |
| PIR Motion Sensor | 1 |
| IR LEDs (night vision) | 1 |
| Buzzer | 1 |
| LED | 1 |
| Resistors 220Ω | 1 |
| MicroSD Card (optional) | 1 |
| Jumper Wires / Breadboard | As needed |
| 5V Power Supply | 1 |
| From | Connect to |
|---|---|
| PIR VCC | 5V |
| PIR GND | GND |
| PIR OUT | GPIO 13 |
| IR LEDs + (via resistor) | GPIO 12 |
| Buzzer + | GPIO 15 |
| LED + (via resistor) | GPIO 14 |
| ESP32-CAM | Stable 5V supply |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32-CAM (AI-Thinker).
#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_NAME "Street Security"
#define BLYNK_AUTH_TOKEN "YourAuthToken"
#include "esp_camera.h"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";
#define PIR_PIN 13
#define BUZZER 15
#define LED 14
#define IR_LED 12
void setupCamera() {
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 = 32;
config.pin_reset = -1;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_VGA;
config.jpeg_quality = 12;
config.fb_count = 1;
if (esp_camera_init(&config) != ESP_OK) {
Serial.println("Camera init failed");
}
}
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(BUZZER, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(IR_LED, OUTPUT);
setupCamera();
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop() {
int motion = digitalRead(PIR_PIN);
if (motion == HIGH) {
digitalWrite(BUZZER, HIGH);
digitalWrite(LED, HIGH);
camera_fb_t *fb = esp_camera_fb_get();
if (fb) {
Serial.printf("Image Captured: %u bytes\n", fb->len);
Blynk.virtualWrite(V1, "Motion Detected!");
esp_camera_fb_return(fb);
}
} else {
digitalWrite(BUZZER, LOW);
digitalWrite(LED, LOW);
}
Blynk.run();
delay(1000);
}A security camera for streets, parking areas and campuses. A PIR sensor detects movement, the ESP32-CAM captures an image, a buzzer and LED give a local warning, and an alert is sent to the Blynk app.
You need: ESP32-CAM (AI-Thinker) (1), PIR Motion Sensor (1), IR LEDs (night vision) (1), Buzzer (1), LED (1), Resistors 220Ω (1), MicroSD Card (optional) (1), Jumper Wires / Breadboard, 5V Power Supply (1). Software: Arduino IDE, ESP32 board package, Blynk IoT app.
It is rated advanced and takes about 4–5 hours to build, using the ESP32-CAM (AI-Thinker). The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-158). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.