Turn a Raspberry Pi into a CCTV Security System
A few weeks ago I received the new version of the Nwazet Camera Box Bundle, re-designed to fit the B+ Raspberry Pi.
It reminded me that I had promised my dad that I would fit a Pi camera system into his porch so he could keep an eye on his beloved motor home when he was in the garden. I'd not got round to doing this as I hadn't quite found a camera viewing solution that would be easy enough for him to use (and for me to figure out!).
Last week whilst browsing the Raspberry Pi forum I came across a camera viewing application for the Raspberry Pi called MotionPie. It almost turns your Raspberry Pi Camera Module into an IP camera, and is really (really!) easy to set up and use - perfect for old papa Average!
With my new CCTV-style case, and this seemingly simple yet brilliant camera application - a project was born!
Read on to see how simple it is to make a CCTV system out of your Raspberry Pi...
The Raspberry Pi CCTV Solution |
The Nwazet camera case is perfect for our CCTV Pi solution as it has an adjustable mounting bracket, a fish-eye lens, and a nice stealty black look. It comes with all the parts you need, and even the fixings for mounting it to a wall.
Assembly
First on the list is to assemble the case. This is easy with the help of the very detailed guide on their blog. You first need to remove all the protective film on the individual panels, then then put it all together. No point in me covering that part - their instructions are very clear and can be found here: http://nwazet.com/camera-box-bplus/assembly
Here's the parts:
The camera box parts with protective film... |
...and with the film removed. |
Here's my assembled case, ready to catch bad guys and burglars:
Assembled and ready for action |
Installation
Installing the camera is simply a case of finding the right spot, drilling a couple of holes and screwing the mount to the wall. Obviously you need to consider things like glare, lighting, moisture, power source and all of the other 'common sense' factors. This case isn't waterproof, so it needs to be installed indoors.
Note: You may want to skip to the Camera Software section below to set up MotionPie first so you can test where you want the camera before drilling any holes.
First mark where your camera will be mounted. Remove the mount panel and use it as a guide to mark your drill holes:
Papa Average marks the mount position |
Now grab your drill and screws/rawl plugs. The case comes with these fixings, but I left those at home so it was off to Papa Average's workshop to grab some spares. I'm pretty sure this was his favourite part - any excuse to use his tools and supplies:
I knew we would end up in my dad's workshop at some point |
Use the appropriate drill bit and drill the two holes for the mount where you marked earlier:
Drill the holes where you marked the mount |
Push in the Rawl plugs ready for the screws, to ensure you get a solid mount:
If you don't use Rawl plugs, it wont stay on the wall for long |
Screw the mount in to the holes. Make sure you get the mount the right way round:
Fit the mount to the wall |
The case should now slide on to the mount, using the small screw at the end to secure it:
The case bracket slides on to the mount |
There we have it, the camera box fitted and ready to plug in:
Ready for crime fighting |
Camera Software
This is the part that had me puzzled for a while. There's a lot of different ways to get your camera streaming to a screen/computer, but I hadn't had much time to look at them. The few that I did try didn't quite offer the 'simple' factor that is so very important when trying to get my father to adopt new technology!
MotionPie
Then I came across MotionPie. This clever application comes as an image that you simply write to an SD card and put straight into your Pi - no code, no messing around. It feels a bit like cheating, but it does work very well and will keep papa Average happy as it's so easy to use.
Download the Image
To install MotionPie you need a blank SD card and the MotionPie image available here (hit the big green download button). You can use a 4Gb SD card but you may want something bigger if you want to use the recording features of MotionPie.
Think of an image as an operating system, like Windows. This image is a dedicated image for MotionPie, which makes it very easy to install.
Once the file has downloaded, unzip the files to a folder and move to the next step.
Write the Image to an SD Card
Pop your SD card into your PC (using an SD card adapter if needed) and open up your favourite image writing software - I use Win32DiskImager for Windows.
Open up Win32DiskImager - you should see the drive letter for your SD card in the top right 'device' section. Make sure this is right before continuing.
Win32DiskImager is an essential tool for Pi people |
Next we need to tell the application which image file we want to 'burn' to the SD card. Click the little folder icon and navigate to the folder you extracted the MotionPie files to. Click the MotionPie.img file and then click 'Open':
Your image file should be a .img file type |
The file path should now be showing in the 'Image File' section.
Double check the image and drive letter are correct |
Now click on 'Write' to burn the image on to the SD card. A warning will show, telling you you can corrupt the device. Don't worry about that, it's a standard message. Click 'Yes' to proceed:
(Note: The 'read' option is for doing it the other way - reading the SD card and making a file - great for backing up)
This warning always shows - don't panic! |
A progress bar will give you an indication of progress - this image isn't very large so should only take a few minutes:
MotionPie takes just a few minutes to write to an SD card |
Once complete, a message will pop up. Click 'OK',
Don't remove your SD card just yet! |
Now we're ready to remove the SD. Don't forget to 'eject' the device safely using the icon in your taskbar, there's a chance you could corrupt the SD card otherwise:
All storage should be removed this way |
First Run
Your SD card is ready now, so push it in to your Pi and continue.
Setup
We need to connect MotionPie to a wired internet connection for the initial start up (ethernet), as we need to be able to retrieve an IP address. We can't do any of this via a HDMI screen as MotionPie doesn't have a video output (you'll just see a colourful screen).
Once you've connected everything, push your micro-USB power supply in to the Pi and turn the plug on. We need to give it at least a few minutes to let the initial setup run, so go and grab a coffee.
IP Address
You now need to find the IP address of your MotionPie to be able to log in to it. You could log in to your router to find the IP addresses of your connected devices, but I always use the Android 'Fing' app on Android as it's quick and easy.
You also need the Pi's serial number which will be visible when you check for the IP address.
I opened Fing, did a scan on my network, and found my MotionPie along with the serial number (the serial number is the part after 'MP-'):
Fing is great for grabbing IP addresses |
Log In
This part is easy. Using a laptop/tablet/phone connected to the same network as your MotionPie, simply type in the IP address and hit enter (the same way you would type in a web address such as AverageManVsRaspberryPi.com). In the example above, I'm using 192.168.1.9.
The slick MotionPie interface should load up. You will at some point be asked for a log in, which is simply 'admin' and no password. For remote access such as SSH, the user name is 'root' and the password is the Pi's serial number (which you can see above when we get the IP address).
I used SSH to set up my Edimax WiFi adapter so that this camera didn't need to rely on a wired ethernet connection.
Interface
Here's what MotionPie looks like on my Android phone - it was a bit of a dark day.
The MotionPie mobile web interface |
The icon top left takes you to the setting menu, where you can adjust all manner of things such as framerate, resolution, brightness, contrast, rotation, storage locations and loads more. I need to have a play with these settings over the next week or so.
You then have icons on the right which take you to full screen mode, camera and video capture and more options. To use the same interface on a PC or tablet, it's the same process. Simply enter the IP address and away you go.
There currently isn't a shutdown command on the interface but I have been told that it may be coming soon. You can run more than one Pi camera on MotionPie as well, almost creating a full security interface:
3 Pis running on MotionPie (image from MotionPie site) |
Summary
I'm really happy with the outcome of this project, and more importantly, so is Papa Average!
The Nwazet case and mount is solid, looks the part and works very well as a CCTV housing. The fish-eye lens isn't the greatest quality, looking a bit fuzzy at the edges, so we just removed this part. I'm going to look into drilling some holes in the top panel and wiring some 'deterrent' LEDs to make it a bit more visible.
The MotionPie application is very easy to set up compared to fiddling with code and 'Motion' yourself, although playback can be choppy if you set the resolution too high. It's a bit of a lazy man's solution, but I'd rather concentrate my coding on some of the other projects I have on the go.
I had this case and MotionPie on display at the recent Cambridge Raspberry Pi Jam, which provided hours of entertainment for children running in front of the lens! (See my write up of that event here)
Who can resist a bit of live selfie acrion? |
Continue reading here: Average Bot Devblog 9 - Results & Learnings
Was this article helpful?
Readers' Questions
-
jennifer4 months ago
- Reply
-
Asphodel11 months ago
- Reply