Raspberry Pi Security Camera

This post is meant as a guide for setting up a Raspberry Pi as a security camera. First, I will tell you what hardware you need and how to setup it up, then I will walk you through configuring the software, then finally how to view and archive your security footage. I used a Raspberry Pi model B because i had one lying around but you can do this with any Raspberry Pi that has the camera connector. I will assume you don’t have any of the items needed to get this done so if you do please use what you have. Otherwise, I encourage you to be adventurous and get upgraded versions.

What you need before you start

  • Raspberry Pi Model B
  • SD Card for Raspberry Pi
  • Wifi Adapter for Raspberry Pi
  • Charger for Raspberry Pi
  • HDMI Cable ( For Raspberry Pi Setup)
  • TV/Monitor with HDMI Input ( For Raspberry Pi Setup)
  • Very long charging cord for Raspberry Pi
  • Keyboard/mouse to setup Raspberry Pi ( For Raspberry Pi Setup)
    • wireless 2 in 1 works great for Pi with only 2 usb ports because you need one for wifi
  • Raspberry Pi Camera
  • Raspberry Pi Case
  • Standard Drill (optional for mounting Pi)
  • Mount (thing about where you want to mount the camera)

Setting up the Raspberry Pi

Place the Raspberry Pi into the case before making any connections. If your case doesn’t have a port for the camera don’t close it just yet.


You will connect the keyboard/mouse, power adapter, camera, wifi adapter, HDMI cable to the tv/monitor and SD Card setup with NOOBS to your Raspberry Pi. Use the NOOBS setup instructions on the official Raspberry site to setup Raspbian. You can find a great video walkthrough on youtube.

Setting up SSH

After Raspbian is setup your pi should boot up to the desktop. Everything from this point on will be done in the terminal. When the camera is mounted it will not have the keyboard/mouse or monitor connected. Therefore, we need to setup ssh to access the device. Please follow the official Raspberry Pi instructions for enabling ssh.

Setting up Motion

Motion is the software you will use to monitor the feed and take images and video whenever it detects movement. I find this more efficient than 24/7 full motion video. Before you setup motion please setup your camera and verify that it is working. Here is a youtube video that will guide you though the process. The next step is to install and configure motion. Please follow the instructions on this youtube video.

Mounting  the Camera

If everything when well you should have a Raspberry pi + camera with motion installed and capturing movement. You can get creative about how you mount the Pi but I decided to drill holes in the Pi case for my setup. First drill a hole into the top facing part of the case for your camera. It has to be just right for the camera to fit through. Place it slightly down from center on the side of the camera port so you have enough space to spread the camera cable once the case is closed. The extra cable should help the camera to stay in place.


I used the above case because I had it lying around. You will notice I spray painted it but I still have all the other ports visible.  For that reason I recommend getting a fully enclosed case.


Mounting the Case

There are many different ways to do this last part but by now you should have a closed raspberry pi with camera hidden inside the case. The easiest way to do this is simply put the pi case in a universal cellphone mount.

I went a step further and screwed the pi directly on the mount. I bought the following mount because it had the longest most flexible arm I could find. It is great if you need to mount it in an awkward position.


Break off the plastic part which is meant to hold the device. You will be left with the screw that goes directly into the tip of the mount. remove the screw and put it to the side. Remove the raspberry pi from the case and drill a hole into the back of the case. The hole should be big enough for the screw to fit through. Then screw the back of the case directly to the mount and put the Raspberry Pi back together.


Once the case is mounted and is facing the area you want to monitor, open the browser from a computer on your network and navigate to the webpage hosted on the Pi which allows you to see live footage. Please see the section on setting up motion if you are not sure how to get to it.

Accessing Captured Images and Video

All images are stored in /var/lib/motion on the Raspberry Pi. You can copy them to your local computer with SCP, setup a samba/nfs file share that other computers on your network can mount or sync the files to cloud storage.

My next post will walk you through syncing the files to azure storage and deleting files over a certain age. The third post will either create from scratch or modify an existing ui to browse  and search the images and video uploaded to azure. We will create a full text index for our media with the help of the Azure Cognitive API.