You are on page 1of 64

ECE

GSM BASED HOME AUTOMATION SYSTEM

ABSTRACT

This paper mainly focuses on the controlling of home appliances remotely and providing security when the user is away from the place. The system is MOBILE based and uses wireless technology to revolutionize the standards of living. This system provides ideal solution to the problems faced by home owners in daily life. The system is wireless therefore more adaptable and cost-effective. The HACS system provides security against intrusion as well as automates various home appliances using MOBILE. The system uses GSM technology thus providing ubiquitous access to the system for security and automated appliance control. Home automation (also called domotics) is the residential extension of "building automation". It is automation of the home, housework or household activity. Home automation may include centralized control of lighting, HVAC (heating, ventilation and air conditioning), appliances, and other systems, to provide improved convenience, comfort, energy efficiency and security. Disabled can provide increased quality of life for persons who might otherwise require caregivers or institutional care.

KSHATRIYA COLLEGE OF ENGINEERING

Page 1

ECE

GSM BASED HOME AUTOMATION SYSTEM

1. INTRODUCTION

The objective of this project is to develop a device that allows for a user to remotely control and monitor multiple home appliances using a cellular phone. This system will be a powerful and flexible tool that will offer this service at any time, and from anywhere with the constraints of the technologies being applied. Possible target appliances include (but are not limited to) climate control systems, security systems, and lights; anything with an electrical interface. The proposed approach for designing this system is to implement a microcontrollerbased control module that receives its instructions and commands from a cellular phone over the GSM network. The microcontroller then will carry out the issued commands and then communicate the status of a given appliance or device back to the cellular phone. For security purposes, a means of identification and user authentication will be implemented, and will combine caller identification with a password authorization. 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 GSM. 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 (users cell phone).

KSHATRIYA COLLEGE OF ENGINEERING

Page 2

ECE

GSM BASED HOME AUTOMATION SYSTEM

2. BLOCK & SCHEMATIC DIAGRAMS

BLOCK DIAGRAM:

SATELLITE

MOBILE

GSM MODULE

MAX 232 8051


MICRO
CONTROLLER
POWER SUPPLY

DRIVER

RELAY 1 RELAY 2

DEVICE 1 DEVICE 2

LCD DISPLAY

KSHATRIYA COLLEGE OF ENGINEERING

Page 3

ECE

GSM BASED HOME AUTOMATION SYSTEM

SCHEMATIC DIAGRAM:

KSHATRIYA COLLEGE OF ENGINEERING

Page 4

ECE

GSM BASED HOME AUTOMATION SYSTEM

3. WORKING PRINCIPLE
The main motto of using Home Automation is lowering the wastage of time and power with the increasing technology. By using AT commands we would be communicating or bridging the gap between GSM modems. Here we are emphasizing much on the

GLOBAL SYSTEM for MOBILE COMMUNICATIONS because we want to establish the communication over the long distances. Initially micro controller, LCD, passive components GSM modem , diodes, RS 232,MAX 232,drivers are interfaced and programming is based on AT commands is done. 5 AT commands we would be using for READING MESSAGES SENDING MESSAGES WAITING MESSAGES DELETING MESSAGES DISPLAYING MESSAGES By using these commands the GSM modem works. We would be using a GSM modem at one side and the mobile on the other side. MAX 232, RS 232 are used for the serial communication. RS 232 (Recommended Standard 232) we would be using DB-9 type male & female connector. MAX 232 is used to convert RTL logic level voltage to TTL logic level voltage. Driver is used to interface the electronic devices with the micro controller as the microcontroller pins cant be connected directly because of which we are using it. Even a driver is also used to connect more no of electronic devices to single port. Relay is a electromechanical switch. Based on the power supply , magnetic induction takes place by which switching on/off takes place. Sequentially first the c stays in the waiting state and then any one of 5 commands are sent through GSM modem and those commands are serially transmitted by using RS 232 and MAX 232 for converting RTL to TTL logic level voltages and then the c reads the
KSHATRIYA COLLEGE OF ENGINEERING Page 5

ECE

GSM BASED HOME AUTOMATION SYSTEM

code and acts according to the programmed code and enables/disables based on the the instructions and at the same time displays the status of modem, c in a LCD display during the execution of commands.

Micro controller

Lamp Send completion Appliances status

Security system

Send statu s Send statu Cell Phone s

Send statu s Send statu s

Perform

GSM module

Issue command

required instructions

Fan message

Send text
message

Communicate
with network

Decode incoming Send instruction


to appliance

Garage Door

Receive

status message

Transfer data to
microcontroller

Monitor

completion status

Fig: Flow Diagram of Working Principle

KSHATRIYA COLLEGE OF ENGINEERING

Page 6

ECE

GSM BASED HOME AUTOMATION SYSTEM

4. HARDWARE DESCRIPTION
4.1 MICRO CONTROLLER In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually. Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts. 4.1.1 Features: The AT89C51 provides the following standard features: 4Kbytes of Flash 128 bytes of RAM Two 16-bittimer/counters a five vector two-level interrupt architecture a full duplex serial port on-chip oscillator and clock circuitry. 8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz 256 x 8-bit Internal RAM 32 Programmable I/O Lines Eight Interrupt Sources Programmable Serial Channel

KSHATRIYA COLLEGE OF ENGINEERING

Page 7

ECE

GSM BASED HOME AUTOMATION SYSTEM

Low-power Idle and Power-down Modes

In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freeze the oscillator disabling all other chip functions until the next hardware reset.

KSHATRIYA COLLEGE OF ENGINEERING

Page 8

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.1.2 Pin Diagram:

4.1.3 Pin Description: Pin 1-8: Each of these pins can be configured as an input or an output. Pin 9(RS): A logic one on this pin disables the microcontroller and clears the contents of most registers. In other words, the positive voltage on this pin resets the microcontroller. By applying logic zero to this pin, the program starts execution from the beginning. Pin 10-17(Port3): Similar to port 1, each of these pins can serve as general input or output. Besides, all of them have alternative functions: Pin 10: RXD Serial asynchronous communication input or Serial synchronous communication output. Pin 11: TXD Serial asynchronous communication output or Serial synchronous communication clock output.
KSHATRIYA COLLEGE OF ENGINEERING Page 9

ECE

GSM BASED HOME AUTOMATION SYSTEM

Pin 12: INT0 Interrupt 0 input. Pin 13: INT1 Interrupt 1 input. Pin 14: T0 Counter 0 clock input. Pin 15: T1 Counter 1 clock input. Pin 16: WR Write to external (additional) RAM. Pin 17: RD Read from external RAM. Pin 18, 19: X2 ,X1 Internal oscillator input and output. A quartz crystal which specifies operating frequency is usually connected to these pins. Instead of it, miniature ceramics resonators can also be used for frequency stability. Later versions of microcontrollers operate at a frequency of 0 Hz up to over 50 Hz. Pin 20: GND Ground. Pin 21-28: Port2 If there is no intention to use external memory then these port pins are configured as general inputs/outputs. In case external memory is used, the higher address byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is not used, which means that not all eight port bits are used for its addressing, the rest of them are not available as inputs/outputs. Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on it every time the microcontroller reads a byte from memory. Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes the state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As seen, port data multiplexing is performed by means of only one additional (and cheap) integrated circuit. In other words, this port is used for both data and address transmission.

KSHATRIYA COLLEGE OF ENGINEERING

Page 10

ECE

