Wednesday, December 2, 2015

71. A Raspberry Pi Security Camera System

78,000 page views!!
I came across motionPie [this has now become motionEYE OS] some time ago and bookmarked it for later reference.  I only remembered it recently and looked into it in detail.  I discovered a fantastic system which is what I've been looking for for ages.

I've done live video via SSH HERE which was interesting, and even did control of LEDs via wireless network HERE but I hadn't realised that access to web pages on the internet is not possible unless you open a port on your router.  This is called Port Forwarding, and I've always been afraid to get involved in this by meddling with my router's settings in case I messed the whole thing up.

Anyway, this time I bit the bullet and had a go, and it worked!!  What I now have is an extremely cheap security camera system - with 2 cameras - and I can broadcast the live video images to the internet!

Camera 1 is the RasPi Camera at 1600 x 1200 pixels.  Camera 2 is the Logitech USB camera at 640 x 480 pixels.

The instructions for installing motionPie are very clearly given HERE by Gus of PI My LifeUP.  He also gives instructions for setting your router up for Port Forwarding HERE.  [The download page for motionEYE OS can be found HERE]. However, while the instructions give all the essential information, his router is not the same as my BT Infinity Hub 3.0 router.  So I went to my Home Hub web page and the information there is also useful, although after setting it up, you don't know whether your port is open or not.

However, I then found a useful site HERE which will confirm that your port is open and is not being blocked by the firewall.  There are of course other good sites with Port Forwarding testers.
Another program useful for showing you what devices are on your network is Zenmap available from HERE. Run it with a target of 192.168.1.0/24 and a command of nmap -sn 192.168.1.0/24.  This will list all the addresses of connected devices (hosts).

motionEye requires a dedicated SD card image on the Pi, because it is a stand-alone operating system (OS), but this is not a problem.  Once set up, you don't even need a monitor attached to the Pi, your motionEye console gives you access to everything you need, including downloading images to your PC and deleting images from the Pi.

The two cameras I am using are the RasPi Camera board, connected to the Pi through the CSI - camera serial interface - in the usual way, and a cheap USB camera I used to use for Skyping from my PC.  PI My LifeUP suggests that you can have even more USB cameras.  I will have to test that.

Here is an image of the control console [the motionEye console is almost identical, with some improvements]:
The available control options are too numerous to capture in one picture, but the image shows the main sections which open up and give almost total control of your video, stills, time lapse or motion activated images from all your cameras.

There's only one problem that I've noticed after running this for a couple of days  - my router port has for some reason closed a couple of times (it changed its IP address once too - maybe is this what is meant by Dynamic DNS - Dynamic Domain Name System?).  When this happens, you no longer have the ability to re-boot the Pi through the motionEye console.  If the Pi were to be placed somewhere remote, you would have to go to it and de-power and re-power it to get the system running again.  This is just something to bear in mind.

I have added a couple of time-lapse sequences (conveniently produced by motionPie/motionEye) below:

Camera 1:
Camera 2:
Here's a photo of the Pi with the RasPi Camera looking through my 8X zoom Telephoto lens.  You can see the cable running up to the USB camera which is looking through the window higher up.


Have a close look at this picture and see if you notice that pesky Jay bird nosing about.

Here he is pinching the tits' lunch:
Nice bird - a type of crow, and related to the magpie - apparently not that common in this part of the world - except my garden!  They are said to be "shy woodland birds" - this one's anything but shy.  I must report him to the RSPB!

motionEye is a really super piece of software.