You are on page 1of 46

CHAPTER 1 INTRODUCTION

1.0 EMBEDEDD SYSTEMS


An embedded system is an application that contains at least one programmable computer (typically in the form of a microcontroller, a microprocessor or digital signal processor chip) and which is used by individuals who are, in the main, unaware that the system is computer-based. Typical examples of embedded applications that are constructed using the techniques discussed in this book include: Mobile phone systems (including both customer handsets and base stations). Automotive applications (including braking systems, traction control, airbag release systems, engine-management units, steer-by-wire systems and cruise control applications). Domestic appliances (including dishwashers, televisions, washing machines, microwave ovens, video recorders, security systems, garage door controllers). Aerospace applications (including flight control systems, engine controllers, autopilots and passenger in-flight entertainment systems). Medical equipment (including anesthesia monitoring systems, ECG monitors, drug delivery systems and MRI scanners). Defence systems (including radar systems, fighter aircraft flight control systems, radio systems and missile guidance systems).

GSM BASED HOME AUTOMATION

1.1 What is meant by Home Automation?


Automation means the act of implementing the control of equipment with advanced technology; usually involving electronic hardware . Home Automation means controlling of home appliances remotely when the user is away from the place and to operate devices while we are not able to access them physically. Here we used GSM technology so the controlling of home appliances is done through SMS. An automated home is sometimes called a smart home. The motivation is to facilitate the users to automate their homes having ubiquitous access. The use of home automation technology is to become as common place as owning a DVD player is today. The capabilities of home automation are endless. Audio, video, home theater, lighting, blinds, airconditioning, to name a few can be integrated and operated remotely.

1.2 Need of Home Automation?


The main need is forgetting to switch of the devices when we live home. Activating our air-conditioning from work, so our home is comfortable when we step through the door on your arrival home. Operating our lights and sound remotely to give the appearance that our home is occupied when we are away. Home automation is very popular these days and it is common to read in magazines about its marvels. With state of the art technology it is possible to achieve home automation with remote control and monitoring via GSM phones. This is enough to irrigate plants, to monitor old persons, to switch ON or OFF lights, to open an electric gate, to interface a burglar alarm in order to send SMS messages in case of intrusion. You can send an SMS and set the temperature at the correct value 1 hour before going home. Another important feature is the AC power monitor. Therefore this paper proposes a system that allows user to be control home appliances via SMS using GSM technology so that we can operate from anywhere.

GSM BASED HOME AUTOMATION

1.3 PROJECT OVERVIEW

Working:

Fig.1 Basic working of the system

The Basic working of the system follow below steps:


1. User sends commands via SMS 2. Mobile at the system transfers it to Micro controller 3. The Microcontroller operates the Devices according to the command received.

The working model is explained as:GSM Modem: GSM modem is a plug and play device and is attached to the microcontroller which communicates via RS232 port. GSM modem is a bridge responsible for enabling/ disabling of SMS capability. Cell Phone: Mobile device communicates with the GSM Modem via radio waves. The mode of communication is wireless and mechanism works on the GSM technology. Cell phone has a SIM card and a GSM subscription. This cell phone number is configured on the system. User transmits instructions via SMS and the system takes action against those instructions.

GSM BASED HOME AUTOMATION

1.4 ADVANTAGES
The main advantages of Home automation are Global Range Low Cost Low Power Requirement

This can be explained in below: Our mini project has many advantages such as remote controlling of home appliances, availability and ease of users. The user can get alerts anywhere through the GSM technology thus making the system location independent. The system contains low cost components easily available which cuts down the overall system cost. Moreover system alerts user about breach via SMS providing home security also it allows secure access due to pre-configured number. The ease of deployment is due to wireless mode of communication. GSM technology provides the benefit that the system is accessible in remote areas as well. The system reliability increases due to the useful features such as battery level checking, charging status and signal strength indicating the system about threats. The system integration is simple and is also scalable and extensible. The auto-configuration capability allows the system auto enabling/disabling of certain features. As we are using gsm technology we can operate our home from any where .

1.5 APPLICATIONS

Home automation Office automation.

GSM BASED HOME AUTOMATION

CHAPTER 2 SYSTEM MODEL


2.1 BASIC MODEL OF A SYSTEM

POWER SUPPLY

GSM MODEM

LCD

8051 MICRO
CONTROLLER

GSM
Mobile

RELAY

load

GSM BASED HOME AUTOMATION

2.2 CIRCUIT DIAGRAM

GSM BASED HOME AUTOMATION