GSM BASED HOME AUTOMATION SYSTEM

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address transmission with no regard to whether there is internal memory or not. It means that even there is a program written to the microcontroller, it will not be executed. Instead, the program written to external ROM will be executed. By applying logic one to the EA pin, the microcontroller will use both memories, first internal then external (if exists). Pin 32-39: Port0 Similar to P2, if external memory is not used, these pins can be used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0). Pin 40: VCC +5V power supply. 4.1.4 INPUT/OUTPUT (I/O) PORTS: All 8051 microcontrollers have 4 I/O ports each comprising 8 bits which can be configured as inputs or outputs. Accordingly, in total of 32 input/output pins enabling the microcontroller to be connected to peripheral devices are available for use. Pin configuration, i.e. whether it is to be configured as an input (1) or an output (0), depends on its logic state. In order to configure a microcontroller pin as an input, it is necessary to apply a logic zero (0) to appropriate I/O port bit. In this case, voltage level on appropriate pin will be 0. Similarly, in order to configure a microcontroller pin as an input, it is necessary to apply a logic one (1) to appropriate port. In this case, voltage level on appropriate pin will be 5V (as is the case with any TTL input). This may seem confusing but don't loose your patience. It all becomes clear after studying simple electronic circuits connected to an I/O pin. Port 0: The P0 port is characterized by two functions. If external memory is used then the lower address byte (addresses A0-A7) is applied on it. Otherwise, all bits of this port are configured as inputs/outputs.

KSHATRIYA COLLEGE OF ENGINEERING

Page 11

ECE

GSM BASED HOME AUTOMATION SYSTEM

Note: Only in case P0 is used for addressing external memory, the microcontroller will provide internal power supply source in order to supply its pins with logic one. There is no need to add external pull-up resistors. Port 1: P1 is a true I/O port, because it doesn't have any alternative functions as is the case with P0, but can be configured as general I/O only. It has a pull-up resistor built-in and is completely compatible with TTL circuits. Port 2: P2 acts similarly to P0 when external memory is used. Pins of this port occupy addresses intended for external memory chip. This time it is about the higher address byte with addresses A8-A15. When no memory is added, this port can be used as a general input/output port showing features similar to P1. Port 3: All port pins can be used as general I/O, but they also have an alternative function. In order to use these alternative functions, a logic one (1) must be applied to appropriate bit of the P3 register. In terms of hardware, this port is similar to P0, with the difference that its pins have a pull-up resistor built-in. Program Counter (PC): The Program Counter is a 16 or 32 bit register which contains the address of the next instruction to be executed The PC automatically increments to the next sequential memory location every time an instruction is fetched. Branch, jump, and interrupt operations load the Program Counter with an address other than the next sequential location. During reset, the PC is loaded from a pre-defined memory location to signify the starting address of the code.

KSHATRIYA COLLEGE OF ENGINEERING

Page 12

ECE

GSM BASED HOME AUTOMATION SYSTEM

Interrupts: Interrupts are mostly hardware mechanisms which tell the program an event has occurred. They happen at any time, and are therefore asynchronous to program flow. They require special handling by the processor, and are ultimately handled by a corresponding Interrupt Service Routine (ISR) Need to be handled quickly. Take too much time servicing an interrupt, and you may miss. Memory Organization: The 8051 has two types of memory and these are Program Memory and Data Memory. Program Memory (ROM) is used to permanently save the program being executed, while Data Memory (RAM) is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Depending on the model in use (we are still talking about the 8051 microcontroller family in general) at most a few Kb of ROM and 128 or 256 bytes of RAM is used. HoweverAll 8051 microcontrollers have a 16bit addressing bus and are capable of addressing 64 kb memory. It is neither a mistake nor a big ambition of engineers who were working on basic core development. It is a matter of smart memory organization which makes these microcontrollers a real programmers goody. Program Memory: The first models of the 8051 microcontroller family did not have internal program memory. It was added as an external separate chip. These models are recognizable by their label beginning with 803 (for example 8031 or 8032). All later models have a few Kbyte ROM embedded. Even though such an amount of memory is sufficient for writing most of the programs, there are situations when it is necessary to use additional memory as well. A typical example are so called lookup tables. They are used in cases when equations describing some processes are too complicated or when there is no time for solving them. EA=0 In this case, the microcontroller completely ignores internal program memory and executes only the program stored in external memory.

KSHATRIYA COLLEGE OF ENGINEERING

Page 13

ECE

GSM BASED HOME AUTOMATION SYSTEM

EA=1 in this case, the microcontroller executes first the program from built-in ROM, then the program stored in external memory. In both cases, P0 and P2 are not available for use since being used for data and address transmission. Besides, the ALE and PSEN pins are also used. Data Memory: As already mentioned, Data Memory is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Besides, RAM memory built in the 8051 family includes many registers such as hardware counters and timers, input/output ports, serial data buffers etc. The previous models had 256 RAM locations, while for the later models this number was incremented by additional 128 registers. However, the first 256 memory locations (addresses 0-FFh) are the heart of memory common to all the models belonging to the 8051 family. Locations available to the user occupy memory space with addresses 0-7Fh, i.e. first 128 registers. This part of RAM is divided in several blocks. The first block consists of 4 banks each including 8 registers denoted by R0-R7. Prior to accessing any of these registers, it is necessary to select the bank containing it. The next memory block (address 20h-2Fh) is bit- addressable, which means that each bit has its own address (0-7Fh). Since there are 16 such registers, this block contains in total of 128 bits with separate addresses (address of bit 0 of the 20h byte is 0, while address of bit 7 of the 2Fh byte is 7Fh). The third groups of registers occupy addresses 2Fh-7Fh, i.e. 80 locations, and do not have any special functions or features. Additional RAM: In order to satisfy the programmers constant hunger for Data Memory, the manufacturers decided to embed an additional memory block of 128 locations into the latest versions of the 8051 microcontrollers. However, its not as simple as it seems to be The problem is that electronics performing addressing has 1 byte (8 bits) on disposal and is capable of reaching only the first 256 locations, therefore. In order to keep already existing 8bit architecture and compatibility with other existing models a small trick was done.

KSHATRIYA COLLEGE OF ENGINEERING

Page 14

ECE

GSM BASED HOME AUTOMATION SYSTEM

What does it mean? It means that additional memory block shares the same addresses with locations intended for the SFRs (80h- FFh). In order to differentiate between these two physically separated memory spaces, different ways of addressing are used. The SFRs memory locations are accessed by direct addressing, while additional RAM memory locations are accessed by indirect addressing

4.1.5 Addressing: While operating, the processor processes data as per program instructions. Each instruction consists of two parts. One part describes WHAT should be done, while the other explains HOW to do it. The latter part can be a data (binary number) or the address at which the data is stored. Two ways of addressing are used for all 8051 microcontrollers depending on which part of memory should be accessed:

KSHATRIYA COLLEGE OF ENGINEERING

Page 15

ECE

GSM BASED HOME AUTOMATION SYSTEM

Direct Addressing: On direct addressing, the address of memory location containing data to be read is specified in instruction. The address may contain a number being changed during operation (variable). For example: Since the address is only one byte in size (the largest number is 255), only the first 255 locations of RAM can be accessed this way. The first half of RAM is available for use, while another half is reserved for SFRs. MOV A,33h ; Means: move a number from address 33 hex. To accumulator Indirect Addressing: On indirect addressing, a register containing the address of another register is specified in instruction. Data to be used in the program is stored in the letter register. For example: Indirect addressing is only used for accessing RAM locations available for use (never for accessing SFRs). This is the only way of accessing all the latest versions of the microcontrollers with additional memory block (128 locations of RAM). Simply put, when the program encounters instruction including @ sign and if the specified address is higher than 128 (7F hex.), the processor knows that indirect addressing is used and skips memory space reserved for SFRs. MOV A, @R0; Means: Store the value from the register whose address is in the R0 register into accumulator. On indirect addressing, registers R0, R1 or Stack Pointer are used for specifying 8-bit addresses. Since only 8 bits are available, it is possible to access only registers of internal RAM this way (128 locations when speaking of previous models or 256 locations when speaking of latest models of microcontrollers). If an extra memory chip is added then the 16bit DPTR Register (consisting of the registers DPTRL and DPTRH) is used for specifying address. In this way it is possible to access any location in the range of 64K.

