Raspberry Pi can be connected to a camera to capture picture and video in order to use it as a CCTV motion detection device, which I have described in my previous post. To further enhance the motion detection feature, we can build a Raspberry Pi Webcam Video Server for browsing from web. It is more effective to monitor environment from outside. In the following, I will describe the installation steps of a application call motionPie to build a web server.
1. Download & Format the SD Card
- Download the Motion Pie SD Card Image from the Motion Pie GitHub repository or my link <<HERE>>.
- You will need a formatting tool. Visit the SD Association’s website and download SD Formatter 4.0 for either Windows or Mac.
- Follow the instructions to install the formatting software.
- Insert your SD card into the computer or laptop’s SD card reader and check the drive letter allocated to it, e.g. I:/
- In SD Formatter, select the drive letter for your SD card (eg. I:/) and format
2. Install the Motion Pie Image onto the SD Card
- Download the Win32DiskImager.
- Now unzip the MotionPie ISO file so you can install it onto the Pi safely.
- Select the MotionPie ISO file and the drive letter your SD card is assigned (Eg. I:/)
- Confirm you have the correct details and click on Write.
- Once done you can safely remove your SD card from the computer.
Booting/Setting up MotionPie
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 like 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 setup correctly.
Setting up the Raspberry Pi Security Camera
Once the Pi has booted you will need to do the following:
- First we will need the IP or host name so we’re able to connect to the Pi.
- If you’re using Windows simply go to network on the right hand side in the File Explorer.
- You should see a computer names something like MP-xxxxxxx
- Go to your browser and add this to your browser bar eg.
- You should now have the Motion Pie interface up.
- 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 this is done. Please refer to your manufactures manual.
- To login as the admin go to key symbol in the upper left corner. The username is admin and the password is blank, this can be changed later.
- 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 on more to find out what the settings do in Motion Pie.
How to setup 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 setup using the Raspberry Pi Webcam server tutorial.
- First click on the 3 lines with dots on them in the upper left hand corner.
- Now up in the upper left hand corner and click on the dropdown box and select add camera.
- In here you have four settings to set up.
- Device: This is allows you to select where the camera is located(network/local) and type. (Eg. motionEye, MJEPG camera)
- URL: This is the URL to the other network camera. Eg.
- Username: This is the username to the camera device. (If no username/password required leave the fields blank)
- Password: This is the password for the username chosen above.
- Camera: Select the camera you wish to add.
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 simply 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.5.78
- Internal port is 80.
Ensure you have also setup passwords on both the admin and the surveillance user to help avoid unwanted visitors.
Once setup 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 recommended changing it to avoid easy access for unwanted visitors)
Configuring the Settings in MotionPie
In here you are able to set the administrator username and password. This account will have access to all the settings you’re seeing at the moment.
Surveillance username and password can also be set in here this can be used to just access the camera interface.
To view all the settings available to set turn the show advanced settings to on.
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 a able to disconnect the Ethernet cord and remain connected to the network.
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 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 to not be treated as motion. (This will help prevent false positives)
- Automatic Brightness: This will enable software automatic 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 in order 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 amount 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.
Under this menu you can specify where you would like the files stored for the Raspberry Pi Security Camera. This can be a custom path on the Pi, the predetermined path or the network path.
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 (Todays date and current time).
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 exactly the same as mentioned above under video device.
- Streaming Quality: You can reduce the video streaming quality. This 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 MotionPie 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 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 on.
Here you can set the Raspberry Pi security camera to take still images whenever motion is triggered, during specific intervals or all the time.
In here you activate the Raspberry Pi security camera motion detection that is included in the software. You are able to make adjustments to the settings here so that you can get better motion detection.
In you here you can set the Pi to record movies whenever motion is detected
You’re able to set up email notifications, web hook notifications or even run a command whenever motion is detected. This will allow you to be notified whenever activity is detected on the cameras, perfect if they are monitoring areas with low traffic.
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.
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 motion pie provides allows you to have a strong functioning security hub for your home, office or wherever you’re setting this up.
In past, we often used “Motion” package (“sudo apt-get install motion”) for webserver, but this method doesn’t work on the Raspberry Pi 2.