2.3 REQUIREMENTS & IMPLEMENTATION


The Different Modules required for implementing GSM Based Home Automation are 1. 8051 Microcontroller 2. GSM Module 3. MAX 232 IC 4. LCD Display 5. Relay 6. Load (electrical lights or any other)

Implementation
Devices are connected to an embedded system. The embedded system is programmed to control the devices according to commands from a remote.

2.3.1 GSM RANGES

GSM, the Global System for Mobile communications, is a digital cellular communications system, which has rapidly gained acceptance and market share worldwide, although it was initially developed in a European context. In addition to digital transmission, GSM incorporates many advanced services and features, including ISDN compatibility and worldwide roaming in other GSM networks. The advanced services and architecture of GSM have made it a model for future third-generation cellular systems, such as UMTS. This paper will give an overview of the services offered by GSM, the system architecture, the radio transmission structure, and the signaling functional architecture

GSM BASED HOME AUTOMATION

GSM carrier frequencies


GSM networks operate in a number of different carrier frequency ranges (separated into GSM frequency ranges for 2G and UMTS frequency bands for 3G), with most 2G GSM networks operating in the 900 MHz or 1800 MHz bands. Where these bands were already allocated, the 850 MHz and 1900 MHz bands were used instead (for example in Canada and the United States). In rare cases the 400 and 450 MHz frequency bands are assigned in some countries because they were previously used for firstgeneration systems.Most 3G networks in Europe operate in the 2100 MHz frequency band. Regardless of the frequency selected by an operator, it is divided into timeslots for individual phones to use. This allows eight full-rate or sixteen half-rate speech channels per radio frequency. These eight radio timeslots (or eight burst periods) are grouped into a TDMA frame. Half rate channels use alternate frames in the same timeslot. The channel data rate for all 8 channels is 270.833 kbit/s, and the frame duration is 4.615 ms. The transmission power in the handset is limited to a maximum of 2 watts in GSM850/900 and 1 watt in GSM1800/1900.

2.3.2 RS232
In order to connect micro controller or a PC to GSM or ZIGBEE modem a serial port is used. Serial, is a very common protocol for device communication that is standard on almost every PC. Most computers include RS-232 based serial ports. Serial is also a common communication protocol that is used by many devices for instrumentation. In serial communication, the data is sent one bit at a time where as in parallel communication; the data is sent a byte or more at time. Serial communication uses a single data line where as the parallel communication uses 8 bit data line, this makes serial communication not only inexpensive but also makes it possible for two computers located in two different cities to communicate over the telephone.

GSM BASED HOME AUTOMATION

RS-232 WAVEFORM

TTL/CMOS Serial Logic Waveform

The diagram above shows the expected waveform from the UART when using the common 8N1 format. 8N1 signifies 8 Data bits, No Parity and 1 Stop Bit. The RS-232 line, when idle is in the Mark State (Logic 1). A transmission starts with a start bit which is (Logic 0). Then each bit is sent down the line, one at a time. The LSB (Least Significant Bit) is sent first. A Stop Bit (Logic 1) is then appended to the signal to make up the transmission. The data sent using this method, is said to be framed. That is the data is framed between a Start and Stop Bit.

RS-232 Voltage levels


1. +3 to +25 volts to signify a "Space" (Logic 0). 2. -3 to -25 volts for a "Mark" (logic 1). 3. Any voltage in between these regions (i.e. between +3 and -3 Volts) is undefined. The data byte is always transmitted least-significant-bit first. The bits are transmitted at specific time intervals determined by the baud rate of the serial signal. This is the signal present on the RS-232 Port of your computer, shown below.

RS-232 Logic Waveform

RS-232 LEVEL CONVERTER Standard serial interfacing of microcontroller (TTL) with PC or any RS232C Standard device , requires TTL to RS232 Level converter . A MAX232 is used for this purpose. It provides 2-channel RS232C port and requires external 10uF capacitors. GSM BASED HOME AUTOMATION 9

The driver requires a single supply of +5V .

MICROCONTROLLER INTERFACING WITH RS-232 STANDARD DEVICES

GSM BASED HOME AUTOMATION

10

CHAPTER 3 HARDWARE DESCRIPTION


3.1 Introduction To Microcontroller:
Micro controller is the heart of total system. The micro controller controls all the devices connected in the diagram. Micro controller sends pulses to all the devices, which are connected to it.We can program it in any language i.e., in assembly or C or C++, depending upon the user. In this flash memory is more compatible with others. In our design, this controller is compatible and also reliable one.