KSHATRIYA COLLEGE OF ENGINEERING

Page 16

ECE

GSM BASED HOME AUTOMATION SYSTEM

Special Function Registers (SFRs): Special Function Registers (SFRs) are a sort of control table used for running and monitoring the operation of the microcontroller. Each of these registers as well as each bit they include, has its name, address in the scope of RAM and precisely defined purpose such as timer control, interrupt control, serial communication control etc. Even though there are 128 memory locations intended to be occupied by them, the basic core, shared by all types of 8051 microcontrollers, has only 21 such registers. Rest of locations is intentionally left unoccupied in order to enable the manufacturers to further develop microcontrollers keeping them compatible with the previous versions. It also enables programs written a long time ago for microcontrollers which are out of production now to be used today. A Register (Accumulator): A register is a general-purpose register used for storing intermediate results obtained during operation. Prior to executing an instruction upon any number or operand it is necessary to store it in the accumulator first. All results obtained from arithmetical operations performed by the ALU are stored in the accumulator. Data to be moved from one register to another must go through the accumulator. In other words, the A register is the most commonly used register and it is impossible to imagine a microcontroller without it. More than half instructions used by the 8051 microcontroller use somehow the accumulator. B Register: Multiplication and division can be performed only upon numbers stored in the A and B registers. All other instructions in the program can use this register as a spare accumulator (A). 4.1.7 Program Status Word (PSW) Register: CF
D7

AF
D6

F0
D5

RS1 RS0 OV
D4 D3 D2

D1

PF
D0

PSW register is one of the most important SFRs. It contains several status bits that reflect the current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit and user-definable status flag.
KSHATRIYA COLLEGE OF ENGINEERING Page 17

ECE

GSM BASED HOME AUTOMATION SYSTEM

PF - Parity bit. If a number stored in the accumulator is even then this bit will be automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via serial communication. - Bit 1. This bit is intended to be used in the future versions of microcontrollers. OV Overflow occurs when the result of an arithmetical operation is larger than 255 and cannot be stored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared (0). RS0, RS1 - Register bank select bits. These two bits are used to select one of four register banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of RAM.

RS1 RS2 0 0 1 1 0 1 0 1

Space in RAM Bank0 00h-07h Bank1 08h-0Fh Bank2 10h-17h Bank3 18h-1Fh

F0 - Flag 0. This is a general-purpose bit available for use. AF - Auxiliary Carry Flag is used for BCD operations only. CF - Carry Flag is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions. Data Pointer Register (DPTR): DPTR register is not a true one because it doesn't physically exist. It consists of two separate registers: DPH (Data Pointer High) and (Data Pointer Low). For this reason it may be treated as a 16-bit register or as two independent 8-bit registers. Their 16 bits are primarily

KSHATRIYA COLLEGE OF ENGINEERING

Page 18

ECE

GSM BASED HOME AUTOMATION SYSTEM

used for external memory addressing. Besides, the DPTR Register is usually used for storing data and intermediate results. Stack Pointer (SP) Register: A value stored in the Stack Pointer points to the first free stack address and permits stack availability. Stack pushes increment the value in the Stack Pointer by 1. Likewise, stack pops decrement its value by 1. Upon any reset and power-on, the value 7 is stored in the Stack Pointer, which means that the space of RAM reserved for the stack starts at this location. If another value is written to this register, the entire Stack is moved to the new memory location. Counters and Timers: As you already know, the microcontroller oscillator uses quartz crystal for its operation. As the frequency of this oscillator is precisely defined and very stable, pulses it generates are always of the same width, which makes them ideal for time measurement. Such crystals are also used in quartz watches. In order to measure time between two events it is sufficient to count up pulses coming from this oscillator. That is exactly what the timer does. If the timer is properly programmed, the value stored in its register will be incremented (or decremented) with each coming pulse, i.e. once per each machine cycle. A single machinecycle instruction lasts for 12 quartz oscillator periods, which means that by embedding quartz with oscillator frequency of 12MHz, a number stored in the timer register will be changed million times per second, i.e. each microsecond.The 8051 microcontroller has 2 timers/counters called T0 and T1. As their names suggest, their main purpose is to measure time and count external events. Besides, they can be used for generating clock pulses to be used in serial communication, so called Baud Rate.

TIMER HIGH
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5

TIMER LOW
D4 D3 D2 D1 D0

KSHATRIYA COLLEGE OF ENGINEERING

Page 19

ECE

GSM BASED HOME AUTOMATION SYSTEM

Timer T0: As seen in figure below, the timer T0 consists of two registers TH0 and TL0 representing a low and a high byte of one 16-digit binary number.

TH0

TL0

D7

D6

D5

D4

D3

D2

D1

D0

Timer T1: As seen in figure below, the timer T1 consists of two registers TH1 and TL1 representing a low and a high byte of one 16-digit binary number.
TH1 TL1

D7 TMOD: Timer Mode:

D6

D5

D4

D3

D2

D1

D0

T1 Gate C/T M1
D7 D6 D5

T0 M0
D4

Gate C/T M1
D3 D2 D1

M0
D0

The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to the timer 1. There are 4 operational modes and each of them is described herein. Bits of this register have the following function:

GATE1 enables and disables Timer 1 by means of a signal brought to the INT1 pin (P3.3):
o o

1 - Timer 1 operates only if the INT1 bit is set. 0 - Timer 1 operates regardless of the logic state of the INT1 bit.

C/T1 selects pulses to be counted up by the timer/counter 1:


o o

1 - Timer counts pulses brought to the T1 pin (P3.5). 0 - Timer counts pulses from internal oscillator.

These two bits select the operational mode of the Timer 1.

KSHATRIYA COLLEGE OF ENGINEERING

Page 20

ECE

GSM BASED HOME AUTOMATION SYSTEM

GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2):
o o

1 - Timer 0 operates only if the INT0 bit is set. 0 Timer 0 operates regardless of the logic state of the INT0 bit.

T1M1 T1M0 MODE DESCRIPTION 0 0 1 1 0 1 0 1 0 1 2 3 13 bit register 16 bit register 8bit auto reload 8 bit split timer

C/T0 selects pulses to be counted up by the timer/counter 0:


o o

1 - Timer counts pulses brought to the T0 pin (P3.4). 0 - Timer counts pulses from internal oscillator.

T0M1,T0M0 These two bits select the operational mode of the Timer 0.

TCON: Time Control TCON register is also one of the registers whose bits are directly in control of timer operation. Only 4 bits of this register are used for this purpose, while rest of them is used for interrupt control to be discussed later.

TF1 bit is automatically set on the Timer 1 overflow. TR1 bit enables the Timer 1.
o o

1 - Timer 1 is enabled. 0 - Timer 1 is disabled.

TF0 bit is automatically set on the Timer 0 overflow. TR0 bit enables the timer 0.
o o

1 - Timer 0 is enabled. 0 - Timer 0 is disabled.

KSHATRIYA COLLEGE OF ENGINEERING

Page 21

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.2 POWER SUPPLY UNIT


4.2.1 Introduction:
The microcontroller and other devices get power supply from AC to Dc adapter through 7805, 5 volts regulator. The adapter output voltage will be 12V DC non-regulated. The 7805/7812 voltage regulators are used to convert 12 V to 5V/12V DC.

