1. Introduction
In security systems, capturing images is useful—but storing them is even more important. In this project, we enhance the ESP32-CAM motion detection system by saving captured images directly to a microSD card.
Whenever motion is detected, the ESP32-CAM captures an image and stores it permanently in the SD card with a unique filename.
This project is ideal for:
-
Home security systems
-
Surveillance applications
-
IoT-based monitoring
2. Components
- ESP32-CAM Module
-
PIR Motion Sensor (HC-SR501)
-
MicroSD Card (4GB–32GB, FAT32)
-
FTDI Programmer
-
Jumper Wires
-
Breadboard
-
5V Power Supply (2A recommended)
3. Circuit and Connections
 |
Pinout Diagram of PIR Motion Sensor
|
🔌 Connections:
💾 SD Card
-
Insert into ESP32-CAM slot (no wiring needed)
PIR Sensor → ESP32-CAM
- VCC → 5V
- GND → GND
- OUT → GPIO 13
FTDI Programmer → ESP32-CAM (Uploading)
- VCC → 5V
- GND → GND
- TX → U0R
- RX → U0T
- GPIO0 → GND (for programming mode)
4. Detailed Step-by-Step Circuit Working
- PIR sensor detects motion.
-
Output goes HIGH when motion is present.
-
ESP32-CAM reads this signal.
-
Camera captures image using internal camera module.
-
Image is stored in temporary memory (frame buffer).
-
Image is then saved to SD card as a .jpg file.
-
Each image is saved with a unique filename.
5. Code
6. Detailed Step-by-Step Code Working
SD_MMC.begin() initializes SD card
PIR sensor detects motion
esp_camera_fb_get() captures image
millis() generates unique filename
file.write() saves image to SD card
esp_camera_fb_return() clears memory
7. Tips
Use Class 10 SD card for better speed
Always format SD card to FAT32
Use 5V 2A power supply (very important ⚠️)
Adjust PIR sensitivity using onboard potentiometer
Add delay to avoid multiple image captures
8. Uses
-
Home surveillance system
-
Office security monitoring
-
Motion-triggered camera
-
Evidence recording system
9. Conclusion
This ESP32-CAM SD card-based motion detection system is a powerful and reliable solution for offline security monitoring. It allows continuous image logging without requiring internet connectivity, making it ideal for real-world applications.
Note: Similar Projects
https://simplebasicelectronics.blogspot.com/2026/03/arduino-pir-motion-sensor-alarm.html
https://simplebasicelectronics.blogspot.com/2026/04/esp32-wi-fi-weather-station.html
https://simplebasicelectronics.blogspot.com/2026/03/esp32-cam-face-recognition-system-arduino.html
https://simplebasicelectronics.blogspot.com/2026/03/arduino-keypad-password-door-lock-system.html