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:

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.

  1. Download the latest Raspberry Pi OS from the official website. The Lite version suffices.
  2. Flash the OS image onto the microSD card using balenaEtcher.
  3. 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.

  1. Hook the Pi up to a monitor and USB keyboard.
  2. Power on the Pi and open a terminal window.
  3. 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.
  4. 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.

  1. SSH into the Pi (ssh pi@raspberrypi) using the new password.
  2. 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.
  3. Once complete, access the web UI at http://<pi-ip>:8765. Default login is admin 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!

  1. 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.
  2. Next, go to the Camera tab:

    • Set the Resolution and Rotation.
    • Enable Timestamp and Annotations if desired.
    • Click Save to apply the camera settings.
  3. 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:

The possibilities are endless! With just a simple Raspberry Pi, you can build an extensible security camera on a budget.