The power supply unit is used to provide constant 5 V dc supply to the peripherals. The 230 V ac is converted into 9 V ac by using a transformer and then a bridge rectifier rectifies it to a 9 V dc with ac ripples. This is then filtered by electrolytic capacitors used across the rectifier output. LM7805 regulator is employed to obtain a constant 5 V dc at the output. . The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the Output pin.

KSHATRIYA COLLEGE OF ENGINEERING

Page 22

ECE

GSM BASED HOME AUTOMATION SYSTEM

Fig: POWER SUPPLY CIRCUIT

4.2.2 Circuit Features:


Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot Circuit complexity: Very simple and easy to build Circuit performance: Very stable +5V output voltage, reliable operation Availability of components: Easy to get, uses only very common basic components Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects Applications: Part of electronics devices, small laboratory power supply Power supply voltage: Unregulated DC 8-18V power supply Power supply current: Needed output current + 5 mA Component costs: Few dollars for the electronics components + the input transformer cost

KSHATRIYA COLLEGE OF ENGINEERING

Page 23

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.3 LCD (Liquid Crystal Display)


4.3.1 Introduction: LCD stands for Liquid Crystal Display. The most commonly used LCDs found in the market today are 1 line, 2 line or 4 line LCDs which have only one controller and support at most 80 characters.

Liquid crystal display a type of display used in digital watches and many portable computers.LCD displays utilize two sheets of polarizing material with a liquid crystal solution between them. The liquid crystals can be manipulated through an applied electric voltage so that light is allowed to pass or is blocked. By carefully controlling where and what wavelength (color) of light is allowed to pass, the LCD monitor is able to display images. A back light provides LCD monitors brightness. Response time is basically the amount of time it takes for a pixel to change colors. In reality response time is the amount of time it takes a liquid crystal cell to go from being active to inactive Here the LCD is used at both the Transmitter as well as the receiver side. The input which we give to the microcontroller is displayed on the LCD of the transmitter side and the message sent is received at the receiver side which displays at the receiver end of the LCD and the corresponding operation is performed. They make

complicated equipment easier to operate. LCDs come in many shapes and sizes but the most common is the 16 character x 4 line display with no backlight. It requires only 11 connections eight bits for data (which can be reduced to four if necessary) and three control lines (we

KSHATRIYA COLLEGE OF ENGINEERING

Page 24

ECE

GSM BASED HOME AUTOMATION SYSTEM

have only used two here). It runs off a 5V DC supply and only needs about 1mA of current. The display contrast can be varied by changing the voltage into pin 3 of the display. Pin Description of LCD:

Pins 1 2 3 4 5 6 7 8 9 10 11 12 13 14

SYMBOL Vss Vcc Vee RS R/W EN DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7

I/0 ---I I I/O I/O I/O I/O I/O I/O I/O I/O I/O

DESCRIPTION Ground VCC Constrast Voltage RS = 0 to Select Command Register RS = 1 to Select Data Register R/W = 0 for Write R/W = 1 for Read Enable 8-Bit Data Bus 8-Bit Data Bus 8-Bit Data Bus 8-Bit Data Bus 8-Bit Data Bus 8-Bit Data Bus 8-Bit Data Bus 8-Bit Data Bus

4.3.2 Interfacing LCD with Micro Controller:

KSHATRIYA COLLEGE OF ENGINEERING

Page 25

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.4 RS 232 (Recommended Standard)


The RS-232 interface is the Electronic Industries Association (EIA) standard for the interchange of serial binary data between two devices. It was initially developed by the EIA to standardize the connection of computers with telephone line modems. The standard

allows as many as 20 signals to be defined, but gives complete freedom to the user. Three wires are sufficient: send data, receive data, and signal ground. The remaining lines can be hardwired on or off permanently. The signal transmission is bipolar, requiring two voltages, from 5 to 25 volts, of opposite polarity. RS 232 Pin Description:

KSHATRIYA COLLEGE OF ENGINEERING

Page 26

ECE

GSM BASED HOME AUTOMATION SYSTEM

The standard voltage range on RS-232 pins is _15V to +15V. This voltage range applies to all RS-232 signal pins. The total voltage swing during signal transmission can be as large as 30V. In many cases, RS-232 ports will operate with voltages as low as _5V to +5V. This wide range of voltages allows for better compatibility between different types of equipment and allows greater noise margin to avoid interference. Because the voltage swing on RS-232 lines is so large, the RS-232 signal lines generate a significant amount of electrical noise. It is important that this signal does not run close to high impedance microphone lines or audio lines in a system. In cases where you must run these types of signals nearby one another, it is important to make sure that all audio wires are properly shielded. The main role of the RS232 chip is to convert the data coming for the 12-volt logic to 5 volt logic and from 5 volt logic to 12 volt logic.

RS 232 Male & Female Connectors:

KSHATRIYA COLLEGE OF ENGINEERING

Page 27

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.5 MAX 232


MAX232 is compatible with RS-232 standard, and consists of dual transceiver. Each receiver converts TIA/EIA-232-E levels into 5V TTL/CMOS levels. Each driver converts TTL/ COMS levels into TIA/EIA-232-E levels. The MAX232 is characterized for operation from -40C to +85C for all packages. MAX232 is purposed for application in high-performance information processing systems and control devices of wide application

4.5.1 Features : Input voltage levels are compatible with standard MOS levels Output voltage levels are compatible with EIA/TIA-232-E levels Single Supply voltage: 5V Low input current: 0.1A at A= 25 Output current: 24mA Latching current not less than 450mA at A= 25 The transmitter outputs and receiver inputs are protected to }15kV Air ESD

4.5.2 Pin Diagram:

KSHATRIYA COLLEGE OF ENGINEERING

Page 28

ECE

GSM BASED HOME AUTOMATION SYSTEM

Pin Description :

S. NO. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Name C1+ V+ C1C2+ C2VT2OUT R2IN R2OUT T2IN T1IN R1OUT R1IN T1OUT GND VCC

Function External capacitance of positive voltage multiplier unit Output of positive voltage of multiplier unit External capacitance of positive voltage multiplier unit External capacitance of negative voltage multiplier unit External capacitance of negative voltage multiplier unit Output of negative voltage of multiplier unit Output of transmitter data (levels RS 232) Input of receiver data (levels RS 232) Output of receiver data (levels TTL/CMOS) Input of transmitter data (levels TTL/CMOS) Input of transmitter data (levels TTL/CMOS) Output of receiver data (levels TTL/CMOS) Input of receiver data (levels RS 232) Output of transmitter data (levels RS 232) Ground Supply voltage

Internal Circuit Diagram:

KSHATRIYA COLLEGE OF ENGINEERING

Page 29

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.5.3 Interfacing Diagram between RS232, MAX 232 & Microcontroller:

KSHATRIYA COLLEGE OF ENGINEERING

Page 30

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.6 RELAY
A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism mechanically, but other operating principles are also use .relays are used where it is necessary to control a circuit by a low power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal.

Fig 1: Relay Internal circuit

Fig 2: 5v dc Relay

A relay is an electrically operated switch .current flowing through the coil of the relay a creates magnetic field which attracts a lever and changes the switch contacts .the coil current can be on or off so relay have two switch position and most have double throw (changeover ) switch contacts as shown in the diagram . The figure shows a relay with its coil and switch contacts .you can see a lever on the left being attracted by magnetism when the coil is switched on. This lever moves the switch contacts.

KSHATRIYA COLLEGE OF ENGINEERING

Page 31

ECE

GSM BASED HOME AUTOMATION SYSTEM

Applications of relays:

1. Control a high voltage circuit with a low voltage signal, as is some type of modems or audio amplifiers 2. Control a high current circuit with a low current signal, as in the starter solenoid of an automobile.

Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC. Relays can switch higher voltages than standard transistors. Relays are often a better choice for switching large currents (> 5A). Relays can switch many contacts at once.

