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:

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:

-Magnetic Door Sensor - Sense open/closed status of doors.

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:

  1. Download the Raspberry Pi OS image and install it on a microSD card.

  2. Insert the microSD card into the Pi and connect it to a monitor, keyboard, power adapter and internet.

  3. Boot up the Pi, run through the setup wizard to configure system settings like WiFi, timezone, etc.

  4. Open the terminal and update the system with sudo apt update and sudo apt full-upgrade.

  5. 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:

  1. In the terminal, run: sudo apt install motioneye. Enter your password when prompted.

  2. Once installed, enable MotionEye to start on boot:

sudo systemctl enable motioneye

  1. Start the service immediately with:

sudo systemctl start motioneye

  1. 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:

  1. In a web browser, visit the Pi IP address on port 8765 (e.g. http://192.168.1.100:8765).

  2. Log into the MotionEye interface with the default admin credentials (admin/admin).

  3. Go to the Camera tab and click Add New Camera.

  4. Set the Name, Device URL as /dev/video0, Streaming Method as MJPEG, and Resolution to your preference.

  5. Click Save to add the camera. It should display the live video feed.

  6. You can tweak settings like frame rate, rotation, and streaming quality in the Advanced section.

  7. Click on the Motion Detection tab to enable and configure motion alerts.

  8. 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:

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:

  1. Install the Pushbullet app on your phone and create an account.

  2. On the Pi terminal, run sudo apt install pushbullet.py to install the package.

  3. Run pushbullet-configure and enter your Pushbullet access token.

  4. 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:

  1. Attach an external hard drive to the Raspberry Pi.

  2. Run sudo apt-get install samba samba-common-bin to install Samba.

  3. Edit the Samba config file: sudo nano /etc/samba/smb.conf.

  4. Under the [pi] section, add the folder you want to share, like:

path = /home/pi/security_recordings
browseable = yes
writable = yes

  1. Create a Samba user: sudo smbpasswd -a pi

  2. Restart the service: sudo service smbd restart

  3. 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:

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!