Micro Controller 8051:


In 1981, Intel Corporation introduced an 8-bit microcontroller called the 8051. This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one serial port, and four ports (each 8-bits wide) all on a single chip. The 8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a time. Data larger than 8 bits has to broken into 8-bit pieces to be processed by the CPU. The 8051 has a total of four I/O ports, each 8 bits wide. Although the 8051 can have a maximum of 64K bytes of on chip ROM, many manufacturers have put only 4K bytes on the chip. There are different flavors of the 8051 in terms of speed and amount of on-chip ROM, but they are all compatible with the original 8051 as far as the instructions are concerned.

Features :
The basic architecture consists of the following features: an eight bit ALU 32 discrete I/O pins (4 groups of 8) which can be individually accessed two 16 bit timer/counters full duplex UART 6 interrupt sources with 2 priority levels 128 bytes of on board RAM separate 64K byte address spaces for DATA and CODE memory

GSM BASED HOME AUTOMATION

11

Pin diagram:

Pin Description:
VCC: Supply voltage. GND: Ground. 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 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification. Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, GSM BASED HOME AUTOMATION 12

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL ) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification

Port pin Alternate functions


P1.0 P1.1 P1.5 P1.6 P1.7 T2 (EXTERNAL COUNT INPUT TO TIMER/COUNTER 2), CLOCK-OUT T2EX (TIMER/COUNTER 2 CAPTURE /RELOAD TRIGGER AND DIRECTION CONTROL ) MOSI (USED FOR IN-SYSTEM PROGRAMMING ) MISO (USED FOR IN-SYSTEM PROGRAMMING ) SCK (USED FOR IN-SYSTEM PROGRAMMING )

Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output
buffers can sink/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 current (IIL ) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. 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. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups.Port 3 receives some control signals for Flash programming and verification.Port 3 also serves the functions of various special features of the AT89S52, as shown in the following table.
Port pin P3.0 Alternate functions RXD (serial input port)

GSM BASED HOME AUTOMATION

13

P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7

TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) RD (external data memory read strobe)

RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN: Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

EA/VPP: External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to GSM BASED HOME AUTOMATION 14

FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCCfor internal program executions.This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2: Output from the inverting oscillator amplifier

Pin Description
Pin Number Description

18 9 10 17 18 19 20 21 28 29 30 31 32 39 40

P1.0 - P1.7 - Port 1 RST - Reset P3.0 - P3.7 - Port 3 XTAL2 - Crystal XTAL1 - Crystal GND - Ground P2.0 - P2.7 - Port 2 PSEN - Program Store Enable ALE - Address Latch Enable EA - External Access Enable P0.7 - P0.1 - Port 0 Vcc - Positive Power Supply

GSM BASED HOME AUTOMATION

15

3.2 GSM MODEM


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.

3.2.1Description:
A GSM modem can be an external modem device, such as the Wavecom FASTRACK Modem. Insert a GSM SIM card into this modem, and connect the modem to an available serial port on your computer. A GSM modem can be a PC Card installed in a notebook computer, such as the Nokia Card Phone. A GSM modem could also be a standard GSM mobile phone with the appropriate cable and software driver to connect to a serial port on your computer. Phones such as the Nokia 7110 with a DLR-3 cable, or various Ericsson phones, are often used for this purpose. A dedicated GSM modem (external or PC Card) is usually preferable to a GSM mobile phone. This is because of some compatibility issues that can exist with mobile phones. For example, if you wish to be able to receive inbound MMS messages with your gateway, and you are using a mobile phone as your modem, you must utilize a mobile phone that does not support WAP push or MMS. This is because the mobile phone automatically processes these messages, without forwarding them via the modem interface. Similarly some mobile phones will not allow you to correctly receive SMS text messages longer than 160 bytes (known as concatenated SMS or long SMS). This is because these long messages are actually sent as separate SMS messages, and the phone attempts to reassemble the message before forwarding via the modem interface When you install your GSM modem, or connect your GSM mobile phone to the computer, be sure to install the appropriate Windows modem driver from the device manufacturer. To simplify configuration, the Now SMS/MMS Gateway will communicate with the device via this driver. An additional benefit of utilizing this driver is that you can use Windows diagnostics to ensure that the modem is communicating properly with the computer

GSM BASED HOME AUTOMATION

16

Figure: GSM modem Now SMS/MMS gateway can simultaneously support multiple modems, provided that your computer hardware has the available communications port resources