Disadvantages of relays:

Relays are bulkier than transistors for switching small currents. Relays cannot switch rapidly (except reed relays), transistors can switch many times per second.

Relays use more power due to the current flowing through their coil. Relays require more current than many ICs can provide, so a low power transistor may be needed to switch the current for the relay's coil.

KSHATRIYA COLLEGE OF ENGINEERING

Page 32

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.7 DRIVER (ULN 2804)


The eight NPN Darlington connected transistors in this family of arrays are ideally suited for interfacing between low logic level digital circuitry (such as TTL, CMOS or PMOS/NMOS) and the higher current/voltage requirements of lamps, relays, printer hammers or other similar loads for a broad range of computer, industrial, and consumer applications. All devices feature opencollector outputs and freewheeling clamp diodes for transient suppression. Pin Description:

Pin 1-8: Inputs pins for 1-8 channels Pin 11-18: Output pins for 1-8 channels Pin 9: Ground Pin 10: Common Free Wheeling Diodes

Internal circuit of ULN 2804 DRIVER:

KSHATRIYA COLLEGE OF ENGINEERING

Page 33

ECE

GSM BASED HOME AUTOMATION SYSTEM

4.8 GSM MODULE

Definition: Global system for mobile communication (GSM) is a globally accepted standard for digital cellular communication. GSM is the name of a standardization group established in 1982 to create a common European mobile telephone standard that would formulate specifications for a pan-European mobile cellular radio system operating at 900 MHz It is estimated that many countries outside of Europe will join the GSM partnership. Introduction: Cellular is one of the fastest growing and most demanding telecommunications applications. Today, it represents a continuously increasing percentage of all new telephone subscriptions around the world. Currently there are more than 45 million cellular subscribers worldwide, and nearly 50 percent of those subscribers are located in the United States. It is forecasted that cellular systems using a digital technology will become the universal method of telecommunications. By the year 2005, forecasters predict that there will be more than 100 million cellular subscribers worldwide.

Graph : Cellular Subscriber Growth Worldwide

KSHATRIYA COLLEGE OF ENGINEERING

Page 34

ECE

GSM BASED HOME AUTOMATION SYSTEM

GSM: Throughout the evolution of cellular telecommunications, various systems have been developed without the benefit of standardized specifications. This presented many problems directly related to compatibility, especially with the development of digital radio technology. The GSM standard is intended to address these problems. Why has GSM been successful? The success of GSM is that its development was founded on the delivery of a specific user benefit international roaming. The demands of international roaming had profound changes on GSMs architecture and mandated an open future-proof standard that ensured interoperability, without stifling competition, and innovation among suppliers. This lowered barriers to entry, promoted compatibility between systems which, in turn, lowered development costs and set the stage for better choice and innovation. The unparalleled economies of scale and competition that resulted brought convenience and falling prices to manufacturers, network operators and consumers. The adoption of a digital system offered improved mobility, spectrum efficiency, better quality transmission and new services over the first generation systems. The use of Very Large Scale Integration (VLSI) microprocessor technology and other low-cost IC architectures paved the way for more efficient and affordable pocket-sized mobile phones. This resulted in a profound change in users mobile communication style from vehicular based to personal, opportunity-based communications. Although GSM is only one of the pieces in the cluster of current and future telecommunications networks, its ability to provide anytime, and almost anywhere, communications has resulted in tremendous economic and social consequences. Without GSM the pace of development of mobile telephony would have pared dramatically and that additional revenue streams, such as roaming would not have been as successful.

KSHATRIYA COLLEGE OF ENGINEERING

Page 35

ECE

GSM BASED HOME AUTOMATION SYSTEM

The GSM Network: GSM provides recommendations, not requirements. The GSM specifications define the functions and interface requirements in detail but do not address the hardware. The reason for this is to limit the designers as little as possible but still to make it possible for the operators to buy equipment from different suppliers. The GSM network is divided into three major systems: the switching system (SS), the base station system (BSS), and the operation and support system (OSS). The basic GSM network elements are shown.

Fig: GSM modem

KSHATRIYA COLLEGE OF ENGINEERING

Page 36

ECE

GSM BASED HOME AUTOMATION SYSTEM

Figure 5.11: GSM Network Elements

The Switching System: The switching system is responsible for performing call processing and subscriberrelated functions. The switching system includes the following functional units. Home location registers (HLR)The HLR is a database used for storage and management of subscriptions. The HLR is considered the most important database, as it stores permanent data about subscribers, including a subscriber's service profile, location information, and activity status. When an individual buys a subscription from one of the PCS operators, he or she is registered in the HLR of that operator. Mobile services switching center (MSC)The MSC performs the telephony switching functions of the system. It controls calls to and from other telephone and data systems. It also performs such functions as toll ticketing, network interfacing, common channel signaling, and others.

KSHATRIYA COLLEGE OF ENGINEERING

Page 37

ECE

GSM BASED HOME AUTOMATION SYSTEM

Visitor location registers (VLR)The VLR is a database that contains temporary information about subscribers that is needed by the MSC in order to service visiting subscribers. The VLR is always integrated with the MSC. When a mobile station roams into a new MSC area, the VLR connected to that MSC will request data about the mobile station from the HLR. Later, if the mobile station makes a call, the VLR will have the information needed for call setup without having to interrogate the HLR each time. Authentication center (AUC)A unit called the AUC provides authentication and encryption parameters that verify the user's identity and ensure the confidentiality of each call. The AUC protects network operators from different types of fraud found in today's cellular world. Equipment identity register (EIR)The EIR is a database that contains information about the identity of mobile equipment that prevents calls from stolen, unauthorized, or defective mobile stations. The AUC and EIR are implemented as stand-alone nodes or as a combined AUC/EIR node. The Base Station System (BSS): All radio-related functions are performed in the BSS, which consists of base station controllers (BSCs) and the base transceiver stations (BTSs).

BSCThe BSC provides all the control functions and physical links between the MSC and BTS. It is a high-capacity switch that provides functions such as handover, cell configuration data, and control of radio frequency (RF) power levels in base transceiver stations. A number of BSCs are served by an MSC.

BTSThe BTS handles the radio interface to the mobile station. The BTS is the radio equipment (transceivers and antennas) needed to service each cell in the network. A group of BTSs are controlled by a BSC.

The Operation and Support System: The operations and maintenance center (OMC) is connected to all equipment in the switching system and to the BSC. The implementation of OMC is called the operation and support system (OSS). The OSS is the functional entity from which the network operator

KSHATRIYA COLLEGE OF ENGINEERING

Page 38

ECE

GSM BASED HOME AUTOMATION SYSTEM

monitors and controls the system. The purpose of OSS is to offer the customer cost-effective support for centralized, regional, and local operational and maintenance activities that are required for a GSM network. An important function of OSS is to provide a network overview and support the maintenance activities of different operation and maintenance organizations. GSM Subscriber Services: There are two basic types of services offered through GSM: telephony (also referred to as teleservices) and data (also referred to as bearer services). Telephony services are mainly voice services that provide subscribers with the complete capability (including necessary terminal equipment) to communicate with other subscribers. Data services provide the capacity necessary to transmit appropriate data signals between two access points creating an interface to the network. In addition to normal telephony and emergency calling, the following subscriber services are supported by GSM,

Dual-tone multi frequency (DTMF)DTMF is a tone signaling scheme often used for various control purposes via the telephone network, such as remote control of an answering machine. GSM supports full-originating DTMF.

Facsimile group IIIGSM supports CCITT Group 3 facsimile. As standard fax machines are designed to be connected to a telephone using analog signals, a special fax converter connected to the exchange is used in the GSM system. This nables a GSMconnected fax to communicate with any analog fax in the network.

