Build a Raspberry Pi Security Camera Network

In this project, I am going to make a Raspberry Pi security camera simply using the standard Pi camera such as the one I used in the time-lapse tutorial.

Raspberry Pi Security Camera

This project is a cost-effective way of getting a security camera up and running that you can view over the network and also have it, so it is motion activated.

Remember the Raspberry Pi isn’t a powerhouse, so performance will degrade if you try to do too much by adding too many high definition cameras.

With that said, it’s still an excellent way of building your own affordable camera network. So let’s get to it.

Equipment

You will need the following equipment to complete this Raspberry Pi security camera project.

Raspberry Pi

Raspberry Pi camera or USB WebCam

Power Supply

Micro SD Card (8GB + Recommended)

Ethernet Cord (Recommended) or WiFi Dongle

Raspberry Pi Case (Optional)

Video

If you want to see how to set up the Raspberry Pi security camera visually, then check out the video I have prepared below.

As always, if you like what you see and want to stay up to date with all the latest and greatest projects, guides and much more, then please subscribe.

Adblock blocking the video? Support us by subscribing to our ad-free service.

Installing the Raspberry Pi Camera

Firstly before we do anything, we need to have a Raspberry Pi camera. In this tutorial, I use the regular IR camera, and it works fine however if it gets dark it can’t see at all. (Which is probably not much good for a security camera). You can find the regular camera here or the non-IR camera here.

If you’re after for more information check out my Raspberry Pi camera guide for everything you need to know.

Secondly, we will need to install the camera (If you haven’t got one you can get one here), to do this go to the ribbon slot (the one directly behind the Ethernet port) using two fingers gently pull up on both sides of the connector.

Clips & Ribbon Cabble

Now the connector is open insert the ribbon cable with the metal leads facing away from the Ethernet port. Make sure it is nicely lined up and then gently press back down on the connector. The cable should now be locked in place, and we can now move onto the software.

On a side note, if you want to install this into a more secure enclosure, there is some great equipment you can buy or even design to do this. To keep this tutorial pretty basic I am not going to go into a heavily customized camera enclosure.

Installing MotionEye OS

I settled on using MotionEye OS as it seems to be an all in one solution for what I require and it also didn’t involve as much fiddling around to get it to work.

Download & Format the SD Card

1. Download the MotionEye OS SD Card Image from the MotionEye OS GitHub repository.

2. You will need a formatting tool. Visit the SD Association’s website and download SD Formatter for either Windows or Mac.

3. Follow the instructions to install the formatting software.

4. Insert your SD card into the computer or laptop’s SD card reader and check the drive letter allocated to it, e.g. G:/

5. In SD Formatter, select the drive letter for your SD card (eg. G:/) and format

Install the MotionEye OS Image onto the SD Card

1. Download the Win32DiskImager.

2. Now unzip the MotionEye OS img file so you can install it onto the Pi safely.

3. Select the MotionEye OS img file and the drive letter your SD card is assigned (Eg. G:/)

4. Confirm you have the correct details and click on Write.

5. Once done you can safely remove your SD card from the computer.

win32diskimager MotionEyeOS

Booting/Setting up MotionEye OS

Now we’re ready for boot up, so insert the SD Card, an Ethernet cord, and the power cord.

We will need to communicate to the Pi over the network rather than directly as I have done in most of the previous tutorials.

So now go ahead and boot the Pi up and then we can move onto getting it set up correctly.

Setting up the Raspberry Pi Security Camera

Once the Pi has booted you will need to do the following:
1. First, we will need the IP or hostname, so we’re able to connect to the Pi.

  • If you’re using Windows, then simply go to network on the right-hand side in the File Explorer.
  • You should see a computer names something like MP-E28D9CE5
  • Go to your browser and add this to your browser bar e.g. http://MP-E28D9CE5
  • You should now have the MotionEye OS interface up.

2. Alternatively, you can find out the IP of the Pi by going to your router.