Global System for Mobile Communications (GSM) modems are specialized types of modems that operate over subscription based wireless networks, similar to a mobile phone. A GSM modem accepts a Subscriber Identity Module (SIM) card, and basically acts like a mobile phone for a computer. Such a modem can even be a dedicated mobile phone that the computer uses for GSM network capabilities. A GSM modem is a wireless modem that works with a GSM wireless network. A wireless modem behaves like a dial-up modem. The GSM modem can be an external device or a PC Card / PCMCIA Card. Typically, an external GSM modem is connected to a computer through a serial cable or a USB cable. It is a Most Popular Mobile Technology Launch -1991by Radio linja in Finland Frequencies -900/1800MHz Range Global Interface Subscriber Identity Module Services SMS, MMS, GPRS, EDGE

GSM BASED HOME AUTOMATION

17

3.2.2 AT Commands :
In addition to the standard AT commands, GSM modems support an extended set of AT commands. These extended AT commands are defined in the GSM standards. With the extended AT commands, you can do things like:

* * *

Reading, writing and deleting SMS messages. Sending SMS messages. Reading, writing and searching phone book entries.

AT commands features: Line settings: A serial link handler is set with the following default values. Autobaud,

8 bits data, 1 stop bit, no parity, flow control. Command line: Commands always start with AT (which means attention) and finish with a <CR>character. .

Send message +CMGS


Description : The <address> field is the address of the terminal to which the message is sent. To send the message, simply type, <ctrl-Z> character (ASCII 26). The text can contain all existing characters except <ctrl-Z> and <ESC> (ASCII 27). This command can be aborted using the <ESC> character when entering text. In PDU mode, only hexadecimal characters are used (09,AF). Syntax :Command syntax in text mode : AT+CMGS= <da> [ ,<toda> ] <CR>

GSM BASED HOME AUTOMATION

18

The message reference, <mr>, which is returned to the application is allocated by the product. This number begins with 0 and is incremented by one for each outgoing message (successful and failure cases); it is cyclic on one byte (0 follows 255). Note: this number is not a storage number - outgoing messages are not stored.

Delete message +CMGD


This command is used to delete one or several messages from preferred message storage (BM SMS CB RAM storage, SM SMSPP storage SIM storage or SR SMS Status-Report storage). Syntax : Command syntax :AT+CMGD=<Index> [.<DelFlag>]

GSM BASED HOME AUTOMATION

19

3.3. LIQUID CRYSTAL DISPLAY(LCD):


An LCD consists of two glass panels, with the liquid crystal material sand witched in between them. The inner surface of the glass plates are coated with transparent electrodes which define the character, symbols or patterns to be displayed polymeric layers are present in between the electrodes and the liquid crystal, which makes the liquid crystal molecules to maintain a defined orientation angle. One each polarisers are pasted outside the two glass panels. These polarisers would rotate the light rays passing through them to a definite angle, in a particular direction The LCD is used for the purpose of displaying the words which we are given in the program code. This code will be executed on microcontroller chip. By following the instructions in code the LCD display the related words.

Fig. LCD Display The LCD display consists of two lines, 20 characters per line that is interfaced with the PIC16F73.The display contains two internal byte-wide registers, one for commands (RS=0) and the second for characters to be displayed (RS=1). It also contains a user-programmed RAM area (the character RAM) that can be programmed to generate any desired character that can be formed using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will be used to signify that the display RAM address 00h will be chosen Port1 is used to furnish the command or data type, and ports 3.2 to 3.4 furnish register select and read/write levels.

GSM BASED HOME AUTOMATION

20

3.3.1 PIN DIAGRAM The Pin diagram for LCD is shown in the following fig and the pin description is also explained in Table
GN D

+5 v

VD
D

15

16

2x16 Liquid Crystal Display


4 5 6 7 8 9 10 11 12 13 14

RS R/w En ww Pins wo w 1 "Vss" 2 3 4 5 6 7 14 "Vcc" "Vee" "R/S" "R/W" "E"

D0 D1 D2 D3 D4 0D Description 6 0Ground +5v power supply Contrast Voltage

D5 D6 D7

Instruction/Register Select Read/Write LCD Registers Enable

Data I/O Pins

GSM BASED HOME AUTOMATION

21

3.2.2 INTERFACING LCD TO 8051

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used, the LCD will require a total of 7 data lines. If an 8-bit data bus is used, the LCD will require a total of 11 data lines. The three control lines are EN, RS, and RW. Note that the EN line must be raised/lowered before/after each instruction sent to the LCD regardless of whether that instruction is read or write, text or instruction. In short, you must always manipulate EN when communicating with the LCD. EN is the LCD's way of knowing that you are talking to it. If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.

