Setting up a Security Surveillance System with Raspberry Pi and Camera Module

A step-by-step guide for installing camera module in Raspberry Pi and using it for security surveillance. …


Updated October 6, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


A step-by-step guide for installing camera module in Raspberry Pi and using it for security surveillance.

Introduction

Raspberry Pi is an affordable, credit card sized computer that can be used for various purposes including home automation, robotics, and internet of things (IoT). One of its most interesting uses is as a surveillance system. In this article, we will learn how to set up a security surveillance system using Raspberry Pi and Camera Module.

Requirements

  • A Raspberry Pi 4 Model B or above with Raspbian OS installed (other versions may work but have not been tested)
  • A Micro SD Card (minimum 8GB) with Raspbian OS pre-installed
  • A Raspberry Pi Camera Module V2.1 or later
  • An HDMI Monitor, Keyboard, and Mouse for initial setup
  • Power supply (5V, 2.5A recommended)
  • A tripod or stand for the camera module (optional but recommended)

Step 1: Setting up the Raspberry Pi Camera Module

Insert the Micro SD card into your Raspberry Pi and connect it to a monitor using an HDMI cable. Plug in the power supply, keyboard, and mouse. Open a terminal window by clicking on the terminal icon on the taskbar or pressing Ctrl+Alt+T.

First, update the package list and install the necessary dependencies:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-picamera python3-rpi.gpio

Step 2: Connecting the Camera Module to Raspberry Pi

Connect the camera module to your Raspberry Pi using the ribbon cable that came with it. The pins should align automatically on both sides, and you can secure them in place by pressing gently. Ensure that the red light on the camera is lit.

Step 3: Testing the Camera Module

To test if the camera module is functioning correctly, open the Python interpreter by typing python3 in the terminal window. Then, run the following code:

import picamera
camera = picamera.PiCamera()
camera.start_preview()
input('Press Enter to stop...')
camera.stop_preview()

This will start a preview of what the camera is seeing on your monitor. Press Enter to stop the preview. If everything works correctly, you should see a live video feed from the camera module.

Step 4: Installing MotionEyeOS

MotionEyeOS is an open-source surveillance software that makes it easy to set up and manage your security system with Raspberry Pi and Camera Module. To install it, run the following commands in the terminal:

wget https://github.com/motioneye/motioneye_pi_config/archive/master.zip
unzip master.zip
cd motioneye_pi_config-master
sudo ./install.sh

This script will install MotionEyeOS and all the necessary dependencies. Once the installation is complete, reboot your Raspberry Pi by running:

sudo reboot

After the reboot, open a web browser on your computer and enter http://<RASPBERRY_PI_IP>:8765 in the address bar (replace <RASPBERRY_PI_IP> with the IP address of your Raspberry Pi). You should see the MotionEyeOS interface.

Step 5: Configuring MotionEyeOS

In the MotionEyeOS interface, click on Configuration in the top menu and select Add Camera. Fill out the necessary details, such as camera name, resolution, framerate, and rotation (if needed). For the source, choose /dev/video0. Save your changes by clicking on Save.

Step 6: Viewing Video Feed

In the MotionEyeOS interface, click on the newly created camera to view its video feed. You can also set up motion detection and other features within the software.

Conclusion

You have now successfully installed a camera module in your Raspberry Pi and set up a security surveillance system using MotionEyeOS. With this setup, you can monitor your home or office remotely and receive alerts when motion is detected. You can also expand the system to include multiple cameras and record footage for later review.