The Raspberry Pi Security Camera using MotionPie
As you may know, we love shiny new tech. When the pi came out, the first thing we did was experiment with Openelec by changing the pi into a media centre. Recently, we have seen some great developments with the pi camera and now it is possible to have a fully functional security camera with just a few simple addons.
With this in mind, a guide was born. We know there are quite a few guides that show you how to set up motion with the pi but very few that show how to use MotionPie. MotionPie is a security suite for your pi. It doesn't need any other OS running and can be installed with much less hassle than motion with Raspbian. It's was created by Calin Crisan so all credit goes to him on this and we hope he continues to develop this great bit of software.
Ok, let's begin.
How to set up your Raspberry Pi as a security camera.
Step 1 : Collect your Pi bits.
You will need the following.
- A raspberry pi (of course)
- An SD card
- Raspberry Pi Power supply
- USB WiFi dongle (Optional but better)
- Ethernet connection (for setup)
- Raspberry Pi Camera module (we used the PiNoir but the non PiNoir will be fine)
Step 2 : Install the MotionPie image.
The first thing you will need to do is install the MotionPie image to your SD card.
Visit https://github.com/ccrisan/motionPie/releases and download the latest release (the green button).
Next, you need to get this image onto the SD card. To do this with Windows, you can use a program called Win32 Disk Imager (you can download this at http://sourceforge.net/projects/win32diskimager/files/).
Insert your SD card into your computer and open Win32 Disk imager then click the browse button.
Select the MotionPie image you have just downloaded. Next, choose your SD card from the device dropdown and click 'write'.
Confirm the overwrite.
It will now write the MotionPie image to your SD card. Once complete, you can move into step 3 below.
Step 3 : Setting Running the MotionPie setup.
Before doing this, make sure you have grounded yourself to avoid electrostatic discharge and that your Pi is switched off!
Attach your camera to your Raspberry Pi (lift up the clip, slide the ribbon in then push the clips back down).
Insert your SD card.
Finally, connect your Raspberry Pi to your network via ethernet. Do NOT connect your Wireless dongle at this stage or you won't be able to complete the setup.
Step 4 : The initial setup.
Now, you are ready to power up the pi and load up MotionPie. Notice how we didn't connect a HDMI cable? This is because motion pie doesn't need one, the video is streamed via your local network.
You need to connect to your Pi directly via the IP. Locate your pi's IP and type this into a browser's address bar. If you do not know your pi's IP, you will be able to get this from your router. In our case, this was 192.168.1.12 ( the router was 192.168.1.1).
You should now see the MotionPie home screen. Say hello to Chip (our Squirrel Hosting mascot).
Step 5 : Secure your feed.
Next, add some protection to the feed. To add a password to your MotionPie, enter the desired username and password in the provided boxes.
Then click the 'Apply' button at the top.
Step 6 : Set up Wireless
Now that you have your pi streaming over ethernet, you need to get the WiFi working. If you intend to stream via ethernet, you can skip this step. Click the 'off' link next to 'Show Advanced Settings' to switch on the advanced options.
Next, scroll down to the Wireless Network section and enter your WiFi name and password.
Then click the 'Apply' button again.
It's worth noting here that MotionPie doesn't currently support WEP (WPA or WPA2 is supported). We also had issues with our test system as the WiFi has spaces in the name which MotionPie didn't seem to like. Removing the spaces fixed this.
Now, click the 'Shutdown' button.
Once the Pi has shut down, you can disconnect your ethernet cable and add your USB Wifi dongle.
Step 7 : Add Motion picture recording.
In our tests, the motion picture recording worked better than the video recording and is a great way of getting a high res snapshot. Load up your Pi admin (remember your IP will have changed if you are on Wifi) and scroll down to the 'Still Images' section and click the button to switch it on.
You can play about with the quality of the images and how long they are kept for.
Step 8 : Add video motion recording.
Video motion recording worked well for us and can be activated the same way as still images. Click the button next to 'Motion Movies' and alter the settings accordingly.
Step 9 : Change resolution.
Whilst the pi is great, it can struggle with high frame rates and high resolutions. Under the Video Device tab, you can tweak these settings to best suit what you require. It's best to experiment with these until you find a setting you are happy with.
You can also rotate the camera which is a handy little feature. Again, once you are happy with the settings, click 'apply'.
Step 10 : Test your pi camera!
It's now time to have fun! Test your camera and see which settings work best. Some Pi users have even found that you can fit your pi inside a dummy CCTV camera. As you can pick these up on ebay for around £9, it gives you a case for your pi outside.
As mentioned above, Motion Pie doesn't support WEP (WPA or WPA2 is supported). We also had issues when images were stored on our USB device hooked up to our router (the camera would stop streaming/switch off after motion had been recorded, possibly due to the files being uploaded).
Finally, on our Model B board, video recording over 320X240 which was stored on the network device was a bit patchy (often we would get 0MB sized videos). Switching to storing these on the SD card or attached USB worked fine.
If you want to SSH into your MotionPi the password will be the cameras last 8 digits. E.g. our camera serial number was called mp-273f911e so the SSH password would be 273f911e.
More details regarding MotionPie can be found at https://github.com/ccrisan/motionPie
Well there you have it, a security IP camera for a fraction of the cost and much more fun. If you have found this guide helpful, please consider sharing it via the social media links at the top of our site and help spread the Pi Fun.
Leave a comment
Has this guide helped you? Have an idea for a guide or need help? Let us know below.