Introduction

Keeping your home safe and secure is a top priority. Investing in an expensive security camera system may not be feasible for everyone. Fortunately, with a Raspberry Pi and a few inexpensive components, you can build your own motion-activated security camera for around $50.

In this guide, I'll walk you through every step to build a DIY security camera using Raspberry Pi. With just a little bit of effort, you can have your own motion-activated camera up and running in no time. Let's get started!

What You Will Need

Building your Raspberry Pi security camera doesn't require many components. Here is a complete list of everything you will need:

In total these components cost around $50 on Amazon. Now let's look at assembling our camera.

Setting up the Raspberry Pi

The first step is setting up the Raspberry Pi with the operating system.

  1. Insert your microSD card into your computer.

  2. Download the Raspberry Pi OS Lite from the official website. This is a minimal version without a GUI.

  3. Use balenaEtcher to flash the OS image onto the microSD card.

  4. Insert the microSD card into your Pi and connect it to power. It will boot up directly to the command line.

  5. Next, you need to enable the camera module. Run sudo raspi-config and select Interface Options > Camera to enable video support. Reboot when prompted.

The Raspberry Pi is now ready to go with the camera enabled! Now we can add components.

Connecting Components

With the Pi prepped, we can start hooking everything up:

Once powered on, verify everything is connected properly with lsusb for the camera and reading the motion sensor values at /sys/class/gpio/gpio4/value.

If all looks good, we can move on to software installation.

Installing and Configuring Software

Now for the fun part - installing and configuring the software to bring our security camera to life.

Install Required Packages

First we need to install the packages for recording video when motion is detected:

sudo apt update
sudo apt install motion libmariadb3 mariadb-server

Motion is the program that will monitor the motion sensor and camera module to detect movement and record video. MariaDB is for storing information on motion events.

Configure Motion

Next we need to configure Motion with some key settings:

sudo nano /etc/motion/motion.conf

In this file, make sure to update the following:

There are many more options you can tweak, but this covers the basics.

Automating Startup

The last software step is making Motion start automatically on boot:

sudo systemctl enable motion

Now whenever your Pi powers on, the motion detection software will start!

With all the software configured, our motion-activated security camera is complete. Time to test it out.

Testing and Using Your Security Camera

To test your DIY security camera, just walk in front of the motion sensor. You should see Motion detect activity and start recording video to the /tmp directory.

Stream the live video feed by opening the stream_localhost address you configured in Motion earlier. I used VLC media player to view the stream.

You can also pull recorded clips from /tmp via SFTP. I set up automated FTP transfers to my home server for persistent storage.

And that's it! You now have your very own motion-activated security camera with Raspberry Pi. For under $50, you can monitor your home day and night.

This basic camera has tons of room for upgrades and expansions too. You could add live streaming, object detection, TensorFlow integration, and more! But even in its simplest form, it keeps your home a little more secure.

Let me know if you have any other questions. I'm happy to help out with your own DIY security camera project!