I wanted to build a smart home security system on a budget. As a tech enthusiast, I knew that Raspberry Pi would be the perfect platform for creating an affordable DIY system to secure my home. In this guide, I will walk you through the complete process of setting up your own smart home surveillance with Raspberry Pi.
Why Build Your Own Security System
Purchasing an off-the-shelf smart security system can cost hundreds or even thousands of dollars. Major brands like ADT and Vivint require long contracts, charge high monthly fees, and use proprietary technology that limits customization.
By choosing to build your own system with Raspberry Pi, you get total control and flexibility. Here are some key benefits of the DIY approach:
-
Lower Cost - You can build an advanced system for less than $100. No expensive monthly fees either.
-
Open Source - Everything is customizable since you use open source software and hardware.
-
Privacy - No data gets sent to the cloud without your knowledge. It stays local.
-
Expandability - Start small and add cameras, sensors, etc. easily later on.
-
Education - Learn new skills about Linux, programming and electronics.
The Raspberry Pi platform is perfect for home automation and security. Let's look at how to leverage it.
Raspberry Pi Security System Components
The Raspberry Pi microcomputer serves as the central hub for our smart security setup. Here are the main hardware components we will use:
-
Raspberry Pi - Runs the Linux-based OS and security software. Mini computer.
-
Camera Module - Attaches to the Raspberry Pi to provide video surveillance.
-
Motion Sensor - Detects movement and triggers the camera.
-Magnetic Door Sensor - Sense open/closed status of doors.
-
PIR Sensor - Motion detection for rooms.
-
Speaker - Provides audio alerts and notifications.
In addition, a microSD card stores footage and software. A power adapter powers the Pi. And an Ethernet cable or WiFi provides connectivity.
Install and Configure Raspberry Pi OS
The first step is to get the Raspberry Pi up and running with the operating system:
-
Download the Raspberry Pi OS image and install it on a microSD card.
-
Insert the microSD card into the Pi and connect it to a monitor, keyboard, power adapter and internet.
-
Boot up the Pi, run through the setup wizard to configure system settings like WiFi, timezone, etc.
-
Open the terminal and update the system with
sudo apt update
andsudo apt full-upgrade
. -
Reboot Pi to complete OS installation.
With the OS ready, we can move on to installing and configuring the security software.
Install MotionEye Security Camera Software
MotionEye is an excellent open source surveillance camera system for Linux. We will use it to manage cameras and recording.
Follow these steps to install MotionEye on the Raspberry Pi:
-
In the terminal, run:
sudo apt install motioneye
. Enter your password when prompted. -
Once installed, enable MotionEye to start on boot:
sudo systemctl enable motioneye
- Start the service immediately with:
sudo systemctl start motioneye
- Verify it is running:
sudo systemctl status motioneye
With MotionEye installed, we can configure the security cameras and other settings.
Set Up the Camera in MotionEye
Here is how to set up the Raspberry Pi Camera Module in MotionEye:
-
In a web browser, visit the Pi IP address on port 8765 (e.g. http://192.168.1.100:8765).
-
Log into the MotionEye interface with the default admin credentials (admin/admin).
-
Go to the Camera tab and click Add New Camera.
-
Set the Name, Device URL as
/dev/video0
, Streaming Method as MJPEG, and Resolution to your preference. -
Click Save to add the camera. It should display the live video feed.
-
You can tweak settings like frame rate, rotation, and streaming quality in the Advanced section.
-
Click on the Motion Detection tab to enable and configure motion alerts.
-
Make sure to Save the settings.
Now MotionEye will stream and record video based on the parameters you specified.
Connect Motion Sensors and Door Sensors
Adding motion and door sensors around your home lets the security system actively monitor for physical breaches.
Here is how to hook them up:
-
Obtain PIR motion sensors and magnetic door/window sensors. They plug into the the Raspberry Pi's GPIO pins.
-
Using jumper wires, connect the signal pin on each sensor to a GPIO pin on the Raspberry Pi.
-
Enable the GPIO daemon in Raspberry Pi's preferences so it can detect sensor state changes.
-
In MotionEye camera settings, configure Actions like email alerts when the sensors are triggered.
With those steps complete, your cameras will initiate recording when the sensors are tripped, giving you video evidence of any intrusions!
Receive Mobile Alerts with Pushbullet
Receiving real-time mobile notifications whenever the system detects something is extremely useful.
I recommend using the free app Pushbullet for this:
-
Install the Pushbullet app on your phone and create an account.
-
On the Pi terminal, run
sudo apt install pushbullet.py
to install the package. -
Run
pushbullet-configure
and enter your Pushbullet access token. -
In MotionEye, go to Actions for your cameras and set notifications to use Pushbullet.
Now when motion or a door sensor is triggered, you'll get an instant push notification on your smartphone.
Store Footage Remotely with Samba Share
It's important to store your security footage where it can't be deleted or destroyed locally.
Setting up a Samba share allows saving recordings to another device on your network:
-
Attach an external hard drive to the Raspberry Pi.
-
Run
sudo apt-get install samba samba-common-bin
to install Samba. -
Edit the Samba config file:
sudo nano /etc/samba/smb.conf
. -
Under the
[pi]
section, add the folder you want to share, like:
path = /home/pi/security_recordings
browseable = yes
writable = yes
-
Create a Samba user:
sudo smbpasswd -a pi
-
Restart the service:
sudo service smbd restart
-
On your Windows/Mac, connect to the shared folder.
The MotionEye recordings will now securely save directly to the network drive!
Automate Security Actions with Home Assistant
An advanced option is adding Home Assistant to automate actions based on sensor triggers.
Some examples of useful automations:
- Flash lights when motion detected.
- Sound alarm when door opened.
- Only record when home mode active.
Home Assistant connects to MotionEye and lets you create rules. Definitely recommended for taking your smart security to the next level!
Conclusion
Building your own home security system with Raspberry Pi and open source software is extremely powerful while being affordable for home use.
No need to pay monthly fees to alarm companies! With these steps, you can now set up customized surveillance, alerts and automation to protect your home.
The ability to self-monitor through your own network gives peace of mind. I hope this guide gives you a starting point to leverage Raspberry Pi's capabilities for keeping your home and family safe. Let me know if you have any other questions!