Short message servicesA convenient facility of the GSM network is the short message service. A message consisting of a maximum of 160 alphanumeric characters can be sent to or from a mobile station. This service can be viewed as an advanced form of alphanumeric paging with a number of advantages. If the subscriber's mobile unit is powered off or has left the coverage area, the message is stored and offered back to the subscriber when the mobile is powered on or has reentered the coverage area of the network. This function ensures that the message will be received.

Cell broadcastA variation of the short message service is the cell broadcast facility. A message of a maximum of 93 characters can be broadcast to all mobile subscribers in a certain geographic area. Typical applications include traffic congestion warnings and reports on accidents.

KSHATRIYA COLLEGE OF ENGINEERING

Page 39

ECE

GSM BASED HOME AUTOMATION SYSTEM

Voice mailThis service is actually an answering machine within the network, which is controlled by the subscriber. Calls can be forwarded to the subscriber's voice-mail box and the subscriber checks for messages via a personal security code.

Fax mailWith this service, the subscriber can receive fax messages at any fax machine. The messages are stored in a service center from which they can be retrieved by the subscriber via a personal security code to the desired fax number

GSM Advantages as Perceived by Proponents:

Already deployed as a worldwide standard


o o

35 million subscribers today 150 million subscribers in 1999 (est.), outnumbering CDMA 7 to 1

National/International roaming
o

PCS1900 architecture supports full network interoperability

Total system specified in standard


o o o

CDMA is just an air interface Enhanced full rate vocoder (13 Kbps)

Subscriber Identity Module (SIM) card


o o o

Increased flexibility and utility Allows worldwide roaming Stores personal phone numbers, missed calls, voice mail notification, text messages

GSMS Economic Impact: It is estimated that global subscribers will exceed 1.5bn in 2004 and reach 2.3bn by 2010. And expectations are that at least 85% of the world's next-generation wireless customers utilize the GSM family of technologies for both voice and data services. Mobile network operator revenues alone totaled $426bn in 2003 (based on current exchange rates), an increase of 19% versus 2002. Beliefs are that GSM accounted for 65% of this total.

KSHATRIYA COLLEGE OF ENGINEERING

Page 40

ECE

GSM BASED HOME AUTOMATION SYSTEM

Returns analysis suggests that the sector is highly profitable. In addition, estimates are that mobile telephony has created 4.1m jobs worldwide and within this GSM itself accounts for 75%. GSMs social impact: Probably no single telecommunication system in recent history has had as profound an impact on global society than the GSM mobile phone. Its unprecedented growth in the world has paved the way for increased mobile telephone usage and brought badly needed modern telecommunications services to undeserved communities in the developing world. GSMs future key success factors (KSFs): Over the next five years, several KSFs for the mobile industry will influence the market as we transition to the new 3G environment. These include: Enabling convergence with other wireless technologies Developing mobile centric applications Evolving the mobile business model Introducing mobile terminal enhancements and variety Fostering industry partnerships and co-operations Interoperability and intergenerational roaming between various platforms

GSM Specifications
RF Spectrum GSM 900 GSM 1800 Mobile to BTS (uplink): 1710-1785 MHz BTS to Mobile (downlink) 1805-1880 MHz Mobile to BTS (uplink): 890-915 MHz BTS to Mobile(downlink):935-960 MHz

KSHATRIYA COLLEGE OF ENGINEERING

Page 41

ECE

GSM BASED HOME AUTOMATION SYSTEM

Characteristics of GSM Standard


Fully digital system using 900, 1800 MHz frequency band. TDMA over radio carriers (200 KHz carrier spacing). 8 full rate or 16 half rate TDMA channels per carrier. User/terminal authentication for fraud control. Encryption of speech and data transmission over the radio path. Full international roaming capability. Low speed data services (up to 9.6 Kb/s). Support of Short Message Service (SMS).

Combining AT commands on the same command line: You can enter several AT commands on the same line. In this case, you do not need to type the AT or at prefix before every command. Instead, you only need type AT or or at the beginning of the command line. Please note to use a semicolon as command delimiter. The command line buffer can accept a maximum of 256 characters. If the characters entered exceeded this number then none of the command will executed and TA will returns ERROR. Entering successive AT commands on separate lines When you need to enter a series of AT commands on separate lines, please note that you need to wait the final response (for example OK, CME error, CMS error) of last AT command you entered before you enter the next AT command. Types of AT commands and responses:

Table.1: AT command

KSHATRIYA COLLEGE OF ENGINEERING

Page 42

ECE

GSM BASED HOME AUTOMATION SYSTEM

5. SOFTWARE & CODING


Operating System: WINDOWS XP Software Used: KEIL, MICRO C FLASH, EXPRESS PCB

5.1 KEIL Software: 5.1.1 Installing the Keil software on a Windows PC: Insert the CD-ROM in your computers CD drive On most computers, the CD will auto run, and you will see the Keil installation menu. If the menu does not appear, manually double click on the Setup icon, in the root directory: you will then see the Keil menu. On the Keil menu, please select Install Evaluation Software. (You will not require a license number to install this software). Follow the installation instructions as they appear.

5.1.2 Loading the Projects: The example projects for this book are NOT loaded automatically when you install the Keil compiler. These files are stored on the CD in a directory /Pont. The files are arranged by chapter: for example, the project discussed in Chapter 3 is in the directory /Pont/Ch03_00-Hello. Rather than using the projects on the CD (where changes cannot be saved), please copy the files from CD onto an appropriate directory on your hard disk. Note: you will need to change the file properties after copying: file transferred from the CD will be read only. 5.1.3 Configuring the Simulator: 1. Open the Keil Vision2 2. Go to Project Open Project and browse for Hello in Ch03_00 in Pont and open it. 3. Go to Project Select Device for Target Target1 4. Select 8052(all variants) and click OK
KSHATRIYA COLLEGE OF ENGINEERING Page 43

ECE

GSM BASED HOME AUTOMATION SYSTEM

5. Now we need to check the oscillator frequency 6. Go to project Options for Target Target1 7. Make sure that the oscillator frequency is 11.5902MHz. 8. Building the Target: 9. Build the target as illustrated in the figure below 10. Running the Simulation 11. Having successfully built the target, we are now ready to start the debug session and run the simulator. 12. First start a debug session 13. The flashing LED we will view will be connected to Port 1. We therefore want to observe the activity on port 14. To ensure that the port activity is visible, we need to start the periodic window update flag 15. Go to Debug - Go 16. While the simulation is running, view the performance analyzer to check the delay durations. 17. Go to Debug Performance Analyzer and click on it 18. Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button

KSHATRIYA COLLEGE OF ENGINEERING

Page 44

ECE

GSM BASED HOME AUTOMATION SYSTEM

CODING: ORG 00H MOV SCON,#50H MOV TMOD,#20H MOV TH1,#-3 MOV TL1,#-3 SETB TR1 MOV P0,#00H LCALL INIT_LCD MOV DPTR,#LCD_TEST LCALL LCD_PRINT MOV DPTR,#ATE0 LCALL SERIAL_PRINT LINE1: ACALL RX CJNE A,#0AH,LINE1

LINE11:

ACALL RX CJNE A,#0AH,LINE11 MOV DPTR,#ATE0_SENT LCALL LCD_PRINT MOV DPTR,#CNMI LCALL SERIAL_PRINT

LINE2:

ACALL RX

KSHATRIYA COLLEGE OF ENGINEERING

Page 45

ECE

GSM BASED HOME AUTOMATION SYSTEM

CJNE A,#0AH,LINE2 LINE22: ACALL RX CJNE A,#0AH,LINE22 MOV DPTR,#CNMI_SENT LCALL LCD_PRINT MOV DPTR,#CMGF LCALL SERIAL_PRINT