GSM BASED HOME AUTOMATION

22

3.4.RELAYS
A relay is an electromagnetic switch. In other words it is activated when a current is applied to it. Normally a relay is used in a circuit as a type of switch (as you will see below). There are different types of relays and they operate at different voltages. Relays are switching devices, it has two fixed positions i.e., ON and OFF positions. Circuit symbol of relay:

NO -"Normally Open", NC -"Normally Closed". COM -common connection for double pole switches

A relay will switch one or more poles, each of whose contacts can be thrown by energizing the coil in one of three ways:

Normally-open (NO) contacts connect the circuit when the relay is activated; the circuit is disconnected when the relay is inactive. It is also called a Form A contact or "make" contact. Normally-closed (NC) contacts disconnect the circuit when the relay is activated; the circuit is connected when the relay is inactive. It is also called a Form B contact or "break" contact. Change-over (CO), or double-throw (DT), contacts control two circuits: one normally-open contact and one normally-closed contact with a common terminal. It is also called a Form Ccontact or "transfer" contact ("break before make"). If this type of contact utilizes a "make before break" functionality, then it is called a Form D contact.

GSM BASED HOME AUTOMATION

23

Electromagnetic relay:
Out of different types of relays, Most commonly used relay is Electromagnetic Relay. The electromagnetic relay consists of a multi-turn coil, wound on an iron core, to form an electromagnet. When the coil is energized, by passing current through it, the core becomes temporarily magnetized.

The magnetized core attracts the iron armature. The armature is pivoted which causes it to operate one or more sets of contacts. When the coil is de-energized the armature and contacts are released. The coil can be energized from a low power source such as a ransistor while the contacts can switch high powers such as the mains supply. The relay can also be situated remotely from the control source. Relays can generate a very high voltage across the coil when switched off. This can damage other components in the circuit. To prevent this a diode is connected across the coil. The cathode of the diode is connected to the most positive end of the coil.The springsets (contacts) can be a mixture of n.o, n.c and c.o. Look at the page on switches to see how they can be used in circuits. Various coil operating voltages (ac and dc) are available.The actual contact points on the springsets are available for high current and low current operation. The REED RELAY has a much faster operation than the relays described above.

GSM BASED HOME AUTOMATION

24

The following designations are commonly encountered: SPST Single Pole Single Throw. These have two terminals which can be connected or disconnected. Including two for the coil, such a relay has four terminals in total. It is ambiguous whether the pole is normally open or normally closed. The terminology "SPNO" and "SPNC" is sometimes used to resolve the ambiguity. SPDT Single Pole Double Throw. A common terminal connects to either of two others. Including two for the coil, such a relay has five terminals in total. DPST Double Pole Single Throw. These have two pairs of terminals. Equivalent to two SPST switches or relays actuated by a single coil. Including two for the coil, such a relay has six terminals in total. The poles may be Form A or Form B (or one of each). DPDT Double Pole Double Throw. These have two rows of change-over terminals. Equivalent to two SPDT switches or relays actuated by a single coil. Such a relay has eight terminals, including the coil. The "S" or "D" may be replaced with a number, indicating multiple switches connected to a single actuator. For example 4PDT indicates a four pole double throw relay (with 14 terminals). EN 50005 are among applicable standards for relay terminal numbering; a typical EN 50005-compliant SPDT relay's terminals would be numbered 11, 12, 14, A1 and A2 for the C, NC, NO, and coil connections, respectively.
Fig. SPST, PDT, DPST, DPDT diagrams

Circuit symbols of relays. "C" denotes the common terminal in SPDT and DPDT types

GSM BASED HOME AUTOMATION

25

3.5. POWER SUPPLY:


The 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. The block diagram of power supply is shown in fig below.

AC I/P

Transformer

Rectifier

Filter

Regulator

Load

Block diagram of power supply

Transformer
The potential transformer will step down the power supply voltage (0-230V) to (06V) level. Then the secondary of the potential transformer will be connected to the precision rectifier, which is constructed with the help of opamp. The advantages of using precision rectifier are it will give peak voltage output as DC, rest of the circuits will give only RMS output.

GSM BASED HOME AUTOMATION

26

Bridge rectifier
Bridge rectifier is used to maintain the proper DC polarity at the input to the circuit, irrespective of telephone line polarity. It comprises of four diodes connected to form a bridge. It uses the entire AC wave (both positive and negative sections). 1.4V is used up in the bridge rectifier because each diode uses 0.7V when conducting and there are always two diodes conducting, as shown in fig below.

