Sie sind auf Seite 1von 3

construction

Live Home Security System niraj sa


& Sani th
hay
eo

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

122 February 2012 | Electronics For You www.efymag.com


construction
which distin- the image acquired has to be speci-
guish it from fied in the options of Streamer tool as
other devices. “streamer –o /path/of/the/image”
The vendor The Streamer can be installed from
ID (Logitech) the Internet by using the following
has to be men- command:
tioned in the sudo apt-get install streamer
code. Now Streamer reads audio and video
you can run data from ‘/dev/video0’ and ‘/dev/
the loop.pl dsp’ locations. Then it writes the data
program. to the disk. Various output formats are
Loop.pl. supported. The following instruction in
This is a Perl the code captures the image from the
script that webcam and stores it in your PC:
runs continu- sudo streamer -c /dev/video1 -b 16 -o
ously to check /home/efyindia/Documents/photos/
whether the image_$date.jpeg
webcam is where ‘-c’ defines the device driver and
connected or ‘-o’ defines the file destination.
Fig. 3: Flow-chart of the
not. Values for With ‘streamer –h’ executed in the
program ‘sleep’ com- console, the details of Streamer com-
mand in the mand can be viewed on the PC’s screen.
code can be changed to achieve an Listen.pl. This Perl script uses
optimal performance. Thunderbird has MPlayer tool to play the audio mes-
to be installed and configured before sage “Please, may I know your name”
running this program. The flow-chart to the visitor.
of the program is shown in Fig. 3. Record.pl. This code records the
When the visitor rings the door audio from the visitor using arecord
bell by pressing switch S1, it triggers tool. The destination for the audio
the monostable circuit and the web- acquired has to be specified in the
cam gets connected to the system. options of arecord tool as explained
The program control moves inside the below:
if($count2==1) condition in the loop.pl sudo arecord -f CD -d 5 -D hw:0,0 /
code. Then it starts executing the fol- home/efyindia/Documents/audios/
lowing programs sequentially: audio_$date.wav
Webcam.pl. It is a Perl script which where ‘-f’ is the format, ‘-d’ duration of
acquires the image from the webcam five seconds, ‘-D’ device name and ‘/
using Streamer tool. The image is home/efyindia/Documents/audios/
stored in your system. The path of audio_$date.wav’ destination of the
Parts List file.
The arecord can be installed from
Semiconductors:
IC1 - 555 timer the Internet by using the following
T1 - 2N3904 npn transistor command:
T2 - BC548 npn transistor
sudo apt-get install arecord
D1 - 1N4007 diode
LED1 - 5mm light-emitting diode arecord is a command-line sound
Resistors (all ¼-watt, ±5% carbon): file recorder for the ALSA soundcard
R1, R3, R4 - 1-kilo-ohm driver. It supports several file formats
R2 - 91-kilo-ohm
and multiple soundcards with multiple
Capacitors:
C1 - 100µF, 16V electrolytic devices.
C2 - 0.01µF ceramic With ‘arecord –h’ executed in the
Miscellaneous: console, more details of arecord com-
RL1 - 5V, 1C/O relay
- USB webcam (Logitech/ mand can be viewed on the screen.
Quantum) Mail_pic.sh. It is a Shell script
- USB cable which sends an e-mail to the house
- Door bell pushbutton switch
owner’s e-mail ID using Thunderbird

www.efymag.com Electronics For You | February 2012 123


construction
XTEST extension and other Xlib func-
tions. Additionally, you can modify
window properties. You can use
xdotool to switch desktops, move win-
dows between desktops, and change
the number of desktops.
Two commands of Xdotool are
explained below:
Fig. 4: An actual-size, single-side PCB for the live home security system Xdotool type “ABE”—Types ABE text
Xdotool key tab—Gives tab keystroke
With ‘xdotool –h’ executed in the
console, the details of xdotool com-
mand can be viewed.
Mail_audio.sh. This Shell script
sends an e-mail to another e-mail ID
using Thunderbird tool with the re-
corded audio file as attachment.
An actual-size, single-side PCB lay-
Fig. 5: Component layout for the PCB out for the live home security system
is shown in Fig. 4 and its component
tool with the acquired image file as the Internet by using the following layout in Fig. 5.
an attachment. The owner’s e-mail command: EFY note. The source codes of this
ID can be updated in this file using sudo apt-get install xdotool article are available on www.efymag.
“xdotool type ‘email_id@gmail.com’;” This tool lets you simulate key- com website.
command. board input and mouse activity, move The author is a student of M.Tech in mechatronics
The xdotool can be installed from and resize windows, etc. It uses X11’s & robotics

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

124 February 2012 | Electronics For You www.efymag.com

Das könnte Ihnen auch gefallen