Sunday , 30 April 2017

Turn a Raspberry Pi into a CCTV Security System

The Nwazet camera case is perfect for 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.

The Nwazet camera case
The Nwazet camera case

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:

Here’s the parts:

The camera box parts
The camera box parts

Assembled case, ready to catch video and images:

Assembled and ready for action
Assembled and ready for action

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!

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
Win32DiskImager is an essential tool for Pi

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
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
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!
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
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!
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
All storage should be removed this way


Your SD card is ready now, so push it in to your Pi and continue.

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
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). In the example above, I’m using
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 WiFi adapter so that this camera didn’t need to rely on a wired ethernet connection.

Here’s what MotionPie looks like on my Android phone – it was a bit of a dark day.

The MotionPie mobile web interface
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)
3 Pis running on MotionPie (image from MotionPie site)


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.



Check Also

Windows 10 is coming to the Raspberry Pi 2 for free

Today the Raspberry Pi Foundation announced the retail availability of their new board, the Raspberry …