IN4007 IN4007

AC I/P

IN4007

IN4007 O/P

Fig: Bridge rectifier

IC Voltage Regulators:
Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC. Although the internal construction of the IC is somewhat different from that described for discrete voltage regulator circuits, the external operation is much the same. IC units provide regulation of either a fixed positive voltage, a fixed negative voltage, or an adjustably set voltage.

GSM BASED HOME AUTOMATION

27

Three terminal Voltage Regulators:


Fig shows the basic connection of a three-terminal voltage regulator IC to a load. The fixed voltage regulator has an unregulated dc input voltage, Vin, applied to one input terminal, a regulated output dc voltage, Vout, from a second terminal, with the third terminal connected to ground. From Transformer Secondary Vin IN OUT 7805 GND GND

Vout

Fig.: Fixed Voltage Regulator

The series 78 regulators provide fixed regulated voltages from 5 to 24 V. Unregulated input voltage Vin is filtered by capacitor C1 and connected to the ICs IN terminal. The ICs OUT terminal provides a regulated + 12V which is filtered by capacitor C2. The third IC terminal is connected to ground (GND). The Power

Section consists of a centre tapped step-down transformer, which is used to step down the 230V AC into 12V. This 12V is given to bridge rectifier. The output from the diodes is a full-wave rectifier output. Any unwanted ac ripples are filtered out using a filter. This is fed to the 7805 voltage regulator that gives anoutput voltage of +5v.

. Fig.: Circuit Diagram of Power Supply

GSM BASED HOME AUTOMATION

28

CHAPTER 4 PROJECT DEVELOPMENT


4.1.INTRODUCTION TO KEIL This technical note describes the use of the Keil uVision Integrated Development Environment in the development of a C based, MicroController application. The Keil 8052 compiler package includes uVision2 which is an Integrated Development Environment (IDE) along with all the utilities you may need to create embedded application programs for the MicroController family. CREATING A PROJECT Before writing any C-code, a project associated with our code needs to be created. This is done by first creating a new folder in the Keil directory in which your project will be saved. Next the Keil uV2 application can be launched and a new project is created. This is achieved by completing the following steps. Create a new project. From the main window, choose the Project menu and select New project. A new window appears as shown below in Figure 1.

GSM BASED HOME AUTOMATION

29

A new window appears as shown in figure 2 below and you are now required to configure your setup to target the specific MicroController device you wish to use (in this example we will be using the ADuC834) and the output file format generated after the compilation stage. This is achieved by completing the following steps.

Next, you need to configure your target output options. This is done by clicking on the options for target item located in the project pull-down menu. Alternatively you can select this option by clicking on the icon from the compile toolbar situated at the top of the screen and shown in figure 3 below.

A new window appears as shown in figure 4. Enable the option to Create Hex File by ticking the check-box and pressing OK as shown circled in figure 4 below.

GSM BASED HOME AUTOMATION

30

Now you can begin writing your C program. In the main window, choose the File pulldown menu and select New. A new window named <text1> will appear on the screen. Type the C source code that is included in Appendix A of this tech note into the <text1> window. Once you've typed all the code, again choose the File pull-down menu and select Save.

GSM BASED HOME AUTOMATION

31

COMPILING A C PROGRAM Our C code is compiled by selecting Build Target from the Project pull-down menu on the main tool-bar. The compile option can also be initiated by selecting the F7 special function key or by clicking on the Build Target icon in the compile toolbar as shown in figure 6 below.

If the compilation completes successfully a message indicating that the compile job has completed with 0 errors will appear in the build dialog screen. Sometimes warnings may be generated for information purposes to indicate multiple function calls etc. If the resultant compilation message indicates that there were 1 or more errors, then the output files will not be created. In this case, the file has been entered incorrectly and clicking directly on any error message forces uVision to highlight where in the code the error has occurred.

4.2.SIMULATING C-SOURCE CODE Another powerful feature of the uVision2 IDE is that it allows you to run your code in a MicroController specific simulation environment. To start a simulation session you simply click on the on Start/Stop Debug Session option available from the Debug pulldown menu. Alternatively you can press <Cntrl+F7> or the Debug icon available in the File toolbar as shown in figure 7.

GSM BASED HOME AUTOMATION

32

CREATING THE SIMULATION ENVIRONMENT The following steps will allow you to create a generic simulation environment that you may want to further customize to your own requirements. From the top Debug toolbar, click on the icon buttons that are shown in figure 8 below which open a Serial I/O peripheral window as well as a code Performance Analyzer window. Note: If the Debug toolbar does not appear at the top of the screen, simply select the Debug Toolbar option available from the View pull-down menu.

