(Last Updated On: December 7, 2020)

Table of Contents:

Introduction:

In this article, we will see how to make an ESP32 Cam & Blynk app-based Security Camera with Motion Detection. in my previous articles, I have gone through sending email and telegram alert whenever the motion is detected, but in those projects, there is no way to capture multiple pictures of an intruder on user request. we cannot identify the specific person If the captured picture is under focussed or off framed, . So I have decided to enable a feature where the user can take multiple pictures of the intruder whenever he wants.

PCBway:

The PCBs I’m gonna use in this video are ordered from PCBway.com, PCBWAY is one of the best PCB manufacturers in the current industry.
PCBway is offering services like PCB prototype, SMD Stencil, PCB assembly, Flexible PCBs & Advanced PCBs.

At PCBway.com we can get 10 pieces of 2 layered PCBs at just $5 with 24 hours build time.

The Best part of PCBway is the Instant quote feature, just enter the PCB size, choose the quantity, layers, and thickness. That’s it, we will get the instant quote. place an order by clicking on saving to cart.

PCBway.com

 

This tutorial is also available in the video format, you can watch the below video or continue reading this article.

 

Required components:

  1. ESP32 Camera                        (Buy Online)
  2. FTDI Programmer Module     (Buy Online)
  3. PIR Motion Sensor                 (Buy Online)
  4. NPN Transistor                       (Buy Online)
  5. 1k and 10k Resistors              (Buy Online)

Introduction to ESP32 Cam:

The ESP32-Cam is a very small camera module with the ESP32-S chip that costs less than $10. Besides the OV2640 camera and several GPIOs to connect peripherals, it also features a microSD card slot that can be useful to store images taken with the camera or to store files to serve to clients.

esp32-camera-module

ESP32 Cam Components/parts:

esp32-cam-components

The ESP32-Cam doesn’t have any onboard USB connector like NodeMCU-ESP8266 comes with an onboard micro-USB connector, so you need an FTDI programmer to upload code through the U0R and U0T pins (serial pins).

esp32-cam-ftdi-programmer

Feature of ESP32 Camera:

Here is a list with the ESP32-Cam features:

  • The smallest 802.11b/g/n Wi-Fi BT SoC module
  • Low power 32-bit CPU, can also serve the application processor
  • Up to 160MHz clock speed, summary computing power up to 600 DMIPS
  • Built-in 520 KB SRAM, external 4MPSRAM
  • Supports UART/SPI/I2C/PWM/ADC/DAC
  • Support OV2640 and OV7670 cameras, built-in flash lamp
  • Supports image WiFI upload
  • Support TF card
  • Supports multiple sleep modes
  • Embedded Lwip and FreeRTOS
  • Supports STA/AP/STA+AP operation mode
  • Support Smart Config/AirKiss technology
  • Support for serial port local and remote firmware upgrades (FOTA)

ESP32-Cam Pinout(AI-Thinker module):

esp32-cam-pinout

There are three GND pins and two pins for power: either 3.3V or 5V.

GPIO 1 and GPIO 3 are the serial pins. You need these pins to upload code to your board. Additionally, GPIO 0 also plays an important role, since it determines whether the ESP32 is in flashing mode or not. When GPIO 0 is connected to GND, the ESP32 is in flashing mode.

Circuit Diagram: ESP32 Cam & Blynk app-based Security Camera with Motion Detection

ESP32+PIR+Email

Here is the circuit for Motion Triggered Telegram Alert Device with ESP32 Camera, The intermediate trigger circuit between Motion sensor and ESP32 will generate an interrupt to wakeup the ESP32-Cam Module when the motion is detected by PIR Motion Sensor. since ESP32-Cam doesn’t have any onboard USB connector as NodeMCU-ESP8266 comes with an onboard micro-USB connector, we will use this FTDI programmer to upload code through the U0R and U0T pins (serial pins). GPIO0 (IO0) needs to be connected to GND, to put ESP32-Cam in the flash mode so that we can upload code.

Schematic Diagram: ESP32 Cam & Blynk app-based Security Camera with Motion Detection

I have implemented the schematic diagram of the same circuit on EasyEDA.com.
MOD1 is the PIR Motion sensor, Intermediate Trigger circuit, ESP32 – Cam, P1 Header to interface with FTDI Module, H1 header to short IO0 and GND pins. H3 header will help us in selection 3.3v or 5v from FTDI,  H2 Header is used to supply the input power either from the battery or 5v 1A Adapter.

Motion triggered Telegram Alert device with help of ESP32 camera Schematic Diagram

PCB Designing:

Below is the PCB for the above schematic, I have Placed all the components on the Top layer, All annotation are placed on the Top Layer, and Finally I have added our website logo on the Both Top Silk Layer & Bottom Silk layer.

Motion triggered Telegram Alert device with help of ESP32 camera_PCB

PCB Order:

Below is the Expected Realtime PCB Picture. Download the Gerber file to a known location and Order the PCB on PCBway.com by uploading the Gerber file.

Note: I have clearly explained the process of Downloading the Gerber file and Ordering the PCB on PCBWay.com. You can refer to the video if you don’t know.

Motion triggered Telegram Alert device with help of ESP32 camera_PCB_picture

Unboxing PCB:

