Professional Documents
Culture Documents
Sandip Nair
P
resented here is a simple and
inexpensive PC-based home
security system. It uses a simple
interfacing circuitry, and is developed
using Perl and Shell scripts and tested
on Linux (Ubuntu 9.10) environment.
The computer should be connected
to the Internet, webcam, speaker and
microphone. The door bell switch in
the interfacing circuit activates the
webcam, speaker and microphone.
Fig. 1 shows the block diagram of
live home security system. The web-
cam, speaker and microphone are fixed Fig. 1: Block diagram of live home security system
near the front door at a particular ori-
entation for optimal recording. When
a visitor rings the bell by pressing the
door bell switch, his image is captured
by the webcam. The speaker plays an
audio asking the name of the visitor.
The visitor’s voice (name) is recorded
in the PC through the microphone. The
captured image and audio files are sent
to the e-mail ID of the house owner.
The house owner can receive and ac-
cess these files in his smartphone with
inbuilt e-mail client within seconds
from anywhere.
Apart from Ubuntu operating sys-
tem, you need the following software
to be installed in your PC: Fig. 2: Circuit of live home security system
MPlayer. To play the audio.
Mplayer is a free and Open Source shortcut from the command line in it connects the USB webcam with the
media player. It is available for all ma- Linux for Thunderbird (e-mail client). PC for 10 seconds—set as per the time
jor operating systems, including Linux. xdotool allows programmers to emu- constant of the monostable multivibra-
arecord. To record the audio. late keystrokes and mouse actions. tor (t=1.1×R2×C1). The loop.pl code
arecord is a command-line sound file Thunderbird. To send an e-mail to given at the end of this article runs
recorder for the ALSA soundcard the recipient’s e-mail ID. continuously in the PC to check wheth-
driver. It supports several file formats er the webcam is connected or not.
and multiple sound cards with multi- Project description Before running the application
ple devices. The interfacing circuitry is shown in program, you need to execute ‘lsusb’
Streamer. To capture the image. Fig. 2. It is built around a 555 timer command, which lists out the number
Streamer is a versatile program that al- configured in monostable mode. The of USB devices connected to your PC.
lows capture from a webcam or video circuit does not require external power In the list, you can find the webcam de-
device using only the command line supply. It is directly driven by the 5V vice name (Logitech in this case). Each
in Linux. supply received from the USB of the USB device connected to a computer
xdotool. To control the keyboard user’s PC. When the timer is activated, will have a vendor ID and a product ID
Source Codes
loop.pl -> system “./mail_audio. done < date.txt
#!/usr/bin/perl sh”; thunderbird -compose “attachment=file:///
use strict; } home/efyindia/Documents/photos/
use warnings; } image_$date.jpeg”&
my $i=0; sleep 5;
while($i == 0) webcam.pl -> xdotool type ‘email_id@gmail.com’;
{ #!/usr/bin/perl sleep 1;
system “lsusb |sudo tee usblist.txt”; use strict; xdotool key Tab;
open FILE, “usblist.txt” or die $!; use warnings; sleep 1;
my $line; open FILE, “date.txt” or die $!; xdotool type ‘somebody is at the door’;
my $count; my $date = <FILE>; sleep 1;
my $count2=0; chop($date); xdotool key Tab;
open FILE, “usblist.txt” or die $!; print “\nhi\n$date”; sleep 1;
while ($line = <FILE>) system (“sudo streamer -c /dev/video1 -b xdotool type ‘this is the picture’;
{ 16 -o /home/efyindia/Documents/photos/ sleep 1;
my @word = split(/ /, image_$date.jpeg”); xdotool key Ctrl+Return;
$line); close FILE;
$ c o u n t = mail_audio.sh ->
grep(/^Logitech/, @word); listen.pl -> #!/bin/bash -x
if($count==1) #!/usr/bin/perl while read myline
{ $ c o u n t 2 = 1 ; } use strict; do
use warnings; echo $myline
} system (“sudo mplayer attention.wav”); date=$myline
close FILE; done < date.txt
if ($count2 ==1) record.pl -> thunderbird -compose “attachment=file:///
{ #!/usr/bin/perl home/efyindia/Documents/audios/
my $date = localtime use strict; audio_$date.wav”&
time; use warnings; sleep 5;
my @date2 = split(/ open FILE, “date.txt” or die $!; xdotool type ‘email_id@gmail.com’;
/, $date); my $date = <FILE>; sleep 1;
$date = “$date2[4]_$d chop($date); xdotool key Tab;
ate2[0]_$date2[1]_$date2[3]_$date2[5]”; system (“sudo arecord -f CD -d 5 -D sleep 1;
system “echo $date | hw:0,0 /home/efyindia/Documents/audios/ xdotool type ‘somebody is at the door’;
sudo tee date.txt”; audio_$date.wav”); sleep 1;
system “./webcam.pl”; xdotool key Tab;
system “./listen.pl”; mail_pic.sh -> sleep 1;
system “./record.pl”; #!/bin/bash -x xdotool type ‘this is the audio’;
sleep 10; while read myline sleep 1;
system “./mail_pic. do xdotool key Ctrl+Return;
sh”; echo $myline
sleep 20; date=$myline