GSM BASED HOME AUTOMATION

33

4.3SOURCE CODE
Program : #include<c51.h> void transmit(unsigned char *); void serial_init(); sbit led=P1^3; unsigned char *tx_dat; unsigned char a[70],y[5]; unsigned char b[3],c[3]={"Son"},c1[3]={"Sof"}; int i=0,j=0,k=0,x=0,l=0,Z=0; void main() { LCD_Init(); lprintf("Gsm-recv",1,1); Delay(100); LCD_Cmd(0x01); led=0; serial_init(); ///////////////// AT /////////////////////// while(1) { LCD_Cmd(0x80); tx_dat="at"; transmit(tx_dat); SBUF=13; j=0; while(j<70) { if((a[j]=='O')&&(a[j+1]=='K')) { GSM BASED HOME AUTOMATION 34 //Polling for OK //Transmit AT command //Transmit ENTER //led off

LCD_Data(a[j]); LCD_Data(a[j+1]); Z=1; break; } j++; } if(Z==1) { Z=0; loop: while(1) { Delay(50); LCD_Cmd(0x01); lprintf("send read command",1,1); tx_dat="at+cmgr=1"; transmit(tx_dat); SBUF=13; Delay(50); j=0; lprintf("wait for error",2,0); while(j<70) { LCD_Cmd(0x01); if((a[j]=='E')&&(a[j+4]=='R')) { lprintf("ERROR",1,1); goto loop; } j++; } GSM BASED HOME AUTOMATION //delay

//Display OK

/////RECEIVE//////

//Transmit READ command //Transmit ENTER

//Polling for ERROR

//Display ERROR //loop until message recieve

35

j=0; Delay(50); LCD_Cmd(0x01); lprintf("reading message",1,1); while(j<70) { if((a[j]=='#')&&(a[j+4]=='!')) { b[0]=a[j+1]; b[1]=a[j+2]; b[2]=a[j+3]; break; } j++; } LCD_Cmd(0x01); LCD_Cmd(0xc0); LCD_Data(b[0]); LCD_Data(b[1]); LCD_Data(b[2]); if((b[0]==c[0])&&(b[1]==c[1])&&(b[2]==c[2])) { Delay(50); LCD_Cmd(0x01); lprintf("led on",1,1); led=1; Delay(50); } if((b[0]==c1[0])&&(b[1]==c1[1])&&(b[2]==c1[2])) { Delay(50); LCD_Cmd(0x01); GSM BASED HOME AUTOMATION 36 //compare with sof //led on //compare with son //display message //Polling for message

lprintf("led off",1,1); led=0; Delay(60); } b[0]='\0'; b[1]='\0'; b[2]='\0'; Delay(50); LCD_Cmd(0x01); lprintf("send delet command",1,1); tx_dat="at+cmgd=1"; transmit(tx_dat); SBUF=13; j=0; while(j<70) { if((a[j]=='O')&&(a[j+1]=='K')) { LCD_Cmd(0x80); lprintf("Message Deleted",1,1); Delay(100); break; } j++; } } } } } /* void delay(unsigned int x) { GSM BASED HOME AUTOMATION 37 //Polling for OK /////delete////// //Trasmit delete command //Trasmit ENTER //led of

int i; while(x-->0) { for(i=0;i<=30;i++) {;} } }*/

void serial_init() { SCON=0x50; TMOD=0x20; TH1=0xFD; TR1=1; EA=1; ES=1; tx_dat=0x00; }

