Sunday, 13 April 2014

Low budget Wireless IP surveillance set-up

For some time now I have been thinking of what to do with my old net-book with a 1GB ram memory and a Samsung android Tablet (2.3.6) which isn't updated any more. I finally decided to combine both as an auto-email alert  surveillance equipment for my flat. Really the cost of both at the current market price is less than £80, which by my understanding is fairly cheap for what will be achieved at the end of this small project.

Point to note: -  This set-up is purely Linux OS, I'm not sure how to do same using a windows  OS, as I don't use it for anything.

The basic requirements for this set-up are:

1. WiFi network : This is to enable flexibility with the location of the IP Cam and connectivity to the net-book. Also if you want to have an automated email notification of motion around your premises, then the network will require internet connectivity.

2. Any old laptop or desktop, will do as long as it has WiFi connection. While this is my set-up, you can also do same using a wired connection to the router.

3. An android device (any crap android device),  I'm using a Samsung YP-GI1, running on Ginger bread, this will be enough for this project. You will only need to install IP Webcam from Google play on the device.

The purpose of the installed webcam is to serve as IP webcam server, which will be used to send images to the net-book through the WiFi,  though you can use the installed webcam on the netbook. But for flexibility of the location of the cam, I'm using my android.

The Netbook setup

The net-book will serve two purposes, first is to retrieve and store images from the IP cam, and also send automated emails with picture attached each time motion is detected. We will be installing on the system an application called Motion. This application works by monitoring the noise ratio of the connected Cam and if it changes, which usually occurs when motion is detected or light shade changes, it automatically saves a copy of the image at that point.

Pseudo-code

- monitor folder where pictures are saved
- if new file is detected ( This only happens when new image is saved )
- attach the image file to email
- send an email to the registered email
- delete the file ( you can decide to save it if you have enough memory).

Code
#!/bin/bash
MOTIONCONF=/etc/motion/motion.conf
MOTIONDIR=` sudo grep "^target_dir" $MOTIONCONF | awk '{ print $2}'`
if [ ! -d $MOTIONDIR ]; then
mkdir $MOTIONDIR
#chown motion $MOTIONDIR
fi
while true
do
LISTFILES=`find $MOTIONDIR -maxdepth 1 -type f | grep jpg$`
NUMFILES=`find $MOTIONDIR -maxdepth 1 -type f | grep jpg$ | wc -l`
if [ $NUMFILES -gt 0 ]; then
for i in $LISTFILES
do
echo -e "Warning,\nAn intruder was detected at `date`\nPlease see the image attached for details" | sudo mutt -s /homeDirectory/.muttrc -s "[INTRUDER ALERT] Intruder Detected" -a $i -- ******@*****.com
echo password | sudo -S rm $i
done
fi
done 


Netbook and my crap android 
The final part is setting up the email client, I'm using Mutt, the website might be overwhelming at first sight,  but the process is fairly simple, you can contact me for my script on this. You may need a free SMTP provider setting, for this purpose I'm using Gmail as it offers me the required settings to send text based emails. The motion.conf file  residing in "etc/motion/........." will require some modifications  to use the IP CAM ( my android device). Look for the line netcam_url, this will need to be set to the IP of the android, i.e "http://your_ip_address:8080/photo.jpeg". PLEASE DON'T INCLUDE THE QUOTES WHEN SETTING THIS OPTION,  and the default webcam, which is the one attached to the system will also need to be disabled i.e if the system has one with the option videodevice.

On the Android, you will only need to start up the IP webcam app, it comes with some very basic set-up, but shouldn't be of any problem.

If all goes well, which it should, each time motion is detected by the android device, the user should receive an email with a picture.

That's all you will need to monitor your place.




4 comments:

  1. Thank you! I will try to setup the IP Surveillance using your method!! will feedback you whether it is success or fail...... thank pal!

    ReplyDelete
  2. Great! Thank a lot! I have tried, it is really useful to setup the wireless ip surveillance! one credit you, friend!

    ReplyDelete