It took me, 7 days to get my parcel delivered to my lab from PCBway via DHL Courier Service. PCBs are nicely packed in the cardboard box.

PCBWay.com Package

Inside the cardboard box, PCBs are neatly packed in the Vacuum Plastic film packaging.  PCBs are so nice, I can feel the softness of the surface of the PCBs when I touch them. Soldering mask and the Silkscreen of the PCBs are very good at quality. The border finishing added value to the PCBs.

PCBreview

PCB Assembly:

I have soldered all the components on the PCB, I have followed the standard assembling process. after 10 mins of soldering all the components sits in their respective places. After Placing all the components, It will be something like this.

PCB Assembly

Setting up the Blynk Application:

Before jump into the programming part lets set up the Blynk app for our project.

I have clearly explained this process on the video tutorial, You can refer to that for better understanding.

Step1: Install the Blynk app from the play store and open it.

Step2: Tap on a new project, Enter a name for the project, choose device type esp32 dev board, choose connection type wifi, Then create it.
That’s it a project is successfully created, an authorization code has been sent to registered email. clink on okay.

Step3: On the project edit page where we can add multiple blynk widgets, add an image gallery widget. Then long press widget to edit size. tap on the widget to assign the pin to it., then come back. add a styled button which is a push-button. Then long-press the widget to edit size. tap on the widget to select digital pin 14 for the button. then change the label color and text as you wish. then come back. Add a notification feature to get notified whenever the intruder detected in the surveillance area.

That’s it Blynk app set up for the project is successfully completed. let’s move to the programming part…

How to make an ESP32-Cam & Blynk app-based Security Camera with Motion Detection_blynk

Installing ESP32 Add-on,  Programming part.

We’ll program the ESP32 using Arduino IDE. So, we should have the esp32 addon installed in our Arduino Ide.

1. ESP32 add-on Arduino IDE.

In this example, we use the Arduino IDE to program the ESP32-Cam board. So, we need to have Arduino IDE installed as well as the ESP32 add-on. If you haven’t installed the ESP32 add-on in your machine, follow the below tutorials and get it installed.

2. Source Code: ESP32 Cam & Blynk app-based security camera with motion detection

Here Is the code forESP32-Cam & Blynk app-based security camera with motion detection, Download the code from below  Github link and open with Arduino IDE.  but do not upload the code yet. we need to make some changes in the code to work for you.

GitHub Project link: https://github.com/VeeruSubbuAmi/ESP32_Cam___Blynk_app_based_security_system_with_motion_detection

The following should change before you upload the code:

Network Credentials:

Insert your network credentials in the following lines:

// Enter your WiFi ssid and password

const char* ssid = "xxxxxxxxxxxxxxxxxxxxx";
const char* password = "xxxxxxxx";
Blynk Authorization Code:

Enter the authorization code that has been sent by blynk while creating a project. this code will be available on the blynk registered email.
Usually, the code will be available on the primary section, but some times it may found on the promotions tab. check on the spam if you didn’t find it on the primary and promotions section.

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";  //sent by Blynk

Uploading Source Code:

Connect FTDI Module with Computer with help of data cable as shown in the below picture and restart the ESP32 camera module.

Connect FTDI with laptopm

 

Note: Make sure you have connected IO0 and GND pins to put the ESP32-Cam module in Flash/ Boot mode.

Check the Uploading configurations like board: ESP32 Wroover Module, Uploading Speed, Partition scheme should be Huge app, otherwise, the code will not compile. then select the right port.

uploading configurations

Testing & Demonstration: ESP32cam & Blynk app – based security system with motion detection

After successful uploading open serial monitor, disconnect IO0 and GND Pins & restart the module.

On the Serial monitor, you can see our ESP32 successfully connected to the programmed wifi and allocated with IP address. it has also started web server and streaming server with port 80 and 81 respectively. As soon as the motion detected, GPIO13 gets LOW, then ESP32 cam will send a notification to the Blynk app along with the captured image. we can see the received notification on the mobile phone. if we click on it it will open blynk app and shows the captured image. we will receive the captured image as long as the intruder’s motion is detected.

ESP32-Cam & Blynk app-based security camera with motion detection

Power Source: ESP32 Cam & Blynk app-based security system with motion detection

As I have discussed in the previous video, you can use any 5v 1A Adapter or 3.7v batteries like Li-ion or Li-po batteries which can be connected as shown below.

power source

Summary:

That’s it for this tutorial. this is how we can make an ESP32 Cam & Blynk app-based security system with motion detection. which will allow the user to take multiple pictures of the intruder.
see you soon on the next interesting project,  bye-bye…

Video Tutorial:

By Veeru

4 thoughts on “How to make an ESP32 Cam & Blynk app-based Security Camera with Motion Detection”
  1. Is there any way to save those captured pictures into the image gallery of the android device on which Blynk app is installed? And can you explain why esp32 cam takes pictures on a fixed interval of time(in infinite loop) even without the motion sensed by PIR sensor?

  2. Have seen the Blynk ESP32 cam in the video tutorials, very excellent and I want to try this for my home
    Thank you for sharing your knowledge, we should make our country self reliant! In all sectors.
    Many thanks,
    S.Yogaraja.
    Ayeepalayam, TN

Leave a Reply