There is a time when you are leaving your home empty and you don’t have an expensive security and alarm system. You need to be protected and be aware if there are any changes or visits that you do not approve of while you are gone. There is an easy way to achieve just that with Motion. What you need is:

  1. Linux OS (ex. Ubuntu)
  2. Motion (free)
  3. Webcam
  4. Internet (optional)
  5. Hosting (optional)
  6. Smartphone with data plan (optional)

After you have your computer ready, webcam installed and working, go and download the Motion project or use Ubuntu’s apt to get it (check to get the latest version):

sudo apt-get install motion

Run the program (Motion) with root privileges, like sudo motion, however please note that you should probably run it with sleep or cron, otherwise it will activate immediately and most probably detect you while you are exiting the room.

Now you are all set for the basic surveillance with just a webcam which will record when there is a movement in front of the camera, however there are some more advanced options which could help a lot.

Email you when there is movement detected

For this you will need to install sendmail and mutt, assuming you are on Ubuntu

sudo apt-get install sendmail mutt

The basic settings for sendmail are enough for most users, but if you are an advanced user feel free to modify it as you desire.

Open the file /etc/motion/motion.conf in your favorite text editor (ex. vim), then locate the text on_even_start value and change the value part with:

echo "This is the body of the message" | mutt -s "Motion has been detected" your@mail.com

If there is a ; (semi-colon) on the beginning of the row, remove it, also if there is any empty space before the on_event_start.

Sending images to a webserver

It would be good to have the images taken from the motion to a webserver so that you can check from a remote location what is there on the images and report to the police if needed.
Open the /etc/motion/motion.conf file again in a text editor and locate the text on_picture_save value and change the value part with:

scp %f user@yourdomain.com:/path/for/images/

If there is a ; (semi-colon) on the beginning of the row, remove it, also if there is any empty space before the on_picture_save.

Enable login without password on your webserver

You need to create a ssh key on your machine with the following

sudo ssh-keygen -t dsa

Upload the key to your webserver:

sudo ssh-copy-id -i /root/.ssh/id_dsa.pub user@yourdomain.com

Tips and tricks: if you have a LED light on your camera, put a plastic electrician tape (isolation tape) on it so that the camera is not noticeable. Also, make sure you have some light in the room, unless the camera has a feature for night vision.