void intr(void) interrupt 4 { if(RI) { RI=0; a[i]=SBUF; if(i==69) { //a[69]='\0'; i=0; } i++; } GSM BASED HOME AUTOMATION 38

} void transmit(unsigned char *tx) { while(*tx) { SBUF=*tx++; Delay(15); } SBUF=13; Delay(2); TI=0; i=0; } C51.h program: #include<reg51.h> #include<intrins.h> // Device Mapping #define LCD_Port P2 sbit LCD_RS=P1^0; sbit LCD_RW=P1^1; sbit LCD_EN=P1^2; sbit LCD_BP=P0^7;

// LCD Busy Pin

// Global variables unsigned char bc=0,pflag=0,fstore=0; unsigned char xdata RData[100]; unsigned char xdata Msg[20];

// Functions Prototype Declaration void lprintf(unsigned char *,unsigned char,unsigned char); void LCD_Init(); void LCD_Cmd(unsigned char); void LCD_Data(unsigned char); void Delay_10ms(); void Delay(int); GSM BASED HOME AUTOMATION 39

void LCD_Busy(); void ClrLCD(); void SConfig(void); void Send_Char(unsigned char); void Send(unsigned char *); /*----------------------------------------------*/ // To Clear LCD /*----------------------------------------------*/ void ClrLCD() { LCD_Cmd(0x01); } /*----------------------------------------------*/ // Displaying String /*----------------------------------------------*/ // Displaying String void lprintf(char *str,unsigned char ln,unsigned char col) { static int li; unsigned char line; if(li==0) { li=1; LCD_Init(); } switch(ln) { case 1: line = 0x80; break; case 2: line = 0xc0; break; case 3: line = 0x94; break; case 4: line = 0xD4; break; } LCD_Cmd(line+col-1);

GSM BASED HOME AUTOMATION

40

while(*str) { LCD_Data(*str); str++; } }

/*----------------------------------------------*/ //LCD Initilization void LCD_Init() { LCD_Cmd(0x30); LCD_Cmd(0x30); LCD_Cmd(0x30); LCD_Cmd(0x38); LCD_Cmd(0x06); LCD_Cmd(0x01); LCD_Cmd(0x0c); } /*----------------------------------------------*/ // LCD Command Run void LCD_Cmd(unsigned char cmd) { LCD_Busy(); LCD_Port=cmd; LCD_BP=0; _nop_(); LCD_BP=1; LCD_RS=0; LCD_RW=0; LCD_EN=1; _nop_(); _nop_(); LCD_EN=0; } /*----------------------------------------------*/ //LCD Data Out Function void LCD_Data(unsigned char dt) { LCD_Busy(); LCD_Port=dt; LCD_BP=0; _nop_(); LCD_BP=1; LCD_RS=1; LCD_RW=0; LCD_EN=1; GSM BASED HOME AUTOMATION 41

_nop_(); _nop_(); LCD_EN=0; } /*----------------------------------------------*/ // LCD BUSY Check Function void LCD_Busy() { /* LCD_Port=0xff; LCD_RS=0; LCD_RW=1; while(1) { LCD_EN=0; _nop_(); _nop_(); LCD_EN=1; if(!LCD_BP) break; } Delay(1); */ unsigned int i; for(i=0; i<800; i++); } /*/*----------------------------------------------*/ // Delay Function void Delay(int n) { while(n) { Delay_10ms(); n--; } }

void Delay_10ms() { int i; GSM BASED HOME AUTOMATION 42

for(i=0; i<1825; i++); } /*-------------------------------------------*/ //Functions For Serial Communication /*-------------------------------------------*/ // Serial Configuration void SConfig() { TMOD=0x20; TH1=-6; TL1=-6; SCON=0x50; TR1=1; } /*-------------------------------------------*/ // Function to Tx a single Character void Send_Char(unsigned char ch) { unsigned char flag=0; SBUF=ch; while(!TI); TI=0; } /*-------------------------------------------*/ // Funciton to Tx a given String void Send(unsigned char *str) { while(*str) { Send_Char(*str); str++; } } /*-------------------------------------------*/ // Interrupt Subroutien Function Serial_Int() interrupt 4 using 1 { unsigned char t; if(RI) { t=SBUF; GSM BASED HOME AUTOMATION 43

RI=0; if(t == 'A') fstore =1; if(fstore) { RData[bc++]=t; RData[bc]='\0'; } if(bc>40) { pflag=1; fstore=0; bc=0; } // LCD_Data(RData[bc-1]); // Send_Char(RData[bc-1]); Interrupt. } }

// Uncomment this line to test the Serial

GSM BASED HOME AUTOMATION

44

FUTURE ENHANCMENTS
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. It can be used for high security in banks and other organizations Provision to store mobile numbers Control of more devices Theft Alert.

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 project 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. In addition, which is an era when the number of mobile phone users growing at a high rate, this system makes use of the mobile networks to provide the users with a simple and cheap Home Automation System.

GSM BASED HOME AUTOMATION

45

REFERNCES

Reference Books:
The 8051 Microcontroller and Embedded Systems The 8051 Micro-controller Programming and customizing the 8051 -Muhammad Ali Mazidi - Ayala - Myke Predko

Websites:
www.atmel.com www.analogicgroup.com www.philips.com www.google.com www.gsmworld.com

GSM BASED HOME AUTOMATION

46

You might also like