Wednesday, 16 March 2011

Build a Cheap/easy Linux based Motion Detection CCTV system



This is a guide for those that want to build a cheap CCTV server for your home or business.

It uses a analogue camera to do two things:
  • Motion capture surveillance footage only when needed
  • email pictures of captured footage to you inbox

It requires some computer skills, but you probably will be smarter afterwards.

Hardware Required:
  • Asus EEE PC 701 Netbook $260
  • Easycap DC60 USB Video Capture Adapter $8.90
  • Video Camera $0 free

I picked the netbook up online from www.catchoftheday.com.au and figured it would be useful for some small project. It sat around doing nothing for a while until I was given a camera for free. I thought the two would be perfect for a CCTV project. The camera had a composite video output so the first task was finding a cheap video to usb adaptor. I picked one of these up from www.dealextreme.com after checking that there were Linux drivers available.

Software:
  • Ubuntu 10.04 LTS netbook remix
  • driver for the usb adaptor
  • motion
  • mutt
  • msmtp

The netbook came installed with Xandros. I replaced that with Eeebuntu 3.0 soon after I got it but that distro is getting a bit old. For this project I wanted something that was still being maintained and would suit a netbook. I settled on the netbook remix of Ubuntu 10.04.

The drivers for the USB adaptor were available from sourceforge.net/projects/easycapdc60. The documentation was great and it came with test scripts.

Motion was available in the repos so I picked that. I did have a look at Zoneminder but I wanted to keep the number of running processes to a minimum and Zoneminder was a bit of overkill for what I needed.

I wanted a way to email off the pictures motion took using just the command line. I picked mutt. Installing it from the repos installed postfix as the MTA. The problem was my ISP kept rejected the emails from postfix. Then I found an excellent guide at www.andrews-corner.org/mutt.html so I removed postfix and used msmtp instead..

Setting up
Install Ubuntu
Build/install usb driver
apt-get install motion
apt-get install mutt
apt-get purge postfix (use msmtp instead)
apt-get install msmtp
configure mutt /home/user/.muttrc
configure msmtp /home/user/.msmtprc
configure motion /home/user/motion.conf

I configured .muttrc and .msmtprc using the directions from www.andrews-corner.org/mutt.html. I then tested it with "echo test | mutt -s test myemail@myisp.com". Great success.

I left most of the settings in motion.conf as is, the most important change I made was to add "on_picture_save date | mutt -s motion myemail@myisp.com -a %f" to get it to send an email everytime it took a picture.

I also opened a port on my router so I could monitor the camera remotely using motion's built in webserver.





Credit goes to my mate P, who wrote this.

No comments:

Post a Comment