WiFi CCTV Camera Using ESP32-CAM Development Board

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

WiFi CCTV camera

Circuit Diagram

ESP32-CAM Security Camera 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)

PCB Design

After designing the schematic diagram of the CCTV camera, the assembled components and wiring are too clumsy and looked very unprofessional. In fact, the wiring also has a chance of loose connection. To give it a clean and professional look and compress the size, I decided to build its PCB prototype using EasyEDA software as it is so simple to use. Now come to the main part, where we need to order our PCB prototype. I always prefer PCBWay for its quality assurance, fastest delivery, and 24/7 customer support.

PCB View

ESP32-CAM Security Camera 2D View
2D View
ESP32-CAM Security Camera 3D View
3D View

My Opinion About PCBWay

To start off with, PCBWay is a Chinese-based PCB (printed circuit board) prototype, PCB assembly, SMD Stencil and Flexible PCB manufacturing company. For the past 1.5 years, I have been collaborating with them on my projects and genuinely it is an awesome experience. So today, I will state and give my personal opinion regarding the online service of PCBWay. I have been offered to promote some other PCB manufacturing companies, but compared with them, I feel like PCBWay combines an excellent price and customer service factor in one single serving. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website UI, it all counts towards what makes PCBWay an ideal company for any electronic hobbyist.

When I first approached PCBWay, the features to navigate around their website really astound me, especially since their website is full of features, PCB functions and information about the brand. I also observed their sales statistics on their webpage, which intrigued me a lot because of their high figures for successful payments, partnerships, and published projects. Not many companies truly display their sales information, so this really caught my eye. I also experienced some contests arranged by PCBWay where you will get lots of coupons, lucky draws, discounts, amazing electronics prizes and a few more by simply participating in them.

Moreover, their website includes an instant quote feature, so if you are directed to their homepage, you can put your custom PCB details and Gerber file to receive an estimated price. Also, if you want to view your Gerber file, you don’t need to go anywhere else.

Now, once you have put all your customisation options in place and made your final choices, you can receive a quote directly from the website with a rough price estimate. The price of your product will be based on the options you choose, with the higher, more expensive options contributing to your price more heavily. Shipping is also included separately, with DHL being the most expensive method and standard airmail being the cheapest method of shipment. Your country’s location also matters when determining the shipping cost. The nice thing about PCBWay’s website is that you can see how the final price is broken down by certain costs. Furthermore, there is a choice for you to select your build time and shipping method so that when you change it, you can instantly see the price difference. So go to their website and check out their recent offers and more.

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 Security Camera To FTDI Converter Connection Circuit Diagram
ESP32-CAMFTDI Module
U0RTX
U0TRX
GPIO0GND
+5V+5V
GNDGND
ESP32-Cam To FTDI Module Connection

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.

Router Settings for CCTV Camera

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.

ESP32-CAM Arduino IDE Settings

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 Compile

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

esp32-cam-arduino-ide-serial-monitor-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.

Dashboard for WiFi CCTV camera

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

Leave a Comment