I have been wanting to build a security camera for my home, but most commercial options are expensive and often require monthly fees. However, I recently learned how to make a low-cost motion activated security camera using a Raspberry Pi! This clever hack allows me to build a capable surveillance system on a budget that few people know about.
What You Will Need
To build this low-cost Raspberry Pi security camera, you will need:
Hardware
- A Raspberry Pi - I used the Raspberry Pi 3 Model B+ but any Raspberry Pi with WiFi built-in will work. The newer Pi 4 is ideal.
- A Raspberry Pi camera module - These attach directly to the Pi. Get one compatible with your Pi model.
- A MicroSD card - To install the operating system and software on. I recommend at least 16GB.
- A Power supply - To power the Pi. An official Raspberry Pi one is recommended.
Software
- Raspberry Pi OS - The free Linux distribution I used. Raspbian also works.
- Motion - Open source software that detects motion in video streams. We will install this on the Pi.
- FTP server software - To remotely access video files stored on the Pi. I used vsftpd.
Other Supplies
- A case for the Pi - To protect it. You can 3D print your own or buy one.
- Camera mounts/enclosure - To mount the camera module where you want to point it.
- Ethernet cable - For a wired network connection to maximize bandwidth.
Assembling the Hardware
With all my supplies gathered, it was time to assemble the hardware.
Setting up the Raspberry Pi
I started by inserting the MicroSD card loaded with Raspberry Pi OS into the Pi.
After connecting the Pi to my monitor, mouse, and keyboard, I booted it up to customize the operating system installation.
With the OS ready, I enabled SSH and VNC so I can access the Pi headless after setup.
Connecting the Camera Module
The official Raspberry Pi camera module connects directly to the CSI port on the Pi.
I inserted the ribbon cable securely into the CSI port and attached the camera board.
Accessories
Finally, I placed the Pi inside a protective case and mounted the camera module in an enclosure I 3D printed.
I can position this anywhere I want to point the camera later.
Installing and Configuring Software
With the hardware assembled, it was time to install and configure the necessary software.
Installing Motion
I installed the Motion software on the Raspberry Pi using this command:
sudo apt install motion
This provides the motion detection capabilities.
Configuring Motion
I then edited Motion's configuration file at /etc/motion/motion.conf
to customize its settings:
- I set
daemon
toon
so it runs continuously in the background. - I set the
stream_port
to port8081
for the video stream. - I adjusted the
width
,height
, andframerate
settings as needed. - I tuned the motion detection parameters for my use case.
Setting Up Remote Access with FTP
To access videos remotely, I installed vsftpd - a FTP server for the Pi.
I configured vsftpd to store files in /var/lib/motion
, Motion's default video directory.
Now I can connect to the Pi via FTP to download video files triggered by motion events.
Deploying the Motion-Activated Security Camera
With everything installed and configured, it was time to set up my DIY security camera.
Positioning the Camera
I positioned the camera enclosure to point at my front door to start. The modular design means I can move it anywhere.
Connecting It to My Network
For the best bandwidth, I connected the Pi to my router via Ethernet.
But the built-in WiFi works if Ethernet is not practical for your setup.
Powering on the Camera
The final step was simply connecting the Raspberry Pi power supply to boot up the Pi and activate the camera!
Accessing and Managing Videos
Now my budget Pi security cam is up and running!
When motion is detected, it will record video to the Pi. I can then access these files in a couple ways:
- Connect to the Pi via SSH/VNC to directly access the file system.
- Access the videos remotely using FTP to download footage.
- Stream a live view of the camera feed via the Motion web stream on port 8081.
I can delete old footage as needed to manage storage on the SD card. And I'm notified of any motion events detected!
Closing Thoughts
Building a fully-featured motion activated security camera with a Raspberry Pi turned out to be surprisingly easy and affordable using Motion and a Pi camera module.
The final product rivals commercial offerings at a fraction of the price, and I can customize it to suit my needs. This project is a prime example of the versatile uses for Raspberry Pis!
With some additional work, I could even enable remote access to the video stream over the Internet. But for now, I am satisfied with the local storage and network access capabilities.
I'm thrilled to add this DIY Raspberry Pi camera to my home surveillance system on the cheap. Let me know if you build your own!