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.

Recommended

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 removing the video? Subscribe to premium for no-ads.

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. Avatar for Bruce
    Bruce on

    I have a Pi3 with the Pi NoIR Camera V2. When I load everything up and fire it on – I get a gray image with the nasty message “Unable to open video device”. Any clues?

    1. Avatar for Jeremy Schneider
      Jeremy Schneider on

      If this happened to me, here are the things I would try, in order (I understand that you may not have all the hardware to do some of these things):

      1. Check the physical connections. Remove the cable and put it back in. Make sure that the cable is connected correctly. Look at pictures on the web of how others connected it.

      2. Try other programs that access the camera. If I recall correctly, there is a simple command that will retrieve a single still image from the camera.

      3. Reformat and re-flash the MicroSD storage unit with a fresh copy of the latest version of Raspbian and try to grab an image from the camera.

      4. Try a different camera in the RPi.

      4. Try the camera in a different RPi.

  2. Avatar for Kevin H.
    Kevin H. on

    Thanks for sharing this setup, works as you have stated except for one issue I had. Windows 10 would not show it under Network, and my router did not list it as a device. I had to boot motionPie with a monitor attached to get the name of the device and ip address. Once that was done it worked like a charm. Thanks so much.

  3. Avatar for Wes
    Wes on

    Thanks for the tutorial!

    Is there a way to turn the camera off when it is not in use?
    It seems to stay on even though I have set up the Working Schedule.

  4. Avatar for Rick
    Rick on

    I getting this error whenever I attempt to connect via my browser:

    {“error”: “internal server error”}

    I’ve tried both with and without specifying a port.

    I tried connecting via IP and name as shown using my Netgear network map. I then tired making a SSH connection via Putty and that failed.

    1. Avatar for Rick
      Rick on

      Well, when I changed powering the raspi from two GPIO pins to the micro USB all started working. I’d been using the GPIO pins (RasPi model B, old 512 MB jobbie) for some time to ease connections with a 5 volt PS) but never with the camera. I read someplace the camera uses some GPIO pins and this must cause some conflict so back to microUSB.

      Rick

  5. Avatar for Daniel
    Daniel on

    Pardon my ignorance, is it correct to assume each camera needs to have its own Pi board?

  6. Avatar for Thameem Abbas
    Thameem Abbas on

    Is it possible to connect two USB cams and create each of them as an IP cam with different IPs over a single ethernet line ?

  7. Avatar for Tommy
    Tommy on

    Hey – GREAT tutorial. Thanks for putting this together. I am having an issue regarding Networking. I have a Raspberry Pi 3b using the latest build of MotionPie (from 20160605) and I cannot get this to work over wi-fi.

    Plugged directly into the router, I can access the admin page and even followed directions to setup the wireless network. I then shut down the Pi and removed the Ethernet cable. I cannot access the camera from the IP in a browser, like I could when it was plugged in to the Ethernet Cable.

    Any clue what I’m doing wrong? Thanks for your help.

  8. Avatar for Rajit Kuthiala
    Rajit Kuthiala on

    Can I access it anywhere on internet as I needed to surveillance my villa in another place so I’m thinking to buy a pi zero and put a USB camera along it to surveillance my place.so my query was to can I look through internet to my camera

  9. Avatar for JF
    JF on

    Hi again, thank you very much for this awesome tool. I have been having some flickering issues since the last update (20160410) which were not present before. I have 2 USB cameras hooked up and have tried experimenting with different resolutions, motion optimization etc but the flickering does not go away. It is intermittent but I do have some captures of when it happens that I can send over email/post to a fileshare. Any known issues around this or recommendations?

  10. Avatar for Tom
    Tom on

    When I boot with motionpi (and only motionpi is on the card) on a PI3, it loads and stops after here:
    # Defaultr gateway is 192.xxx.x.x (I put the x’s there)
    # DNS server address is 75.75.75.75

    at this point:
    Welcome to meye-2b5ac9b0!
    meye-2b5ac9b0 login:
    Password:

    Any idea what is going on ? Thanks

    1. Avatar for tom
      tom on

      I have read the wiki, watched every tutorial, asked many folks for the solution and their answers are either technically over my head, or I’m an idiot and just don’t understand what they’re trying to say. Can someone please explain to me in terms an idiot would understand, the solution to the login and password question I posted above ? Thanks.

  11. Avatar for Adam
    Adam on

    Hi. I’m trying to set up this project but the Pi will not boot once the SD card is installed. Can you give me any ideas what I might be doing wrong?

  12. Avatar for chris chambers
    chris chambers on

    reading through al the posts, I got a bit confused. so I would like to confirm a few this.

    the motion PI software, = will it record anything that changes within it view of vision, and save it to a mounted storage location. in a format that is easy viewable.

    can you set up the software so that it it onlys saves a limited amouth of recorded time.

    and lastly, can you use any type of Cam feed ?

  13. Avatar for Shiv
    Shiv on

    Hi,

    First thanks a ton for this project. Its really very detailed blog guiding all the steps and also the features are just fantastic. I had this up and running in no time.

    I would need help in couple of settings which am facing issue with

    a. I am using a r-pi and using a wifi dongle along with it. I entered the SSID and PWD in the web and saved/rebooted but when i remove the ethernet the motioneye is not getting detected on browser ( am sure there is no change in ip after the reboot ). Is there a way to test or check if the wifi is connected or not like we do in rasbian using UI ? Or any other backend way of setting the wifi ?

    a2. Is there a way we can start this off with directly connecting to WIfi than with ethernet ? I want to be using this with 4g dongle in remote locations than using ethernet. Any pointers on how to do it ?

    b. Can someone guide me on how to set it up to be running over on internet and how to define the access.

    Thanks a lot for the answers.

    -Shiv

  14. Avatar for Gururaj
    Gururaj on

    hello sir i am facing trouble with login? Can anyone help me to solve this problem….

  15. Avatar for FerC
    FerC on

    Hi, I have a raspberry Pi 2 with version 20160320, I use the image “motioneyeos-raspberrypi2-20160320.img.gz”
    I have 2 usb webcam and camera raspberry. 3 cameras work well until active the option “Advanced Settings”.
    As active this option the camera raspberry “unable to open video device”
    I can not fix it, until I return to record the image in the SD.
    Regards!

  16. Avatar for Seth
    Seth on

    Is it possible for MotionPi, say with a 32GB micro SD card, to have the RPI constantly recording and looping video back in itself, kind of like a dash cam?

  17. Avatar for Max
    Max on

    Hello,

    Thanks for the tutorial, I love the way you build the tutorials (youtube videos especially). My question is if it is possible to have motionpie installed inside a raspbian? This was I can you the raspberry pi for other project at the same time.

    Thanks

  18. Avatar for Steve
    Steve on

    Hello,
    The tutorial was great! I only had one issue, the time and date stamp overlaid on the video is incorrect. It shows a date starting at the year 2000 and the wrong time. In the Expert Settings it is set to the default which is HTTP and the host is google.com

    If anybody has some advice it would be greatly appreciated!

  19. Avatar for Erik Larsson
    Erik Larsson on

    Hi! your tutorial is a 10 out of 10. I have some problems tho… i cant reach the files through the local network. i looked at the network page on my pc but i didnt see the pi in it. I have a Raspberry Pi 3.

  20. Avatar for Joel
    Joel on

    Hi, I was curious to know if you were planning on having a RPi3 version out at any point in the near future. I tried to run this on an RPi3 and unfortunately, it looks like the current version is not compatible.

    1. Avatar for Gus
      Gus on
      Editor

      Hi Joel,

      I have updated the tutorial to point to the new version of MotionPie OS (Now called motioneyeos), You can find it here (Scroll down and find the Raspberry Pi image, it’s roughly 50mb) > https://github.com/ccrisan/motioneyeos/releases

    2. Avatar for Joel Fernandez
      Joel Fernandez on

      Thanks so much for getting back to me so soon Gus! and thank you also for this awesome solution! Much appreciated.

Leave a Reply

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