Using Raspberry Pi for CCTV with Zoneminder

· 540 words · 3 minute read

Note: zoneminder might be overkill for many people. If you have less than 4 cameras, also read my article about doing CCTV with the motion package.

One of the first uses, for the Raspberry Pi, I thought of was qick-and-dirty CCTV. This could be useful for scenarios, like remote construction sites, senior citizens, holiday homes, etc.

The only gear needed is a Raspberry Pi, a USB webcam and internet access through a router. The webcam could also be a network camera or a network digitizer. That way you have more flexibility with your location. The router could be substituted for a 3G data stick. If you have a spare TV, you could also use it for viewing those cameras.

The steps for setup are:

  1. Connect router, USB-camera and power to your Raspberry.
  2. Flash my favourite SD-card image on a card. Steps are describe on the website. Be sure to enable SSH-access. Or connect a TV via HDMI.
  3. Install the zoneminder package and dependencies with apt-get install zoneminder
  4. Make sure zoneminder and its related services are working with service zoneminder restart
  5. Now you should be able to access the zoneminder interface via http://raspberry-pi/zm
  6. If you got that far, you could already add IP network cameras to your interface. There are some really cheap Chinese models to be found on ebay for about 35 EUR. Just make sure they provide you the image over a fixed path like 10.0.0.22/image.jpg. If they only come with an ActiveX web interface, they are pretty much worthless.
  7. To include a USB camera, make sure it is supported by the Linux kernel. You can check connected devices with lsusb and dmesg after plugging it in. If everything is working, your camera should show up with zoneminder as local interface.
  8. If you want to view your camera on your phone, there are a number of apps available for Android and iPhone/iPad. EyeZM worked particularly well and also allows you to view recorded events. The only thing you need is an external domain with some kind of dynamic DNS and port forwarding on your router. You could use DD-WRT to do both jobs. Or install a cron-job on the Raspberry to update its external IP regularly. A flexible and open DNS-service is ClouDNS. Try to avoid DynDNS. They are way to expensive for what they offer and use questionable tactics to buy out competitors.

These are the rough steps to turn your Raspberry Pi into a surveillance machine. Since the machine is not particularly high powered, don’t connect more than 2 or 3 cameras at a time. Motion detection and recording will also put some pressure on it. There are some tricks to install optimized JPEG-libaries. This is something you can try.

If you already have analogue cameras, I recommend the Aviosys IP9100. It costs around 100 EUR and can digitze up to 4 analogue cameras. To pull separate streams, install this alternative firmware. It allows you to access each channel through /usr/yoics[0-3].jpg

I hope this article gave you some inspirations and ideas of what can be done. Be warned that zoneminder is not the easiest beast to configure and install. I will try to come up with a setup script or a pre-built SD-card image at some point.