Ethernet Based Security System

Published on March 2017 | Categories: Documents | Downloads: 15 | Comments: 0 | Views: 230
of 18
Download PDF   Embed   Report



E t h e r n e t b a s e d S e c u r i t y s y s t e m f o r
Ho me s a n d s ma l l l a n d s c a p e s
The need for Security systems have rapidly grown from being specialized for high-risk
areas (like banks, companies , governmental institutions), to be available and demanded
rapidly by the average public. n the last ten years, small businesses have rapidly grown
and e!panded and the need of reliable, cheap and effective security system is becoming a
must ,not only for the business owners ,but also at homes . "ne of the offered way of
security systems offer the S#S notification service ,, nice but not that reliable . S#S
center could have a congestion at the time the thief was sleeping in your company (or
home) borders . $ell another method of creating a security system and which would be
very effective is to use the nternet or %thernet &otification system . t is reliable, when
using T'(, and effective where most internet services are always on demand and it is
very rare , and very unlikely to have a sudden failure .
Commercially available Security systems are too expensive
)nfortunately, this could be a little pricy since most embedded %thernet devices cost a
large amount of money and they are usually hard to deal with . That*s why was so
interested and a little bit surprised with wiznet offering of the $+,-- .ardwired
T'(/( %thernet chip . was so amazed of its various features especially the
support for T'( and )0( protocols essential for an %thernet based security
system . 1nd what shock me the most was its price ($5.20) . 2ou can actually
build a security system over the internet using an %thernet device that would cost
you about the same as any microcontroller .Simply amazing 3
&ow, why to even bother to create such a system while it could be commercially
available 4 $ell, here the problem arises, 0espite their commercial success, most
if not all commercially available devices target large corporations and companies
,neglecting the need for this system to the home residents and small business
owners . am not saying it is not available for them , but it is way pricy for normal
consumers. .ere comes my pro5ect into place .
My Solution
have constructed a T'( based security system using the %thernet module offered within
the contest , an 1Tmega,67 microcontroller , a (8 as a sensor and few other
peripheral devices , which is specially targeted for homes and small business
have used through for my final design a combination of the $9:,-#; module , an
1Tmega,67 microcontroller , a <.=<>: #.z crystal (compatible with my
bootloader programmer), a 0S,=-> timekeeper , a (8 to sense the human
movement through the body heat , a keypad for initial configuration and a >?,6
7'0 for display. The design also include regulators to power up the circuits
See 3 it is really a simple but effective design . t is a compact, complete, and easy to
install security system designed with home users and small businesses, since it is
affordable as you can see that it was built using an handful of ine!pensive and
cheap parts.
How it works
$ell, the system should be installed near an internet source and a cable (crossover or
straight-through as it depends) should be plugged in to the module*s [email protected]+ 5ack.
f the system is in rest mode (acting as T'( server) . t waits for commands from the
client(its ( address can be programmed or change initially or during operation) and
e!ecute them (after a password is entered obviously )while still inspecting for any
1larm which would arises from the (8 sensor . $hen any 1larm triggers, it
switches into client mode (acts as a T'( client) and starts sending warning signs.
The system uses motion sensing (based on human body heat) to trigger an alarm which
sends a message to the server containing a timestamp presenting the e!act time the
#otion was detected acting as a real-time surveillance system . Aor increasing
safety from the risk arising from a false alarm , it sends the alarm signals for about
+ minutes and then it stops for ,- minutes and so on assuming the alarm was still
active ... 'learing the way for the costumer to stop the alarm if he noticed some
kind of a failure as the system acts as a server in these ,- minutes. This false alarm
is very rare and it could occur as a result of maybe a passing sBuirrel maybe or
some relative passed by and forgot to turn the alarm off .. etc .. So although it is
rare but should be taken care of.
"nce it is connected and powered on , (it takes power from = sources ,=.=v ,+v,and ,> v
for the (8) the system enters into the configuration mode .
Configuration mode
n the first start-up of the system, it enters the configuration mode . t is 5ust a feature that
added for the design to be more fle!ible. The System asks you first(through the
7'0 interface) to enter a @ digit password , didn*t do a masking feature because
sense there would be less error when you can really see the password written on the
7'0 , and there isn*t off course any viruses or key loggers are there 43 
The system will also ask you about the current date and time which is necessary for the
validity of the timestamp associated with the 1larms. "therwise, if the time was
miss-entered ,the customer may lose track of when the alarm was really triggered
1fter entering the current date the system asks the customer to chose between accepting
the default ( setting or reconfigure them depending on his own needs . The
customer will be asked to enter the System ( 1ddress ,the subnet mask, the default
gateway address , the #1' address desired , and the destination or Server (
address in which will give commands remotely to the security system and will also
receive 1larm signals when the motion is sensed . and here ends the configuration ,
didn*t really see any more necessary feature to add to the configuration ,but this
doesn*t block the way for future improvement as minor ad5ustments could be made
and the user could be given more fle!ibility in the future versions.
Server Mode: what happens when the alarm isn’t on
$ell , in this mode , added some features which guess were essential and primary for
this application . $hen first thought about the design , said hey ,, lets control all
the damn house ,, why not right 4 especially that the wiznet chip can tolerate such
feature . Cut as time ran over decided to stick to the main idea of security system .
why would anyone control his home while he isn*t there 433 .e would 5ust need to
protect it ,,, and thus optimized the control for security purposes only .
"D, what happens when the customer connects to the system . "ff course everyone
would e!pect there will be a password so not anyone who would connect to the
system would mess up your house. So you must enter a password before you can
send commands. The command set is limited actually for the purpose mentioned
above to be dedicated only for security. Therefore , you can turn the lights on and
off . This feature looks at the first time as control but it is an effective way to say to
the burglar stop , am in the house and fully alert ... The burglar wouldn*t e!pect
that you have my product 
1nyway, you can also change the destination ( address of the server in which it is
eligible to connect to the system as you could change your location and as a result
you may have to change the server address remotely. "ff course, you have to logout
after you finish configuration to be safe and secure that no one but you could log in
to your system.
"ne nice feature added is the ability to turn 7ights on and off to convince any potential
thief that the house is already occupied, so he would forget the whole operation
from the start , and while it is a control feature , it is a very good security feature.
(SE the led*s o/p could be connected to any relay*s input and it will work splendidly
Client Mode : When a movement is sensed
$hen the system detects any motion through the (8 , t directly switches into the client
mode . t reads the current time and sends the alert message containing the
timestamp . 1s mentioned before it keeps doing so for + minutes, stopes for ,-
minutes and resume the operation if the alarm was still triggered and so on .
Through these ,- minutes , it goes back to server mode 5ust in case the customer
know that it was a flow and wanted to turn it off.
f alarm is
Server mode
'lient mode
f alarm is
$ait for commands
%!ecute 'ommand
+ min from
first alarm4
Send 1larm
Clocked 4
1larm Clocked
,- minutes passed4
%nter password
1sk for
1pply default setting
'onfiguration using
nsert ( settings
Cegin processing
eveloping !rocess
was really interested since went to college to study communication systems ( am now
in the 5unior year in college in the '%% department, 'ommunications and
%lectronic %ngineering), to be able to monitor my home in my absence. This is a
big issue here since most people in my country own summer homes in the
mountains which remains unprotected and empty all winter . There were first
decided to build a compact remote security system designed for ordinary people to
protect their valuables . did chose the nternet as the abstract though, since
through my search on the net it seemed very complicated and e!pensive . Therefore
when heard about the contest from my colleague was both thrilled and surprised.
Thrilled to find my call and surprised to hear about such a product. $hen the
wiznet module first came three weeks ago was so enthusiastic began developing
the module adapter right away .(The ('C was already published on the net , 5ust
did the fabrication)
(icture for the adapter
1s run over the datasheet was really relieved that the module supports S( as usually
chose components in embedded design to be compatible with S( and worked a
lot with it on the past. t was really easy to control $+,-- sing S( and after
initialized The ("8TS and the S( registers , the rest was easy using the following
function E
unsigned char spiGtransfer(volatile unsigned char data)
S(08 I dataJ // Start the transmission
while (3(S(S8 K (,LLS(A)))J // $ait for the end of the transmission
return S(08J // return the received byte
t was a little disappointment though the lack of support for the S( nterrupt handler .
Cut t worked smoothly nevertheless .
1fter we have forgotten all about S( using this function the ne!t thing to do is to write
functions which would be able to read and write to the module*s registers, and as
you can see below, this wasn*t a hard 5ob to do either .
unsigned char wizGrd(unsigned int address)
unsigned char data I -!--J
("8TC KI N(,LL(&GS71F%GS%7%'T) J //enable slave
spiGtransfer((addressOO:) K -!--AA)J
spiGtransfer(addressK -!--AA)J
data I spiGtransfer(0)##2G01T1)J
("8TC PI (,LL(&GS71F%GS%7%'T) J // 0isable slave
return dataJ
void wizGwr(unsigned int address, unsigned int targetFalue)
("8TC KI N(,LL(&GS71F%GS%7%'T) J //enable slave
spiGtransfer((addressOO:) K -!--AA)J
spiGtransfer(address K -!--AA)J
("8TC PI (,LL(&GS71F%GS%7%'T) J // 0isable slave
1nd after this was done , my first task was to make the module accept the ping to its (
address. 1nd unfortunately it was a challenge , why4 ,, lets see .
1s first run the application ,, was so surprised it didn*t work ,, used the terminal to
figure out where the problem was and my functions were ,--Q correct , could
write and read from the device register but still the ping command didn*t work ..
That*s when began to worry about being a problem with the module itself
.%specially that the module wasn*t sending any signals for being alive . 1fter days
of manipulating the code and checking connections which led to re-e!amine the
module*s adapter . Ainally ,, realized what the problem was , noticed that the
power-on 7%0 faints every time insert the module which led me to a theory that
the current wasn*t enough for the module and was right . Cy replacing the old
adapter with a powerful ,>-- m1 adapter and that*s it. The module finally started
to give response, both leds of the [email protected]+ 5ack were illuminating , and it successfully
gave reply to my ping reBuest . So was relieved and went through with
e!perimenting the $+,--.
Why "C!
1ctually first started my pro5ect using )0( packets , and all operations went smoothly .
Then again , noticed that needed a more reliable method for the security system
as )0( is very unreliable , for the data loss is always possible , and you cant really
figure out if you are really connected to the server or not . So T'( was undoubtedly
a more secure solution for the system to work reliably as it reBuires .
The Transmission 'ontrol (rotocol (T'() is one of the core protocols of the #nternet
protocol suite. T'( provides reliable, in-order delivery of a stream of bytes
making it very suitable for secure data communications .
This is the T'( packet simplified ,, scary isn*t it . Cut the great thing about $+,-- is that
it relief you from all the messy work of having to worry about seBuence number and
checksums ,... etc .. 1nd 0" C%7%F% me when tell you this because suffered
alot dealing with nokia*s A-bus protocol which has annoying checksum and
seBuence number fields . 1nyways back to our sub5ect , the $+,-- %thernet chips
let you worry about handling only the data , and it stores the destination ( address
and ("8T address in special registers .
"C! M$%S
Server Mode
T'( can act as a client or a server. 1cting as a server it listens continuously for
connection reBuests until a reBuest is received .t off course keep monitoring in the
process the (8 for any motion detection. n this stage, the peer ( address isn*t of
great importance, since when you send back information to the client his ( address
will be initially captured by the $+,-- and stored in the proper registers. 1lthough
thought of limiting the connection to the module as a server to only one (
address, but it seems the password solves the security problem as the customer may
use a shared computer at work from one side , and for the other side , it makes
space for more fle!ibility to send commands from everywhere and from any
computer through the net. Therefore as you see only locked the ( address in
which the 1718# is sent to.
.ere is how it is done E
7istenGT'((Sock-)J // 7isten for reBuests on socket-
while (wizGrd(SnGS8(Sock-)) II S"'DG7ST%&)
if(1larm) //if 1larm is detected -O connect to server
lcdGputsf(R1larm 0etectedR)J
goto tcpJ //switch to client mode
MJ //wait for reBuest
Client Mode
$hen acting as a client it directly connects to the previously saved destination ( address
and send an embedded message containing the alarm and the time of occurance.
The rest of the functionality is as e!plained earlier is all about alarming for +
minutes, suspension for ten minutes to allow disabling the alarm in case of a fault ,
and so on .
"he !#&
$ell the (8 was easy to interface, it has = pins E , connected to FS , "ne to Tround ,
and one to the microcontroller . whenever body heat based movement is detected ,
the (8 triggers high and the microcontroller is notified and the info is transmitted .
This sensor could be replaced with any similar sensor but the primary application
for this pro5ect was protection against burglary , so this (8 fits perfectly.

The (8 is the Treen ('C module in my hand
"he 'C( )eypad( and the "imekeeper
$ell, the 7'0 and the timekeeper had already developed functions embedded inside the
'odeFision1F8, so used it directly to save time developing the pro5ects and it fitted
perfectly .
1s for the keypad had developed a software for the mission a year before, so this was a
good opportunity to really use it.
)nfortunately had a little error back then, the values of the first row are shifted right 3
7ooks like a keypad hardware error ,, C)T over passed it by a little code manipulation
as you see below so it worked with me perfectly.
co,omn,E //first column
("8T' I-!<fJ//-,,,
//check for rows
if (3'.%'DCT((&',=)) H aI,=Jgoto resultJM
else if(3'.%'DCT((&',>)) H aI>Jgoto resultJ M
else if(3'.%'DCT((&',,)) H aI=Jgoto resultJ M
else if(3'.%'DCT((&',-)) H [email protected] resultJ M
else goto co,omn>J
co,omn>E//second column
("8T' I-!bfJ//,-,,
if (3'.%'DCT((&',=)) H aI,Jgoto resultJ M
else if(3'.%'DCT((&',>)) H aI6Jgoto resultJ M
else if(3'.%'DCT((&',,)) H aI<Jgoto resultJ M
else if(3'.%'DCT((&',-)) H aI:Jgoto resultJ M
else goto co,omn=J
co,omn=E//third column
("8T' I-!dfJ//,,-,
if (3'.%'DCT((&',=)) H aI+Jgoto resultJ M
else if(3'.%'DCT((&',>)) H aI,-Jgoto resultJ M
else if(3'.%'DCT((&',,)) H aI,,Jgoto resultJ M
else if(3'.%'DCT((&',-)) H aI,>Jgoto resultJ M
else goto co,[email protected]
co,[email protected]// fourth column
("8T' I-!efJ//,,,-
if (3'.%'DCT((&',=)) H aIUJgoto resultJ M
else if(3'.%'DCT((&',>)) H aI,@Jgoto resultJ M
else if(3'.%'DCT((&',,)) H aI,+Jgoto resultJ M
else if(3'.%'DCT((&',-)) H aI,6Jgoto resultJ M
else goto co,omn,J
if(c3Ia) //acts sorts of like debouncing
if(aII,) HbI,JM
if(aII>) [email protected]
if(aII=) HbI<JM
if([email protected]) HbIVWVJM
if(aII+) HbI>JM
if(aII6) HbI+JM
if(aII<) HbI:JM
if(aII:) HbI-JM
if(aIIU) HbI=JM
if(aII,-) HbI6JM
if(aII,,) HbIUJM
if(aII,>) HbIV.VJM
if(aII,=) HbIV1VJM
if(aII,@) HbIVCVJM
if(aII,+) HbIV'VJM
if(aII,6) HbIV0VJM
*ree Software +sed
1s for receiving packets and controlling at the other end you can use any free software
available, use .ercules , because it is easy to use and supports both T'( client and
server .. So this software works perfectly . 2ou can )se also %thereal or any other similar
free software.
!ro,ect $ver-iew .lock iagram
; %thernet
Complete High &esolution Schematic
!arts 'ist
1s you can see above used for this pro5ect in addition to the $9:,-#; module E
,) 1Tmega,67 microcontroller
>) <.=<>: #.z crystal oscillator
=) (8
@) > ==pA capacitors
+) 1 timekeeper
6) , 6++=6 .z oscillator for the timekeeper
<) , 7'0
:) , Deypad
The overall cost was about E > X for the keypad
+ X for the (8
> X for the timekeeper
, X for the oscillators
+ X for the 7'0
@ X for the 1Tmega
&one for the $9:,-#; module J)
Total cost I ,U X
Total cost (including the $9:,-#; module real cost)I,US,> I=,X for a secure and
reliable %thernet based security system.
*uture #mprovements
&e!t time would order two $9:,-#; modules to enable two way communication
between two products and enable me to e!pand my pro5ect and design even more for the
future improvements is limitless with the $+,-- wonderful features . was thinking
about adding a sensing camera , and an audio input with could be streamed through the
internet )sing )0( offering a real time monitoring security system . The system could be
eBuipped with flash memory for mass storage and 81#s for real time buffering , but
was intending to use A(T1s for such an application so hopefully ne!t year , circuit cellar
would host an A(T1 contest 33

Sponsor Documents

Or use your account on


Forgot your password?

Or register your new account on


Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in