Since all routers are different, I will not go into how to do this. Please refer to your manufacturer’s manual.

3. To log in as the admin go to the key symbol in the upper-left corner.

The username is admin and the password is blank (Don’t enter any password), this can be changed later.

4. You can access all the setting for the camera stream here. If you’re interested in altering these settings, keep reading as I explain them as much as possible below.

Now we should have a working security hub that we can configure!

Require the security camera to be wireless? No problem! Require to alert you with an email? No problem! Read more to find out what the settings do in MotionEye OS.

How to set up multiple network Raspberry Pi security cameras

If you want to run more than one Pi cameras, it is pretty easy to set this up, so you have all the streams under in one window.

You can even add a stream that has been set up using the Raspberry Pi Webcam server tutorial.

1. First, click on the three lines with dots on them in the upper left-hand corner.

2. Now up in the upper-left hand corner and click on the drop-down box and select add camera.

3. In here you have four settings to set up.

  • Device: This allows you to select where the camera is located(network/local) and type. (Eg. MotionEye, MJPEG camera)
  • URL: This is the URL to the other network camera. Eg. http://othercamera:8080
  • Username: This is the username of the camera device. (If no username/password is required, then leave the fields blank)
  • Password: This is the password for the username chosen above.
  • Camera: Select the camera you wish to add.

In the example below camera1 (Pi Camera) and camera2 (USB WebCam) are connected to the Pi running MotionEye OS. While camera3 is coming from a different Pi that was set up using the webcam server tutorial.

This method is a great way to set up a strong Raspberry Pi security camera network.

Raspberry Pi Multiple Cameras

Connecting to the surveillance outside your network

Now that you have your Raspberry Pi security cameras setup it might be worth considering allowing access to the central Pi so you can monitor your cameras elsewhere.

To do this just head over to my guide on how to setup port forwarding and also how to setup dynamic DNS, you can find the guide at Raspberry Pi Dynamic DNS & Port Forwarding.

A few important bits of information you will need for the setting up the port forwarding.

  • The IP of your Raspberry Pi for example mine is 192.168.1.108
  • Internal port is 80.

Ensure you also have set up passwords on both the admin and the surveillance user to help avoid unwanted visitors.

Once set up, you should now be able to connect using your external IP address such as XX.XXX.XXX.XXX:80 (80 should be changed to something else, I would recommend changing it to avoid easy access for unwanted visitors)

Configuring the Settings in MotionEye OS

Raspberry Pi MotionEyeOS Interface

General Settings

In here you can set the administrator username and password. This account will have access to all the settings you see at the moment.

Surveillance username and password can also be set in here this can be used to just to access the camera interface.

To view all the settings available to set turn the show advanced settings to on.

Wireless Network

Turn this on if you plan on connecting to the network via a wireless dongle. There are two things you will need to fill in here.

  • Network Name: Enter the network name/SSID you wish to connect to in here.
  • Network Key: Enter the network password/network key in here for the network you’re connecting to.

Once done you should be able to disconnect the Ethernet cord and remain connected to the network.

Video Device

Under this menu, you’re able to set certain settings regarding the Raspberry Pi camera device.

  • Camera Name: Set this to whatever you would like the camera to be named. For example, the name kitchen would work well for a camera in a kitchen.
  • Camera Device: You’re unable to edit this one, but this is the device name of the camera.
  • Light Switch Detection: Enable this if you want sudden changes such as a light being switched on not to be treated as a motion. (This will help prevent false positives)
  • Automatic Brightness: This will enable automatic software brightness, this means the camera software will make adjustments for the brightness. You don’t need to activate this if your camera already handles this. In here you change the brightness, contrast, and saturation of the video of the camera.
  • Video Resolution: Here you can set the video resolution of the camera. The higher the resolution, the more room it will take up and the more bandwidth it will need to use to stream the footage. I set mine to 1280×800, and that seems to work perfectly fine.
  • Video Rotation: You can rotate your video from the Raspberry Pi security if you’re finding that it is looking the wrong way.
  • Frame Rate: This sets the number of frames that will be sent be every second. The higher this is, the smoother the video, but again this will increase the storage used and bandwidth.

