Home automation and security using wireless network


Published on

6th sem project doc

Published in: Education
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Home automation and security using wireless network

  1. 1. HOME AUTOMATION AND SECURITY SYSTEMS USING WIRELESS NETWORKS.T.S.HARISHANKAR 05E122 haritechian@gmail.comM.ARUNKUMAR 05E111 arun.logan@yahoo.co.inS.VEDAPRAKASH 05E166 vedaprakash87@yahoo.co.inABSTRACT: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’tmonitor their house from anywhere outside. Due to this houses are prone to theft. Also due to theresident’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 physicalconnection to access those devices. A simple, cost-effective solution is proposed here, by whichdevices 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 andsystems using a cell phone-based interface. To access the control unit, the user should send anauthentication code along with the required/desired function/action to his/her home controlsystem via a simple SMS .Upon being properly authenticated, the cell phone-based interface athome (control unit) would relay the commands to a microcontroller that would perform therequired function/action, and return a function completion code that would be sent to the sourceof the original command (user’s cell phone).This project is aimed toward consumers who wish to control household appliances remotelyfrom their cell phones provided that the appliances are electrically controllable. Example offeasible appliances and applications under consideration include; enable/disable securitysystems, fans, lights, kitchen appliances, and adjusting the temperature settings of aheating/ventilation/air conditioning system. 1
  2. 2. INTRODUCTION:Over the last decade, the implementation of this concept has been attempted by using the Internetand through power-line modems. However, these solutions are not only complex but also requirea physical connection to access those devices. In case of controlling through Internet, the mainproblems are- each controllable device requires separate Ethernet card and IP addresses tocontrol, it also requires Internet connection to each device. A simple, cost-effective solution isproposed here by which devices as mentioned above can be controlled remotely, while the user isanywhere across the globe just by sending appropriate SMS message, which is cheaper thandialing 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 transmittingmessages to and from mobiles. Each short message can be no longer than 160 characters. Thesecharacters can be text (alphanumeric) or binary Non-Text Short messages. An interesting featureof SMS is return receipts. This means that the sender has the option of receiving a receiptnotifying that the SMS was successfully delivered to the intended recipient. Since SMS usessignaling channels for its transmission/reception as opposed to dedicated data channels, thesemessages can be sent/received simultaneously with the voice/data/fax services over GSMnetworks. Moreover, SMS supports national and international roaming. With PCS networksbased on all the three technologies (GSM, CDMA and TDMA) supporting SMS, SMS has beenrendered a universal mobile data service.Power can be wasted in houses and offices due to forgetful nature of users not switching offappliances after use. There is also the risk of over-heating and hence, damage caused tohousehold appliances like water-heaters due to such common human errors. By the solutionproposed, such power wastage can be minimized in homes and even work places can becontrolled by a common remote-switch by appropriate networking. In this method the Switcheswill be controlled by SMS message.DESCRIPTION: The whole setup consists of many individual sub units. The various sub units are1. MICROCONTROLLER2. MAX 2323. RS232 INTERFACE4. AT COMMANDS5. KEIL6. POWER SUPPLY7. VOLTAGE REGULATOR1. INTRODUCTION TO ATMEL MICROCONTROLLER 2
  3. 3. SERIES: 89C51 Family,TECHNOLOGY: CMOSFEATURES:• 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 ModesPORT 0Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can sink eight TTLinputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0may also be configured to be the multiplexed low order address/data bus during accesses toexternal program and data memoryPORT 1Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers cansource four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internalpull-ups and can be used as inputs.PORT 2Port 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 internalpull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled lowwill sourcePORT 3Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers cansink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by theinternal pull-ups and can be used as inputs.RSTReset input. A high on this pin for two machine cycles while the oscillator is running resets thedevice.PSENProgram Store Enable is the read strobe to external program memory.2. MAX232: 3
  4. 4. The MAX232 device is a dual driver/receiver that includes a capacitive voltage generatorto supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232inputs to 5-V TTL/CMOS levels. Each driver converts TTL/CMOS input levels into EIA-232levels. A max232 chip is used to do the level shifting and this chip is required to send dataserially to a PC which requires voltage levels as per RS232 standard.3. RS232 STANDARD: RS232 is an electrical signaling specification published by the Electronic IndustriesAssociation (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 serialConnector. This standard interface provides connection for only modest transmission rates &is often used with modems.The general voltage assignment is:Signal = 0 (LOW) > +3.0VSignal = 1 (HIGH) < -3.0V4. AT COMMANDS :The AT command set is the fundamental interface with the modem. An AT command is simplya string of characters proceeded by the AT prefix that is sent to the modem. The commandstypically instruct the modem to perform some action or set some characteristic within themodem. The modem has two states: command state and on-line state. In command state, themodem will accept and respond to AT commands. In the on-line state, the modem will transmitdata 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) Thecommand is terminated by a carriage return <CR> (except the A/ command andescape sequence). The commands can be entered in upper case or lower case. The AT prefixcan be in upper case or lower case, but both the A and the T must be thesame case. Characters that precede the AT prefix are ignored.The command line interpretation begins upon receipt of the carriage return. These commandsare used for request information about the current configuration or operational status of themobile phone/modem and test availability and request the range of valid parameters, whenapplicable, for an AT command. 4
  5. 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 message6) 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 ofdeveloper from the professional applications engineer to the student just learning aboutembedded software development. The industry-standard Keil C Compilers, Macro Assemblers,Debuggers, Real-time Kernels, and Single-board Computers support ALL 8051-compatiblederivatives 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 obtainedby rectifying the ac voltage, then filtering to a dc level, and finally, regulating to obtain a desiredfixed dc voltage. The regulation is usually obtained from an IC voltage regulator unit, whichtakes a dc voltage and provides a somewhat lower dc voltage, which remains the same even ifthe input dc voltage varies, or the output load connected to the dc voltage changes. Transformer Rectifier Filter IC regulator Load7. 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. Anunregulated 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 forany high-frequency noise). The third IC terminal is connected to ground (GND). While the inputvoltage may vary over some permissible voltage range, and the output load may vary over someacceptable range, the output voltage remains constant within specified voltage variation limits.CONNECTION DIAGRAM: 5
  6. 6. WORKING: 6
  7. 7. The circuit diagram shows the interfacing of the cellular phone with the microcontrollerto communicate with the devices. The cell phone used supports GSM-SMS services. A simpleSMS say “HEATER ON” is sent to this interfaced cell phone. This message can be externallyaccessed using AT commands through SERIAL INTERFACE. AT commands will be explainedin 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 itrequires the line drivers such as MAX232 to convert RS232 voltage levels to TTL levels andvice-versa. For reliable and best serial data transfer we must synchronize microcontroller and the cellphone at a fixed baud rate. The baud rate in the 89c51 is programmable. This is done with thehelp of timer1. Hence the baud rate is set as 9600kbps. The sequence of AT commands that areto 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 phonememory and delete it after reading it.STEP5: when a new message says “HEATER ON” is sent from our mobile this is delivered tothe 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 issensed and the content of the message is received.STEP7: this string received is compared with the already storedstring. If this match occurs the corresponding subroutine isinvoked and the corresponding port pin is made “1”.STEP8: this port is connected to a relay and through this theHEATER is switched ON.FOR SECURITY SYSTEMS: The security system that is used includes an electronic keypad that comprisesof 10 keys numbering (0-9). In the residence absence they canactivate this keypad in which an appropriate code should betyped in. When a person needs to enter the home the code (shouldbe known) should be typed. This code will be sent to the owner’scell phone number through the microcontroller. If the code iscorrect command “OPEN DOOR” is sent. The microcontroller willinterpret this command and opens the door. If the code is wrongthe door will not be opened. All the above authenticationprocess is done by separate subroutine in our program. Thissubroutine is invoked when the keypad is activated. 7
  8. 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 themonitor. 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 preferredstorage newline(); DelayS(2); printf("AT+CNMI=1,2,0,0,0"); // incoming message notification setting newline(); 8
  9. 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 atindex #1 //if there is an SMS at index #1, the phone sends thesms 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. 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 fullyautomated 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. Furtherthe 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
  11. 11. “AT89c51 data sheets”“www.wikipedia.org” 11
  12. 12. “AT89c51 data sheets”“www.wikipedia.org” 11
  13. 13. “AT89c51 data sheets”“www.wikipedia.org” 11
  14. 14. “AT89c51 data sheets”“www.wikipedia.org” 11