LINE3:

ACALL RX CJNE A,#0AH,LINE3

LINE33:

ACALL RX CJNE A,#0AH,LINE33 MOV DPTR,#CMGF_SENT LCALL LCD_PRINT LCALL MSG_DELETE1

READ_MSG: MOV DPTR,#RD_MSG LCALL LCD_PRINT MOV DPTR,#CMGR LCALL SERIAL_PRINT

LINE4:

ACALL RX CJNE A,#0AH,LINE4 ACALL RX CJNE A,#'E',CH1 LJMP NO_MSG

KSHATRIYA COLLEGE OF ENGINEERING

Page 46

ECE

GSM BASED HOME AUTOMATION SYSTEM

CH1:

CJNE A,#'+',NO_MSG LJMP CH2

NO_MSG: LINE44: ACALL RX CJNE A,#0AH,LINE44

MOV DPTR,#NO_NEW_MSG LCALL LCD_PRINT LJMP READ_MSG

CH2:

LCALL RX CJNE A,#'+',CH2 MOV R0,#50H

NUM_SAVE: CLR A LCALL RX MOV @R0,A INC R0 CJNE A,#'"',NUM_SAVE

W_EN: ACALL RX CJNE A,#0AH,W_EN MOV R0,#70H MSG_SAVE: CLR A

KSHATRIYA COLLEGE OF ENGINEERING

Page 47

ECE

GSM BASED HOME AUTOMATION SYSTEM

LCALL RX MOV @R0,A INC R0 CJNE A,#0AH,MSG_SAVE MOV DPTR,#MSG_RECEIVED LCALL LCD_PRINT

COMPARE: MOV R0,#50H MOV DPTR,#ORG_NUM

LOOP:

CLR A MOVC A,@A+DPTR JZ OK MOV B,@R0 CJNE A,B,NOT_MATCH INC DPTR INC R0 SJMP LOOP

NOT_MATCH: MOV DPTR,#MISS_MATCH LCALL LCD_DISPLAY LCALL MSG_DELETE LJMP READ_MSG

OK:

MOV DPTR,#NUM_MATCH LCALL LCD_DISPLAY

KSHATRIYA COLLEGE OF ENGINEERING

Page 48

ECE

GSM BASED HOME AUTOMATION SYSTEM

; -------------------- GSM CONTROL ---------------------------------

MOV R0,#70H MOV DPTR,#BULB_ON

CODE1:

CLR A MOVC A,@A+DPTR JZ DONE1 MOV B,@R0 CJNE A,B,WRONG1 INC DPTR INC R0 SJMP CODE1

DONE1: SETB P0.0 CLR P0.1 MOV DPTR,#BULB_ON LCALL LCD_DISPLAY LCALL MSG_DELETE MOV DPTR,#CMGS LCALL SERIAL_PRINT

STATUS:

ACALL RX CJNE A,#'>',STATUS MOV DPTR,#BULB_ON

KSHATRIYA COLLEGE OF ENGINEERING

Page 49

ECE

GSM BASED HOME AUTOMATION SYSTEM

LCALL SERIAL_PRINT MOV A,#1AH ACALL TX MOV A,#0DH ACALL TX

LINE5:

ACALL RX CJNE A,#0AH,LINE5

LINE55:

ACALL RX CJNE A,#0AH,LINE55 MOV DPTR,#MSG_SEND LCALL LCD_PRINT LJMP READ_MSG

WRONG1:

MOV R0,#70H MOV DPTR,#BULB_OFF

CODE2:

CLR A MOVC A,@A+DPTR JZ DONE2 MOV B,@R0 CJNE A,B,WRONG2 INC DPTR INC R0 SJMP CODE2

KSHATRIYA COLLEGE OF ENGINEERING

Page 50

ECE

GSM BASED HOME AUTOMATION SYSTEM

DONE2:

CLR P0.0 CLR P0.1 MOV DPTR,#BULB_OFF LCALL LCD_DISPLAY LCALL MSG_DELETE MOV DPTR,#CMGS LCALL SERIAL_PRINT

STATUS9:

ACALL RX CJNE A,#'>',STATUS9 MOV DPTR,#BULB_OFF LCALL SERIAL_PRINT MOV A,#1AH ACALL TX MOV A,#0DH ACALL TX

LINE50:

ACALL RX CJNE A,#0AH,LINE50

LINE555:

ACALL RX CJNE A,#0AH,LINE555 MOV DPTR,#MSG_SEND LCALL LCD_PRINT LJMP READ_MSG

WRONG2:

MOV DPTR,#INVALID_SMS

KSHATRIYA COLLEGE OF ENGINEERING

Page 51

ECE

GSM BASED HOME AUTOMATION SYSTEM

LCALL LCD_DISPLAY LCALL MSG_DELETE LJMP READ_MSG

; ------------------------ COMPLETED --------------------------------------

MSG_DELETE: MOV DPTR,#CMGD LCALL SERIAL_PRINT

LINE7:

ACALL RX CJNE A,#0AH,LINE7

LINE77:

ACALL RX CJNE A,#0AH,LINE77 MOV DPTR,#CMGD_SENT LCALL LCD_PRINT RET

;---------------------------------------------------------

MSG_DELETE1: MOV DPTR,#CMGD LCALL SERIAL_PRINT

LINE71:

ACALL RX CJNE A,#0AH,LINE71

LINE771:

ACALL RX CJNE A,#0AH,LINE771

KSHATRIYA COLLEGE OF ENGINEERING

Page 52

ECE

GSM BASED HOME AUTOMATION SYSTEM

RET

LCD_PRINT: MOV A,#01H ACALL COMMAND LCALL N_DELAY MOV A,#80H ACALL COMMAND LCALL N_DELAY

L1:

CLR A MOVC A,@A+DPTR JZ SHORT LCALL LCD_DISPLAY INC DPTR SJMP L1

SHORT: LAST:

MOV R7,#5 LCALL LCD_DELAY DJNZ R7,LAST RET

SERIAL_PRINT: S1: CLR A MOVC A,@A+DPTR JZ SHORT2 LCALL TX

KSHATRIYA COLLEGE OF ENGINEERING

Page 53

ECE

GSM BASED HOME AUTOMATION SYSTEM

INC DPTR SJMP S1

SHORT2: RET

TX: TW:

MOV SBUF,A JNB TI,TW CLR TI RET

RX: RW: JNB RI,RW CLR RI MOV A,SBUF RET

INIT_LCD:

MOV A,#30H ACALL COMMAND LCALL N_DELAY

MOV A,#01H ACALL COMMAND LCALL N_DELAY

MOV A,#02H ACALL COMMAND

KSHATRIYA COLLEGE OF ENGINEERING

Page 54

ECE

GSM BASED HOME AUTOMATION SYSTEM

LCALL N_DELAY

MOV A,#0CH ACALL COMMAND LCALL N_DELAY

MOV A,#20H ACALL COMMAND LCALL N_DELAY RET

COMMAND: MOV R0,A ANL A,#0F0H MOV P1,A CLR P1.2 SETB P1.3 NOP CLR P1.3 MOV A,R0 SWAP A ANL A,#0F0H MOV P1,A CLR P1.2 SETB P1.3 NOP CLR P1.3

KSHATRIYA COLLEGE OF ENGINEERING

Page 55

ECE

GSM BASED HOME AUTOMATION SYSTEM

RET

LCD_DISPLAY: LCALL N_DELAY MOV R0,A ANL A,#0F0H MOV P1,A SETB P1.2 SETB P1.3 NOP CLR P1.3 MOV A,R0 SWAP A ANL A,#0F0H MOV P1,A SETB P1.2 SETB P1.3 NOP CLR P1.3 LCALL N_DELAY RET