File Storage

Under this menu, you can specify where you would like the files stored for the Raspberry Pi security camera.

This location can be a custom path on the Pi, the predetermined path or the network path.

Text Overlay

In here you can set the text overlay on the output of the camera.

By default, the left text reads the camera name and the right read the time stamp (Today’s date and current time).

Video Streaming

This menu you’re able to set the video streaming options, this is the video you see in the browser.

  • Streaming Frame Rate: This is the same as mentioned above under video device.
  • Streaming Quality: You can reduce the video streaming quality. This setting is good to reduce if you need to access the camera on a low bandwidth device often.
  • Streaming Image Resizing: Enable this if you want MotionEye OS to resize the images before being sent to a browser. (Not recommended on a Pi)
  • Streaming Port: This is the port that the device will listen to for connections looking to view the stream. Eg. http://motionpie:8081
  • Motion Optimization: This will reduce the frame rate whenever no motion is detected. This setting will save you bandwidth.

You can also see three URLs that can be used to access different footage.

These URLs are very important if you have multiple cameras per Pi as each camera will have a unique port that you listen to the stream.

Still Images

Here you can set the Raspberry Pi security camera to take still images whenever motion is triggered, during specific intervals or all the time.

Motion Detection

In here you can activate the Raspberry Pi security camera motion detection that is included in the software.

You can make adjustments to the settings here so that you can get better motion detection.

Motion Movies

In here you can set the Pi to record movies whenever motion is detected.

Motion Notifications

You’re able to set up email notifications, webhook notifications or even run a command whenever motion is detected.

This option will allow you to be notified whenever activity is detected on the cameras, perfect if they are monitoring areas with low traffic.

Working Schedule

Here you can set the days, and the hours of operation you would like the system to be monitoring (If you leave this off then it is 24/7).

This option is perfect if you only need it running during specific hours.

Summary

The Raspberry Pi security camera system is a great way to have multiple cameras hooked up both locally and over a network.

All the extra setting MotionEye OS provides allows you to have a strong functioning security hub for your home, office or wherever you’re setting this up.

I hope this tutorial has helped you in creating a fantastic Raspberry Pi security camera network.

If you have had any problems, provide feedback or have a great setup you would like to share then feel free to drop a comment below.

If you’re after more great Raspberry Pi projects, then be sure to check out many other great tutorials.

