ESP32 Night Vision Surveillance Camera

Objective

To design and build a night vision surveillance camera using the ESP32 and an infrared (IR) camera module. The system will be capable of capturing video in low-light conditions and streaming or recording images for surveillance purposes.

Introduction

Night vision surveillance systems are widely used for security in low-light environments. This project demonstrates how to build a simple yet effective night vision camera using the ESP32 and an IR camera module. The ESP32 processes the captured video and sends the data to a display or cloud for monitoring. The system can be further enhanced to record images or stream video over Wi-Fi.

  • Connect the IR camera module to the ESP32.
  • Configure the ESP32 to read frames from the camera module.
  • Process the image data and display it on an OLED screen or stream it to a cloud service.
  • Integrate IR LEDs for night vision capability.
  • Optionally add motion detection or image capturing features for enhanced surveillance.

Formula: The camera module outputs raw image data, which is processed by the ESP32 to display on an OLED screen. Depending on the module, image resolution and frame rate may vary.

Components Required

  • ESP32 Development Board
  • IR Camera Module (e.g., OV2640)
  • IR LEDs for night vision
  • OLED Display (Optional)
  • Breadboard and Jumper Wires
  • USB Cable

Circuit Diagram

  • IR Camera SDA →: GPIO 21
  • IR Camera SCL →: GPIO 22
  • IR LEDs VCC & GND →: 3.3V and GND
  • OLED SDA →: GPIO 21
  • OLED SCL →: GPIO 22

Ensure that the IR camera and OLED display are compatible with the ESP32, and that the IR LEDs provide sufficient illumination for low-light conditions.

Connection Table

  • -> GPIO 21
  • -> GPIO 22
  • -> 3.3V and GND
  • -> GPIO 21
  • -> GPIO 22

Arduino Code

1#include <Wire.h>
2#include <Adafruit_GFX.h>
3#include <Adafruit_SSD1306.h>
4#include <Camera.h>
5
6#define CAMERA_MODEL_AI_THINKER
7#include "camera_pins.h"
8
9#define SCREEN_WIDTH 128
10#define SCREEN_HEIGHT 64
11Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
12
13void setup() {
14  Serial.begin(115200);
15  camera_config_t config;
16  config.ledc_channel = LEDC_CHANNEL_0;
17  config.ledc_timer = LEDC_TIMER_0;
18  config.pin_d0 = 5;
19  config.pin_d1 = 18;
20  config.pin_d2 = 19;
21  config.pin_d3 = 21;
22  config.pin_d4 = 36;
23  config.pin_d5 = 39;
24  config.pin_d6 = 34;
25  config.pin_d7 = 35;
26  config.pin_xclk = 0;
27  config.pin_pclk = 22;
28  config.pin_vsync = 25;
29  config.pin_href = 23;
30  config.pin_sscb_sda = 26;
31  config.pin_sscb_scl = 27;
32  config.pin_pwdn = 32;
33  config.pin_reset = -1;
34  config.xclk_freq_hz = 20000000;
35  config.ledc_channel = LEDC_CHANNEL_0;
36  config.ledc_timer = LEDC_TIMER_0;
37  config.pixel_format = PIXFORMAT_JPEG;
38  config.frame_size = FRAMESIZE_UXGA;
39  config.jpeg_quality = 12;
40  config.fb_count = 1;
41  esp_camera_init(&config);
42
43  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
44    Serial.println("SSD1306 allocation failed");
45    while (1);
46  }
47  display.clearDisplay();
48  display.setTextSize(1);
49  display.setTextColor(WHITE);
50  display.setCursor(0, 0);
51  display.println("Night Vision Camera Initialized...");
52  display.display();
53  delay(2000);
54}
55
56void loop() {
57  camera_fb_t *fb = esp_camera_fb_get();
58  if (!fb) {
59    Serial.println("Camera capture failed");
60    return;
61  }
62
63  display.clearDisplay();
64  display.setCursor(0, 0);
65  display.println("Capturing Image...");
66  display.display();
67
68  // Display image or stream data here
69  // For now, just simulate image display
70  delay(1000);
71  esp_camera_fb_return(fb);
72}

Code Explanation

  • camera_config_t config;: Sets up the camera configuration, including pin assignments and camera properties.
  • esp_camera_init(&config);: Initializes the camera with the defined configuration.
  • camera_fb_t *fb = esp_camera_fb_get();: Captures a frame from the camera.
  • display.println("Night Vision Camera Initialized...");: Displays an initialization message on the OLED display.

Applications

  • Home security
  • Classroom surveillance
  • Low-light monitoring in factories or offices
  • Wildlife observation

Conclusion

This ESP32-powered night vision surveillance camera provides a cost-effective solution for capturing video or images in low-light environments. By integrating an IR camera and LEDs, the system can be used for basic surveillance, making it ideal for home security, classrooms, or outdoor monitoring in dark conditions.