Motion Controlled Photo Capture with Raspberry Pi and PIR Sensor




"Motion Controlled Photo Capture with Raspberry Pi and PIR Sensor" is an experimental prototype design for a security surveillance system for our home or office area. This prototype has a camera and a passive infrared sensor (PIR) sensor module. This system is able to capture a photo when any motion is detected by the sensor. The captured photos will be kept in the local storage for review. Here we are using the Raspberry Pi as the heart of the project. The Raspberry Pi has its own dedicated camera port and customized camera module which is fully compatible with Raspberry Pi. With those modules, we took a cheap PIR sensor module to detect the motion.

Components Need:


  1. Raspberry Pi (any model)
  2. A class 10 32GB micro-SD card (big SD card size help to store more number of photos)
  3. Camera module compatible with Raspberry Pi camera slot
  4. PIR sensor module
  5. Supportive equipment like a power supply for Raspberry Pi, a monitor, mouse, keyboard to configure the system.


  1. No extra software is needed except the Raspbian Operating system.

Working Principle:

A very simple workflow is running behind this prototype. We are using the PIR sensor to detect the motion. When any motion happens in the range of the sensor then the sensor generates a High signal. And this signal will be captured by the Raspberry Pi. When the signal received by the Raspberry Pi then it triggered the camera to take a picture. All the pictures will be kept to a local directory with the proper timestamp. Users can review those photos as their time. We programmed the PIR to reset after the 3 seconds from the motion capture time. We also use the same time gap in our program to synchronize with the sensor. But this timing parameter can be varied.

Hardware Setup:

For this prototype, we need a very basic hardware setup. The Raspberry Pi needs to be powered and connected with the basic peripherals like a mouse, keyboard, monitor. The camera module needs to connect with the Camera Serial Interface (CSI) interface of the Raspberry Pi. The PIR sensor module has three interface pin. One is for VCC one is for Ground and the rest one is for the signal. 



We connected the VCC and the Ground pins with the power supply of Raspberry Pi and the rest one is connected with the GPIO 12 pin. This is the hardware setup that we need. We used some jumper wires to connect the PIR sensor module with the Raspberry Pi.

Software Setup:

We need python for this project. We write a simple python program that uses RPi.GPIO and some basic library for it. The Raspberry Pi will continuously check the status of the output pin of the PIR sensor and if the signal goes high then it will trigger the camera module and the camera will capture the photo. 



Here is a screenshot of the python program. This file will run in the background. The next image shows the output of the program. It is clearly visible that the program shows "PIR is off ..." most of the time due to the continuous checking of the state of the PIR sensor. When the sensor sends the motion-detect signal to the program, then it starts to capture a photo.



Here we add a sample photo that was captured by the camera. The camera has 5 MP resolution. Due to this low resolution, the photo is a bit low in quality but this will serve the purpose of the prototype.



This is a simple prototype design, but it has a huge scope of up-gradation. The first one is the storage location of the photos. In this project, we store the photos in the local storage. But it may cause fewer memory issues in the Raspberry Pi and the photos may be lost forever. So we can solve this issue by transferring those photos to a web server. With this, we can also send those photos to an end-user in real-time.


Project Credit:

Project Idea, Project Execution:

Subhankar Biswas
Ph: 9679340042

Thank You

Leave a Comment

View Previous Comment

MUKESH 11th May, 2020

great work Will it work with a mobile camera?

Show 1 Reply

Anand 11th May, 2020

Good work, nicely explained. This project can be very usefull for police to capture any movement in high alert zone. Specifically useful for defense to capture any movement in nearby border. Great work!!

Show 1 Reply

Subho Basak 11th May, 2020

Nice project and clearly explained. And if you add some explanation on the code it would be great for the beginners. And I know it takes time, but if you add a YouTube video like one of your previous project, with this article will be more attractive and helpful for beginners.

Show 1 Reply