Micro-Scholarship, What it is, How can it help me.pdf
Home automation and security using wireless network
1. HOME AUTOMATION AND SECURITY SYSTEMS USING WIRELESS
NETWORKS.
T.S.HARISHANKAR 05E122 haritechian@gmail.com
M.ARUNKUMAR 05E111 arun.logan@yahoo.co.in
S.VEDAPRAKASH 05E166 vedaprakash87@yahoo.co.in
ABSTRACT:
In the present days many houses are secure less and all appliances are operated manually.
Moreover the residents hardly remain in their houses due to their professions. They couldn’t
monitor their house from anywhere outside. Due to this houses are prone to theft. Also due to the
resident’s carelessness the appliances are “switched on” the whole day.
Over the last decade, this problem has been overcome by using the Internet and through power-
line modems. However, these solutions are not only complex but also require a physical
connection to access those devices. A simple, cost-effective solution is proposed here, by which
devices can be controlled remotely while the user is anywhere across the globe.
The objective of this project is to enable users to remotely control their home appliances and
systems using a cell phone-based interface. To access the control unit, the user should send an
authentication code along with the required/desired function/action to his/her home control
system via a simple SMS .Upon being properly authenticated, the cell phone-based interface at
home (control unit) would relay the commands to a microcontroller that would perform the
required function/action, and return a function completion code that would be sent to the source
of the original command (user’s cell phone).
This project is aimed toward consumers who wish to control household appliances remotely
from their cell phones provided that the appliances are electrically controllable. Example of
feasible appliances and applications under consideration include; enable/disable security
systems, fans, lights, kitchen appliances, and adjusting the temperature settings of a
heating/ventilation/air conditioning system.
1
2. INTRODUCTION:
Over the last decade, the implementation of this concept has been attempted by using the Internet
and through power-line modems. However, these solutions are not only complex but also require
a physical connection to access those devices. In case of controlling through Internet, the main
problems are- each controllable device requires separate Ethernet card and IP addresses to
control, it also requires Internet connection to each device. A simple, cost-effective solution is
proposed here by which devices as mentioned above can be controlled remotely, while the user is
anywhere across the globe just by sending appropriate SMS message, which is cheaper than
dialing and costs more or less same with respect to geographical distance.
Nowadays, SMS has become very popular. It is a store-and-forward way of transmitting
messages to and from mobiles. Each short message can be no longer than 160 characters. These
characters can be text (alphanumeric) or binary Non-Text Short messages. An interesting feature
of SMS is return receipts. This means that the sender has the option of receiving a receipt
notifying that the SMS was successfully delivered to the intended recipient. Since SMS uses
signaling channels for its transmission/reception as opposed to dedicated data channels, these
messages can be sent/received simultaneously with the voice/data/fax services over GSM
networks. Moreover, SMS supports national and international roaming. With PCS networks
based on all the three technologies (GSM, CDMA and TDMA) supporting SMS, SMS has been
rendered a universal mobile data service.
Power can be wasted in houses and offices due to forgetful nature of users not switching off
appliances after use. There is also the risk of over-heating and hence, damage caused to
household appliances like water-heaters due to such common human errors. By the solution
proposed, such power wastage can be minimized in homes and even work places can be
controlled by a common remote-switch by appropriate networking. In this method the Switches
will be controlled by SMS message.
DESCRIPTION:
The whole setup consists of many individual sub units. The various sub units are
1. MICROCONTROLLER
2. MAX 232
3. RS232 INTERFACE
4. AT COMMANDS
5. KEIL
6. POWER SUPPLY
7. VOLTAGE REGULATOR
1. INTRODUCTION TO ATMEL MICROCONTROLLER
2
3. SERIES: 89C51 Family,
TECHNOLOGY: CMOS
FEATURES:
• 4K Bytes of In-System Reprogrammable Flash Memory
• Fully Static Operation: 0 Hz to 24 MHz
• Three-Level Program Memory Lock
• 128 x 8-Bit Internal RAM
• 32 Programmable I/O Lines
• Two 16-Bit Timer/Counters
• Six Interrupt Sources
• Programmable Serial Channel
• Low Power Idle and Power Down Modes
PORT 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can sink eight TTL
inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0
may also be configured to be the multiplexed low order address/data bus during accesses to
external program and data memory
PORT 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can
source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal
pull-ups and can be used as inputs.
PORT 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can
/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal
pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low
will source
PORT 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the
internal pull-ups and can be used as inputs.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the
device.
PSEN
Program Store Enable is the read strobe to external program memory.
2. MAX232:
3
4. The MAX232 device is a dual driver/receiver that includes a capacitive voltage generator
to supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232
inputs to 5-V TTL/CMOS levels. Each driver converts TTL/CMOS input levels into EIA-232
levels. A max232 chip is used to do the level shifting and this chip is required to send data
serially to a PC which requires voltage levels as per RS232 standard.
3. RS232 STANDARD:
RS232 is an electrical signaling specification published by the Electronic Industries
Association (EIA). Although not identified in the specification, the 9-pin (DB9) connector,
With specific pin assignments, is commonly accepted as the RS232 connector or the serial
Connector. This standard interface provides connection for only modest transmission rates &
is often used with modems.
The general voltage assignment is:
Signal = 0 (LOW) > +3.0V
Signal = 1 (HIGH) < -3.0V
4. AT COMMANDS :
The AT command set is the fundamental interface with the modem. An AT command is simply
a string of characters proceeded by the AT prefix that is sent to the modem. The commands
typically instruct the modem to perform some action or set some characteristic within the
modem. The modem has two states: command state and on-line state. In command state, the
modem will accept and respond to AT commands. In the on-line state, the modem will transmit
data but ignore AT commands. Typically the modem is in the on-line state after dialing.
AT commands has the following format: The command is prefixed with AT (Attention) The
command is terminated by a carriage return <CR> (except the A/ command and
escape sequence). The commands can be entered in upper case or lower case. The AT prefix
can be in upper case or lower case, but both the A and the T must be the
same case. Characters that precede the AT prefix are ignored.
The command line interpretation begins upon receipt of the carriage return. These commands
are used for request information about the current configuration or operational status of the
mobile phone/modem and test availability and request the range of valid parameters, when
applicable, for an AT command.
4
5. Important AT command used to Test and Design:
1) ATD To dial a voice call from the modem.
2) AT+CLIR For calling line Identification Restriction.
3) AT+CNMI To set the mode of the mobile.
4) AT+CMGR To read the message at particular location.
5) AT+CMGD To delete the received message
6) AT+CMGS To send the message.
7) AT+CMGF To change the message format to PDU or Text mode.
8) AT+CMGL To see all the list of messages.
5. KEIL:
Keil Software development tools for the 8051 microcontroller family support every level of
developer from the professional applications engineer to the student just learning about
embedded software development. The industry-standard Keil C Compilers, Macro Assemblers,
Debuggers, Real-time Kernels, and Single-board Computers support ALL 8051-compatible
derivatives and help you get your projects completed on schedule.
6. POWER SUPPLIES:
The present chapter introduces the operation of power supply circuits built using filters,
rectifiers, and then voltage regulators. Starting with an ac voltage, a steady dc voltage is obtained
by rectifying the ac voltage, then filtering to a dc level, and finally, regulating to obtain a desired
fixed dc voltage. The regulation is usually obtained from an IC voltage regulator unit, which
takes a dc voltage and provides a somewhat lower dc voltage, which remains the same even if
the input dc voltage varies, or the output load connected to the dc voltage changes.
Transformer Rectifier Filter IC regulator Load
7. VOLTAGE REGULATORS:
The series 78 regulators provide fixed regulated voltages from 5 to 24 V.,
7805 is connected to provide voltage regulation with output from this unit of +5V dc. An
unregulated input voltage Vi is filtered by capacitor C1 and connected to the IC’s IN terminal.
The IC’s OUT terminal provides a regulated + 5V which is filtered by capacitor C2 (mostly for
any high-frequency noise). The third IC terminal is connected to ground (GND). While the input
voltage may vary over some permissible voltage range, and the output load may vary over some
acceptable range, the output voltage remains constant within specified voltage variation limits.
CONNECTION DIAGRAM:
5
7. The circuit diagram shows the interfacing of the cellular phone with the microcontroller
to communicate with the devices. The cell phone used supports GSM-SMS services. A simple
SMS say “HEATER ON” is sent to this interfaced cell phone. This message can be externally
accessed using AT commands through SERIAL INTERFACE. AT commands will be explained
in the program. Serial interface is established using RS232. In RS232 a logic1 is represented by
-3 to -25V while a logic0 is +3 to 25 V. The RS232 standard is not TTL compatible; therefore it
requires the line drivers such as MAX232 to convert RS232 voltage levels to TTL levels and
vice-versa.
For reliable and best serial data transfer we must synchronize microcontroller and the cell
phone at a fixed baud rate. The baud rate in the 89c51 is programmable. This is done with the
help of timer1. Hence the baud rate is set as 9600kbps. The sequence of AT commands that are
to be sent to communicate with the mobile are:
STEP1: the command AT is sent through the microcontroller from SBUF register.
STEP2: “AT+CMGF=1” is sent to set the mobile phone in text mode.
STEP3: AT+CPMS=”ME” command selects the phone memory.
STEP4: AT+CNMI=1,2,0,0,0 this command will read the message in the first index of the phone
memory and delete it after reading it.
STEP5: when a new message says “HEATER ON” is sent from our mobile this is delivered to
the microcontroller directly in this text format.
+CMGL: 1,"REC READ","+85291234567",,"06/11/11,00:30:29+32"
HEATER ON.
STEP6: SBUF register will receive this message. Through our program the carriage return is
sensed and the content of the message is received.
STEP7: this string received is compared with the already stored
string. If this match occurs the corresponding subroutine is
invoked and the corresponding port pin is made “1”.
STEP8: this port is connected to a relay and through this the
HEATER is switched ON.
FOR SECURITY SYSTEMS:
The security system that is used includes an electronic keypad that comprises
of 10 keys numbering (0-9). In the residence absence they can
activate this keypad in which an appropriate code should be
typed in. When a person needs to enter the home the code (should
be known) should be typed. This code will be sent to the owner’s
cell phone number through the microcontroller. If the code is
correct command “OPEN DOOR” is sent. The microcontroller will
interpret this command and opens the door. If the code is wrong
the door will not be opened. All the above authentication
process is done by separate subroutine in our program. This
subroutine is invoked when the keypad is activated.
7
8. PROGRAM:
#include <REGX51.h>
#include <stdio.h>
#include "delay.h"
#include "serial.h"
void newline(void);
void ins(void);
void chksms(void);
void sendsms(void);
main()
{
PORTB = 0b00000000;
TRISB = 0b00000000;
while(1)
{
chksms();
chkkepad();
}
}
void newline()
{
printf("rn");
}
void ins(void)
{
newline();
printf("ATE=0"); //turns off the echo. if ATE=1 we can see what we are typing on the
monitor.
newline();
DelayS(2);
printf("AT"); //the simplest AT command. it is used to check if communication has been
//established with the phone. if the communication is established,
//the phone replies "OK"
newline();
DelayS(2);
printf("AT+CPMS="ME","ME","ME""); //sets the phone memory as the preferred
storage
newline();
DelayS(2);
printf("AT+CNMI=1,2,0,0,0"); // incoming message notification setting
newline();
8
9. DelayS(2);
printf("AT+CMGF=1"); //sets the phone for TEXT mode SMS
newline();
DelayS(2);
}
void chksms(void)
{
ins();
DelayS(3);
printf("AT+CMGR=1"); //tells the phone that the microcontroller wants to read the SMS at
index #1
//if there is an SMS at index #1, the phone sends the
sms string to the device
/*in TEXT mode the AT+CMGR=1 command may get a string like this:
+CMGR: "REC READ","<phone number>","Joe","08/02/23,10:34:57+24"
HEATER ON <<< this line is the real SMS message OK
*/
newline();
for(;getch() == 'r';) // r is the last character before the real SMS message starts.
{
if( getch() == 'H' ) //just checking if the 1st character of the message is 'H'
{
p1.0 = 1; //turning HEATER ON
sendsms();
break;
} }}
sendsms()
{
printf("AT");
newline();
delay(2);
printf("AT+CSCA="+xxxxxxxxxxxx");/*type the sms center number*/
newline();
delay(2);
printf("HEATER SWITCHED ON");
newline();
delay(2);
printf("AT+CMGS="+yyyyyyyyyyyyy");/*recipient no*/
newline();
delay(2);
}
9
10. void chkkepad() /*get the door access code via the keypad*/
{
cur=0xc0;
command(0x01);command(0x80);
command(0xc0);
while(1)
{
command(0x0f);command(cur);
if(k0==0){cur++;if(cur==0xc0)cur=0xc0;}else if(k1==0){cur--;if(cur<=0xc0)cur=0xc0;}
else if(cur==0xc3)
{
if(k2==0){command(0x0c);n1[3]++;if(n1[3]>=10)n1[3]=0;write(n1[3]+0x30);}
else if(k3==0){command(0x0c);n1[3]--; if(n1[3]==0xff)n1[3]=9;write(n1[3]+0x30);}
}
else if(cur==0xc4)
{
if(k2==0){command(0x0c);n1[4]++;if(n1[4]>=10)n1[4]=0;write(n1[4]+0x30);}
else if(k3==0){command(0x0c);n1[4]--; if(n1[4]==0xff)n1[4]=9;write(n1[4]+0x30);}
}
else if(cur==0xc5)
{
if(k2==0){command(0x0c);n1[5]++;if(n1[5]>=10)n1[5]=0;write(n1[5]+0x30);}
else if(k3==0){command(0x0c);n1[5]--; if(n1[5]==0xff)n1[5]=9;write(n1[5]+0x30);}
}
delay(15000);
}
end_k;
command(0x80);
command(0xc0);
}
CONCLUSION:
Thus the denouement of this project will convert a normal domicile into a fully
automated and secured in much cheaper rate than the other counterparts available in the market.
With this people feel at home as they can control the whole system using a cell phone. Further
the service that is used “SMS” is much reliable than other wireless networks like “Bluetooth”.
From this the overall number of thefts and the power consumption in each home can be abated.
This improves the overall economy of the country.
REFERENCE:
“The 8051 Microcontroller and Embedded Systems” by Muhammad Ali Mazidi.
10