Motion Sensing Photo Capturing Device Using ESP32-CAM

Previously, we have built some camera-based IoT projects using the ESP32-CAM Development Board. Those are very effective projects for home automations. So we thought to innovate some new projects using these ideas for the security system.

In this project, we’re going to make a Motion Sensing Photo Capturing Device using the ESP32-CAM module. For that, we use a PIR motion sensor for detection. When the PIR sensor detects any motion near the device, it will automatically capture a photo, and save it on the microSD card.


Motion Sensing Photo Capturing Device

Circuit Diagram

Motion Sensing Photo Capturing Device Circuit Diagram

Components Required

  • ESP32-CAM WiFi Camera Module
  • FTDI Programming Module
  • PIR Motion Sensor
  • 2N3904 Transistor
  • 1K Resistor
  • Connection Wire
  • Breadboard
  • 5V Hi-Link Converter

ESP32-CAM Module Specifications

The ESP32-CAM is based on the ESP32-S module. It has the same features.

  • 802.11b/g/n Wi-Fi
  • Bluetooth 4.2 with BLE
  • UART, SPI, I2C, and PWM interfaces
  • Clock speeds up to 160 MHz
  • Computing power up to 600 DMIPS
  • 520KB SRAM + 4 MB PSRAM
  • Supports WiFi Image Upload
  • Multiple sleep modes
  • Firmware Over the Air (FOTA) upgrades possible
  • 9 GPIO ports
  • Built-in Flash LED

Camera Specifications for Motion Sensing Photo Capturing

The ESP32-CAM has an inbuilt OV2640 camera module. The device also supports OV7670 cameras.

  • 2 megapixel camera sensor
  • Array size UXGA 1622×1200
  • Output formats include YUV422, YUV420, RGB565, RGB555 and 8-bit compressed data
  • Image transfer rate of 15 to 60 fps

Programming ESP32-CAM Camera Module

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-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 “” link pasted into the preferences tab of the Arduino IDE. This link provides you access to example codes, libraries you need, etc.

Working Principle of Motion Sensing Photo Capturing Device

Now let’s talk about the working principle of this simple motion sensing photo capturing device.

At the stand-by situation, the ESP32-CAM module is in deep sleep mode with external wake-up enabled.

When any motion is detected in front of the camera viewing area, the PIR motion sensor sends an Analog signal to wake up the ESP32-CAM.

At the same time, ESP32-CAM takes a photo of the moving object and saves it on the microSD card.

Thereafter, again it turns back to deep sleep mode until another signal from the PIR motion sensor is received.

ESP32-CAM Code

To develop this code, all credit goes to Rui Santos.

Applications of Motion Sensing Photo Capturing Device

  • Usually used in home security systems.
  • Large uses in local shops, malls, banks, companies, etc.

Leave a Comment