IoTAdvancedPRJ-158

IoT Smart Street Crime Detection Camera Using ESP32-CAM

A motion-triggered ESP32-CAM that captures images and alerts your phone.

Built and tested by Drisya K S · Industrial Robotics Institute

ESP32-CAM (AI-Thinker)

Arduino IDE, ESP32 board package, Blynk IoT app

LevelAdvanced
Build time4–5 hours
BoardESP32-CAM (AI-Thinker)
Parts9 components

What is the IoT Smart Street Crime Detection Camera?

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.

How it works

  1. The PIR sensor watches the area for movement.
  2. On motion, the buzzer and LED turn on and the ESP32-CAM captures a frame.
  3. An alert "Motion Detected!" is sent to Blynk V1.
  4. IR LEDs on GPIO 12 can be switched on for night vision; images can also be saved to the microSD card.

Parts list

ComponentQty
ESP32-CAM (AI-Thinker)1
PIR Motion Sensor1
IR LEDs (night vision)1
Buzzer1
LED1
Resistors 220Ω1
MicroSD Card (optional)1
Jumper Wires / BreadboardAs needed
5V Power Supply1

Software

  • Arduino IDE
  • ESP32 board package
  • Blynk IoT app

Wiring and connections

FromConnect to
PIR VCC5V
PIR GNDGND
PIR OUTGPIO 13
IR LEDs + (via resistor)GPIO 12
Buzzer +GPIO 15
LED + (via resistor)GPIO 14
ESP32-CAMStable 5V supply

How to build the IoT Smart Street Crime Detection Camera

  1. Wire the PIR output to GPIO 13, the IR LEDs to GPIO 12, the buzzer to GPIO 15 and the LED to GPIO 14.
  2. In Blynk, create datastream V1 (string) with a label and notification.
  3. Add your Blynk details and Wi-Fi to the code.
  4. Upload with an FTDI programmer (GPIO0 to GND while uploading), board "AI Thinker ESP32-CAM".
  5. Remove the GPIO0 link, reset, and test by walking past the PIR.

IoT Smart Street Crime Detection Camera code

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

Real-world uses

  • Street and parking security
  • Campus monitoring
  • Shop fronts
  • Smart city surveillance

Frequently asked questions

What is a IoT Smart Street Crime Detection Camera?

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.

What components are needed for the IoT Smart Street Crime Detection Camera?

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.

Is the IoT Smart Street Crime Detection Camera project good for beginners?

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.

Where can I get the code for the IoT Smart Street Crime Detection Camera?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the IoT Smart Street Crime Detection Camera?

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.

Industrial Robotics Institute
Logo