184 Comments

  1. Kieran Cranley on

    Brilliant software! Just one request – could you extend the Frame Change Threshold to considerably more than 20 per cent? I use a telephoto lens with a circular field of view so don’t use all the rectangle’s pixels. This makes 20% not enough for motion detection.
    Thanks – keep up the good work.

  2. Deepak on

    I’m getting rainbow screen after deploying the ISO. I have a raspberry pi B+ model. Image which I downloaded is motionpie-raspberrypi2-20150719.img.gz.

    I have already tried options [boot_delay=1] but no luck.

    Can anyone help?

    1. Ping on

      You need to load the Pi image not the Pi B+

  3. Albin on

    I have some problems with the motion notifications. I have tried to make it send gmail notifications but when I check my gmail there is not any.
    Any suggestions?

  4. Dedy on

    Hi, I have little problem, that I want so save picture every 5 second. I set everything how it should be but it is resaving same file again and again. Why it is not doing new copy with another name like photo, photo(1), photo(2). Thanks, BTW your site is great, thanks fot projects that you are making!

  5. Richard Mellersh on

    Stymied at the first hurdle – github is down – so can’t get the motion pi image, please suggest a mirror

  6. Bjorn on

    How big SD card can I use?

    Im using 32GB, need more space for video etc.

    Will a 64GB work? Or even larger?

    Regards
    Bjorn

  7. Pete on

    Really having a hard time with this…. My OS for setting all of this up is Windows 7 X64

    Using build 20150719
    Am downloading motionpie-raspberrypi-20150719.img.gz
    Renaming it to motionpie-raspberrypi-20150719.img
    Format the SD card using the SD card tool
    Install the image using Win32DiskImager

    So the Pi i’m using is the Model B with 512MB. The early rev 2. I got 4 of them spare so might as well put them to good use.

    Power up and nothing happens. I’ve tried the image again and again, new downloads. With and without the .gz nothing.

    Any ideas at all?

    1. Graham Watson on

      Hi please help
      Ive followed your instructions and get as far as installing camera. When I add my URL for my IP camera it leaves the red exclmation mark in, as if its not recognized. It is a wansvew ( Foscam copy ) camera. If I use the URL in my browser it connects without issue.
      What do you think could be wrong?

    2. George on

      You need to unzip the file first. The extension *.gz is a Linux zipped file (gnu-zip). If you are using Windows then you can download 7-Zip which can unzip the *.gz file, once unzipped/uncompressed the file will have the *.img extension (image file). You can then write the *.img file to the SD card with Win32DiskImager. That should get you working.

  8. Yrbo on

    Hi,

    This is great, I’ve been trying RPI CAM Web for a while but this will better suit my needs.
    I have a few questions.
    After setting up the still images are not uploaded to a network share.
    Uploading the files with SCP is successful and it looks like motion is not detecting.

    With kind regards,

    Yrbo

  9. Sal on

    Just installed the most current build on a pi2

    I noticed that the file system on my image is set to read only. As a result I can not edit config.txt, even though i am logged in as root.

    Can anyone help me to make the file system read/writeable

  10. José on

    Hello,

    First I’d like to thank you for share this tutorial with us.
    Secondly, I have a doubt and I need your advice, please.

    I’m trying to build a ROV – Remoted Underwater Operated Vehicle – and I intend build a CCTV system on it. Well, searching a solution for this I bumped into this tutorial and I strongly start to think using a Raspberry Pi 2 to help me in this adventure.

    Just to clarify, the ROV CCTV system will help me in navegation and operation underwater and it’s extremely necessary that the Pi handles at least 4 cameras constantly recording videos keeping them at 30 FPS and sending it over ethernet through a 20m cable to the surface where there’ll be a camputer comunicating with Pi using this MotionPi to get the cameras visualization.

    As a said the enviroment requires a good frame rate, without any possible delay between what happens in real and what appears on monitor.
    Considering all mentioned, my questions is: Can I accomplish that with Raspberry Pi 2 and good IP or USB cameras?

    Best regards!

  11. Micah on

    I’ve tried a few other images and this is by far my favorite! Great write up and fantastic job on software. One question, is there a way to control the red light that turns on when the camera is powered up?

    1. Gus on Editor

      Hi Micah,

      You can disable the RED led on the PI camera by opening the following file:

      sudo nano /boot/config.txt

      Then adding the following line into it.

      disable_camera_led=1

    2. Ronald on

      When i use”sudo nano /boot/config.txt

      i get a message that sudo isn’t installed.
      How can i install sudo?

      Or how can i ssh ad root in motionpie?

    3. Jeremy Schneider on

      I had a similar question. Perhaps the author has made the system more robust by making the partition mounted on /boot be read-only, because although I was able to ssh in as root (or even just use the console, with a keyboard and monitor attached to my Raspberry Pi 3), I couldn’t edit the file because the filesystem had been mounted read-only. That’s a good thing, but it made editing the file a little trickier. In the version of the software that I have, and in my configuration, there is no password on root or admin at the moment. To get around the read-only /boot/config.txt , I remounted the /boot partition as read/write. Below is a record showing what I did. I found out the name of the device that is mounted on /boot. I then remounted that partition read/write (with the same mount point), used sed to edit the file (you can use nano or vi, or just copy my sed command), remounted it as read-only, and rebooted. The remount as read-only is not necessary, as it will revert to what /etc/fstab specifies on reboot.

      ```
      Script started on Tue Mar 29 23:32:22 2016
      hbash-3.2$ ssh 10.11.12.166 -l root
      Welcome to meye-467ecdf3!
      [root@meye-467ecdf3 ~]# mount | grep boot
      /dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
      [root@meye-467ecdf3 ~]# mount -o remount,rw /dev/mmcblk0p1 /boot
      [root@meye-467ecdf3 ~]# grep led /boot/config.txt
      disable_camera_led=0
      [root@meye-467ecdf3 ~]# sed -i "s/disable_camera_led=0/disable_camera_led=1/" /boot/config.txt
      [root@meye-467ecdf3 ~]# grep led /boot/config.txt
      disable_camera_led=1
      [root@meye-467ecdf3 ~]# mount -o remount,ro /dev/mmcblk0p1 /boot
      [root@meye-467ecdf3 ~]# exit
      logout
      Connection to 10.11.12.166 closed.
      bash-3.2$ exit
      exit

      Script done on Tue Mar 29 23:50:47 2016
      ```

  12. Uzair on

    This is an awesome project. thanks for sharing.
    How many cameras can Pi support. Just wondering if I can have one Pi running 3 or 4 USB cams? or even use a usb video input receiver and hook up regular security cams to it? can this setup handle such a configuration?

  13. Ryan on

    I want to create several “IP” cameras using this tutorial. With one of them being the “server”. But my main question is what did you use to secure the Raspberry Pi Camera?

  14. Ronvssr on

    Guy,
    Nice project.
    But would it also be possible to let move the cam.

  15. Mike on

    User admin but when I hit enter for password it fails. I tried to type blank also but still failed to continue I am using pi2

    1. mike on

      following above comments I used the last portion of the devices ID for the password which gave me a reply [root@mp-ab72f34c ~]#
      I need some suggestions on how to get the program to run properaly thanks

  16. Allen on

    First up mr PIMYLIFEUP. thank you so much for the awesome Raspberry pi cctv system. it is just off the rail, and have now introduced it to my friends and family in south Africa and Canada, who is going to set theirs up as well. they are truly amazed.
    I am running two pi’s, a B with a web cam, and a B+ with a pi cam module.
    Its so easy to ad the second pi on the first pi’s stream. IE view two pi feeds on once window. awesome.

    I am a total noob at the pi stuff so like things that i can just drop into place and they work.
    I have an idea/request if your looking for anything to do next.
    with Halloween coming up I was looking for a way to use the pi as a scare controller.
    I once came across a similar thing called the HAUNTBOX. It is a simple device where you can just set inputs and outputs and drop in mp3 sound files etc.
    any chance you could looking into, or put together something like this?
    https://www.youtube.com/watch?v=iEx8xT4j3B4

    anyway thanks again for your tutorials and every things els surely makes a noob like me feel like a master.
    regards

  17. Samet BALCI on

    is it possible to Add PTZ on this camera .

    Example!
    4 pins can be out and we can take output for our servo motors , on page we can click buttons and turn webcam around ,

    Or can we use ssh for get output for our servo motors ?

    And your Project are amazing 🙂 I didn’t know the pi are useful like this .

    Thank you for all .

  18. Alex on

    Awesome tutorial! Quick question. Is it easy to trigger some sort of noise/alarm off of the motion that motionpie detects? In an ideal world, I’d like it to occur simultaneously, so that images are stored, and those on the premises are alerted to any movement as well.

  19. Danny Martin on

    Hi Gus,
    Just a quick question. Been having recent issues with my setup. Every time I log on to MotionPie I can see all the camera views and then the views are replaced with the “no camera” picture. I have also noticed that some times the camera view comes back and then goes away. Any suggestions as to what might be causing this? I notice the same scenario whether I am using the site on IE or Firefox or even on my phone.
    Thanks,
    Danny

Leave a Reply

Your email address will not be published. Required fields are marked *