How to Build a Raspberry Pi Security Camera with Motion Detection on a Budget
Building your own Raspberry Pi security camera with motion detection is a fun and affordable DIY project. With just a few components, you can create a camera that will monitor for movement and send you alerts. Here is a step-by-step guide on how to build your own Raspberry Pi security camera on a budget.
Shopping List
Here are the components you'll need to build the security camera:
- Raspberry Pi - The brain of the camera. A Raspberry Pi 3 or 4 is recommended.
- Camera module - Allows the Pi to capture video. The official Raspberry Pi camera module works best.
- MicroSD card - Stores the operating system and video recordings. Aim for at least 16GB.
- Power supply - Powers the Pi. Any 5V micro USB power supply will do.
- Enclosure (optional) - Houses the Pi. A basic plastic case works well.
In total, expect to spend around $100 for all the core components if buying new. However, you may be able to reduce costs by using a spare Raspberry Pi or shopping for secondhand parts.
Installing the Operating System
The first step is to install the Raspberry Pi OS operating system onto the microSD card.
- Download the latest Raspberry Pi OS from the official website. The Lite version suffices.
- Flash the OS image onto the microSD card using balenaEtcher.
- Once flashed, insert the microSD card into the Pi.
Setting Up the Raspberry Pi
With the OS ready, now it's time to configure the Pi for our security camera.
- Hook the Pi up to a monitor and USB keyboard.
- Power on the Pi and open a terminal window.
- Run
sudo raspi-config
to open the configuration menu.- Change the default password under "System Options > Password".
- Enable the camera under "Interface Options > Camera".
- Finish and choose to reboot.
- After rebooting, enable SSH by creating an empty file called
ssh
on the boot partition.- This will allow us to access the Pi remotely later.
The Raspberry Pi is now ready to rock! Next, we'll install the required software.
Installing Motion Detection Software
MotionEyeOS is an excellent open-source software for DIY security cameras. We'll install it from scratch onto the Raspberry Pi OS.
- SSH into the Pi (
ssh pi@raspberrypi
) using the new password. - Follow the MotionEyeOS install guide. Key steps:
- Run
curl https://github.com/ccrisan/motioneyeos/raw/master/install.sh | bash
- When asked, choose to install the
motioneye
package. - Update permissions with
sudo chmod 755 /etc/motioneye /usr/bin/motioneye
.
- Run
- Once complete, access the web UI at
http://<pi-ip>:8765
. Default login isadmin
with no password.
With MotionEyeOS running, we can configure the security camera settings and enable motion detection alerts.
Configuring the Camera
Now for the fun part - setting up the security camera!
-
In the MotionEyeOS web UI, go to General Settings:
- Set the Camera name and Admin username/password.
- Change the Video streaming port if needed.
- Save the settings.
-
Next, go to the Camera tab:
- Set the Resolution and Rotation.
- Enable Timestamp and Annotations if desired.
- Click Save to apply the camera settings.
-
Go to Motion Detection to configure alerts:
- Set the Threshold and Noise level as needed.
- Enable Trigger a command and enter a webhook URL or script path to run on motion.
- Click Save to finish.
And that's it! The Raspberry Pi security camera is ready for action. It will monitor for motion events and send alerts as configured.
Going Further
To take this project further:
- Add a Pi-compatible IR night vision camera module for 24/7 surveillance.
- Configure off-site storage like Dropbox to save video recordings.
- Enclose the Pi in a wall-mounted camera housing for outdoor use.
- Integrate with home automation platforms like HomeAssistant for smart alerts and controls.
The possibilities are endless! With just a simple Raspberry Pi, you can build an extensible security camera on a budget.