In this tutorial, we will learn how to build a CCTV Camera using just one component, ESP32-CAM which is very popular today to monitor our home, surrounding environment, office, shop, etc.
Even decent commercial WiFi CCTV Cameras aren’t also expensive, but they still cost quite a bit especially when you’re planning to buy several of them for a home security system. In this project, you will learn how to make your own DIY Surveillance CCTV Camera for under $10 depending on the supplies you used for clarification. This project will be based on the $8 ESP32-CAM AI thinker WiFi camera module, one of the best and cheapest camera development boards in the market.
With a unique IP address, you can directly log into the web server through your web browser, and view exactly what the camera sees. Some days ago, I built a WiFi Security Camera using the same module. But this had many limitations like no SD card recording, no wireless recording, no motion tracking, and no image capture, etc. In this, we will be going to add these features. For a basic understanding of ESP32-CAM, you can also check out that project.
So without taking up any more time, let’s make this incredible project for our home.
Project
Circuit Diagram
Components Required
- ESP32-CAM Board
- FTDI USB to Serial Converter
- 5 Volt AC to DC Converter (Hi-Link)
- Connection Wire
- Container (Dummy CCTV Camera Kit)
Programming ESP32-CAM CCTV Camera
First, to program the ESP32-CAM module, first, connect the module to a USB-to-Serial FTDI converter as shown in the schematic below.
ESP32-CAM | FTDI Module |
---|---|
U0R | TX |
U0T | RX |
GPIO0 | GND |
+5V | +5V |
GND | GND |
To program and be ready to upload the code to the ESP32-CAM module, connect GPIO pin 0 to the ground as mentioned above schematic. Also need to press the reset button to set it to flash mode before uploading the code.
Before uploading the code, make sure that you have the “https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json” link pasted into the preferences tab of the Arduino IDE. This link provides you access to example codes, libraries you need, etc.
Make sure your ESP32 board library version is at 2.0.2 or higher
After that fill in all the necessary parameters such as selecting your camera model (uncomment “CAMERA_MODEL_AI_THINKER” if that’s your board and comment the unnecessary board type), and enter your WiFi credentials, password, and FTP credentials (optional) if you want to keep your recorded data remotely. This now has to be done in the “utils.cpp” tab.
Make sure you select “ESP32 Dev Module” with partition scheme “Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)”, enable PSRAM, and choose your COM port. Then press upload. If any errors occur, then make sure that all the necessary libraries are installed.
When you start to see these connection dots on the debugging window as shown below, press the ESP32-CAM on-board reset button.
ESP32-CAM Code
Now download the ESP32-CAM WiFi CCTV camera code from github “MJPEG2SD” (special thanks to “s60sc” for making their code available for anyone to download in the github portal).
After uploading the code, make sure to unplug the wire between IO0 and GND and press the reset button. Then insert a Micro SD card into the SD card slot (Min 4GB), then obtain a unique IP address from the Arduino IDE serial monitor.
Preparing ESP32-CAM and Getting IP Address
After putting the given IP address into your web browser, you will get the same page looking like this below. Now press the “Start Stream” button, and you will be able to view live footage of what the camera actually sees.
Troubleshooting of ESP32-CAM CCTV Camera
- Failed to connect to ESP32: Timed out waiting for packet header
- Camera init failed with error 0x20001 or similar
- Brownout detector or Guru meditation error
- Sketch too big error – Wrong partition scheme selected
- Board at COMX is not available – COM Port Not Selected
- Psram error: GPIO isr service is not installed
- Weak Wi-Fi Signal
- No IP Address in Arduino IDE Serial Monitor
- Can’t open web server
- The image lags/shows lots of latency