LCD_DELAY: D0: D1:

MOV R0,#255

MOV R1,#255 DJNZ R1,D1 DJNZ R0,D0 RET

KSHATRIYA COLLEGE OF ENGINEERING

Page 56

ECE

GSM BASED HOME AUTOMATION SYSTEM

N_DELAY: H1:

MOV R0,#255 DJNZ R0,H1 RET

ATE0: DB "ATE0 ",0DH,0 CNMI: DB "3,0,0,0",0DH,0 CMGF: DB "AT+CMGF=1",0DH,0 CMGR:DB "AT+CMGR=1",0DH,0 CMGS:DB "AT+CMGS=9032879691",0DH,0 CMGD:DB "AT+CMGD=1",0DH,0 LCD_TEST: DB "LCD WORKING ",0 ATE0_SENT: DB "ATE0 SENT",0 CNMI_SENT: DB "CNMI SENT",0 CMGF_SENT: DB "CMGF SENT",0 RD_MSG: DB "READING...",0 NO_NEW_MSG: DB "NO NEW MSG",0 MSG_RECEIVED: DB "GOT A MSG",0 ORG_NUM: DB "919032879691",0 NUM_MATCH: DB "NUMBER MATCH",0 CMGD_SENT: DB "MESSAGE DELETED",0 MSG_SEND: DB "MSG SENT",0 MISS_MATCH: DB "NUMBER NOT MATCH",0 BULB_ON: DB "BULB ON",0 BULB_OFF: DB "BULB OFF",0 INVALID_SMS: DB "INVALID SMS",0 END

KSHATRIYA COLLEGE OF ENGINEERING

Page 57

ECE

GSM BASED HOME AUTOMATION SYSTEM

6. RESULT & ANALYSIS

Home Automation is undeniably a resource which can make a home environment automated. People can control their electrical devices via these Home Automation devices and set up the controlling actions in the computer. We think this product have high potential for marketing in the future. At the moment the components are a bit too high to be able to produce these devices for an interesting price.

Achieved analytical results: System allowed the provision of security such that system took no action against the instructions received from unauthorized number. The required task was performed only when the pre-configured number instructed the system. Remote Controlling capability of the system allowed user to switch on/off through simulating the appliance as directed by the incoming SMS. The system automatically performed tests and checked support for available features and SMS sending and receiving capability and configured system accordingly.

KSHATRIYA COLLEGE OF ENGINEERING

Page 58

ECE

GSM BASED HOME AUTOMATION SYSTEM

7. ADVANTAGES & DISADVANTAGES

ADVANTAGES: Home automation systems allow detailed control over lighting, heating, cooling, security and CCTV systems, appliances and more. The possibilities are endless, although commercial home automation equipment tends to cover the main areas above. Home automation reacts to changes intelligently, like turning on the lights when you enter a room, only heating the building when it is occupied or setting lighting to suit your mood. It can also be tied into home cinema systems, so a single remote can turn on a projector, lower the screen, dim the lights, activate the sound system and start a media source. Most allow a level of remote control via a web application, allowing you to check on your home while away, and even make changes, such as turning on the heating if a frost is expected. Home automation systems can reduce energy consumption, increase security and make a home more comfortable. The primary disadvantages are the costs, the disruption in installing a wired system, and the potential complexity.

DISADVANTAGES: The places where the signal coverage is poor, this system is not capable of handling the instructions given to it and may not work properly. Due to busy and some more network problems, this device may not respond quickly.

KSHATRIYA COLLEGE OF ENGINEERING

Page 59

ECE

GSM BASED HOME AUTOMATION SYSTEM

8. APPLICATIONS & FUTURE SCOPE

APPLICATIONS: Home Automation Office Automation Can be used in various rooms like seminar hall, conference room, and study rooms in college where the capacity of room is limited and should not be exceeded. So the project will display the actual number of persons inside the room. The other part of the project (password detector) can be used to automate the door locking process, so the user need not to carry the door lock keys along with him, he can just remember the password and use it later to open the door.

FUTURE SCOPE: The basic level of home appliance control and remote monitoring has been implemented. In this project in future we can add a multimedia camera to see what is going inside the home by sitting in office or somewhere. The system is extensible and more levels can be further developed using automatic motion/glass breaking detectors so the solution can be integrated with these and other detection systems. In case of remote monitoring other appliances can also be monitored such that if the level of temperature rises above certain level then it should generate SMS or sensors can also be applied that can detect gas, smoke or fire in case of emergency the system will automatically generate SMS.In future the system will be small box combining the PC and GSM modem.

KSHATRIYA COLLEGE OF ENGINEERING

Page 60

ECE

GSM BASED HOME AUTOMATION SYSTEM

9. CONCLUSION
In the paper low cost, secure, ubiquitously accessible, auto-configurable, remotely controlled solution for automation of homes has been introduced. The approach discussed in the paper is novel and has achieved the target to control home appliances remotely using the SMS-based system satisfying user needs and requirements.

GSM technology capable solution has proved to be controlled remotely, provide home security and is cost-effective as compared to the previously existing systems. Hence we can conclude that the required goals and objectives of HACS have been achieved. The basic level of home appliance control and remote monitoring has been implemented. The system is extensible and more levels can be further developed using automatic motion/glass breaking detectors so the solution can be integrated with these and other detection systems. In case of remote monitoring other appliances can also be monitored such that if the level of temperature rises above certain level then it should generate SMS or sensors can also be applied that can detect gas, smoke or fire in case of emergency the system will automatically generate SMS. Wireless controlled home appliances in the comforts of any environment will revolutionize human way of living.

KSHATRIYA COLLEGE OF ENGINEERING

Page 61

ECE

GSM BASED HOME AUTOMATION SYSTEM

10. KIT PHOTOGRAPHY

KSHATRIYA COLLEGE OF ENGINEERING

Page 62

ECE

GSM BASED HOME AUTOMATION SYSTEM

11. BIBILOGRAPHY

Alkar, A. Z., & Buhur, U. (2005). An Internet Based Wireless Home Automation

System for Multifunctional Devices. IEEE Consumer Electronics, 51(4), 1169-1174. Retrieved from http://www.thaieei.com/embedded/pdf/Automation/20022.pdf

Jaywalker, N. P., Ahmed, V., Ladhake, S. A. & Thakare, R. D. (2008). Micro-

controller based Remote Monitoring using Mobile through Spoken Commands. Journal Of Networks, 3(2), 58-63. Retrieved from http://www.academypublisher.com/jnw/vol03/no02/jnw03025863.pdf

www.engineersgarage.com www.microkeil.com www.digi.com www.8051projects.com www.alldatasheets.com www.howstuffworks.com www.youtube.com www.wikipedia.en.com

KSHATRIYA COLLEGE OF ENGINEERING

Page 63

ECE

GSM BASED HOME AUTOMATION SYSTEM

12. APPENDIX
List of Figures: S.no 1 2 3 4 5 6 7 8 9 10 11 12 Figure 8051 Architecture 8051 pin diagram Power supply unit LCD display LCD interfacing with 8051uc RS 232 pin diagram RS 232 male& female connectors MAX 232 pin diagram Interfacing max232, RS232 with 8051uc Relay ULN 2804 Driver GSM modem Page no 8 9 23 24 25 26 27 28 30 31 33 36

List of Tables: 1 2 3 LCD Pin Description RS 232 Pin Description MAX 232 Pin Descriptions 25 26 29

List of Abbreviations: AT commands - Attention Commands GSM - Global system for mobile communications RS 232 - Recommended Standard 232
KSHATRIYA COLLEGE OF ENGINEERING Page 64