home automation system using gsm
TRANSCRIPT
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 1
MINI PROJECT REPORT
ON
“WIRELESS HOME AUTOMATION SYSTEM USING GSM”
Work carried out at
SIDDAGANGA INSTITUTE OF TECHNOLOGY, TUMKUR
Submitted in partial fulfilment of the requirement for the award of
Bachelor of Engineering
Of
Visvesvaraya Technology University, Belgaum
By
MONICA SINGH 1SI11TE030
HARSHA JAISWAL 1SI11TE017
ROHIT SINHA 1SI11TE038
Under the guidance of
Mrs.D.K.KUMUDA
Associate professor
Department of TE
SIT, Tumkur.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 2
SIDDAGANGA INSTITUTE OF TECHNOLOGY, TUMKUR-572103
(An Autonomous Institute under Visvesvaraya Technological University, Belgaum)
DEPARTMENT OF TELECOMMUNICATION ENGINEERING
CERTIFICATE
Certified that the project work entitled “WIRELESS HOME AUTOMATION SYSTEM
USING GSM” is a bonafied work carried out by Monica Singh (1SI11TE030), Rohit
Sinha (1SI11TE038), Harsha Jaiswal (1SI11TE017) in partial fulfilment of the
requirement for the award of the degree in BE, Telecommunication Engineering,
Visvesvaraya Technological University, Belgaum during the year 2013-14.It is certified
that all corrections / suggestion indicated for Internal Assessment have been
incorporated in the Report. The project report has been approved as it satisfies the
academic requirements in respect of project work prescribed for the Bachelor of
Engineering Degree.
GUIDE H.O.D PRINCIPAL
D.K KUMUDA Dr.K.C.Narsimhamurthy Dr.Shivakumaraiah
Associate Professor Professor & Head Principle
Department of TE Department of TE S.I.T, TUMKUR
S.I.T, Tumkur S.I.T, Tumkur
Submitted by : Harsha Jaiswal (1SI11TE017)
Monica Singh (1SI11TE030)
Rohit Sinha(1SI11TE038)
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 3
ACKNOWLEDGEMENT
We are highly indebted to our Faculty Mrs.D.K.KUMUDA,
Telecommunication Engineering Department, who has given us all the
necessary technical guidance in carrying out this Project.
We wish to express our sincere thanks to Dr K.C.NARSIMHAMURTHY, Head
of the Department of Telecommunication Engineering, S.I.T, for permitting us
to pursue our Project and encouraging us throughout the Project.
Finally, we thank all the people who have directly or indirectly help us through
the course of our Project.
We express our deep sense of gratitude to Dr.Madhusudhan , Tumkur, for his
valuable guidance and encouragement in carrying out our Project.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 4
ABSTRACT
Now a day's every system is automated in order to face new
challenges in the present day situation. Automated systems have less
manual operations, so that the flexibility, reliabilities are high and
accurate. Hence every field prefers automated control systems.
Especially in the field of electronics automated systems are doing
better performance.
Probably the most useful thing to know about the global system for
mobile communication is that it is an international standard. If you
travel in parts of world, GSM is only type of cellular service
available. Instead of analog services, GSM was developed
as a digital system using TDMA technology.
The goal of the project is to develop a system, which uses Mobile
technology that keeps control of the various units of the home
appliances, which executes with respect to the signal sent by the
mobile.
For utilization of appliances the new concept has been thought to
manage them remotely by using GSM, which enables the user to
remotely control switching of domestic appliances. Just by dialing
keypad of remote telephone, from where we are calling we can
perform ON / OFF operation of the appliances.
The ranges of appliances that can be controlled through tele remote
systems are many in numbers. Some of them are as follows and this
depends upon the usage priority of the appliances i.e. Lights, Music
System or other electrical / electronic appliances.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 5
CONTENTS
ACKNOWLEDGEMENTS
ABSTRACT
LIST OF FIGURES LIST OF TABLES
CHAPTER 1. INTRODUCTION 1.1 Aim of the project
1.2 Significance and applications
CHAPTER 2. OVERVIEW 2.1 Overview of project
2.1.1 Block Diagram
2.1.2 Circuit Diagram
2.1.3 Description
CHAPTER3. HARDWARE DESCRIPTION 3.1 Microcontroller
3.1.1 A Brief History of 8051
3.1.2 Description of 89S52 Microcontroller
3.1.3 Pin Configurations
3.1.4 Relay
CHAPTER 4. POWER SUPPLY 4.1 Transformer
4.2 Rectifier
4.3 Voltage Regulator
CHAPTER 5.LIQUID CRYSTAL DISPLAY 5.1 LCD Screen
CHAPTER 6.RS-232 AND MAX 232
CHAPTER 7.GSM MODEM
CHAPTER 8.SOFTWARE IMPLEMENTATION
CHAPTER 9.CONCLUSION
REFERENCE
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 6
CHAPTER 1
1. INTRODUCTION
1. Introduction
1.1 Aim of the project: The aim of the project is to develop a system, which uses Mobile technology
that keeps control of the various units of the automobiles, Computer system,
which executes with respect to the signal sent by the mobile.
1.2 Significance and applications: GSM BASED HOME AUTOMATION plays a very important role in
domestic applications. The ease of operation of the kit and low cost add up as an
additional advantage for its usage. Its significance can be proved by considering
the following specialties of kit designed by us.
Reliability: Reliability is one such factor that every electrical system
should have in order to render its services without malfunctioning over along
period of time. We have designed our kit using AT89S52 micro controller
which is itself very reliable and also operates very efficiently under normal
condition.
Cost: The design is implemented at a very economical price. The total
cost incurred by us in designing this kit is very less and further we have
developed the GSM based Home Automation which is more economical rather
than just interfacing those which are readily available in the market.
For utilization of appliances the new concept has been thought to
manage them remotely by using GSM, which enables the user to remotely
control switching of domestic appliances.
The ranges of appliances that can be controlled through cell phones
are many in numbers. Some of them are as follows and this depends upon the
usage priority of the appliances i.e. Lights, Fans or other electrical / electronic
appliances.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 7
CHAPTER 2
2. OVERVIEW
2.1Overview of Project
2.1.1 Block Diagram
2.1.2 Circuit Diagram
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 8
2.1.3 Description
In this project we are going to control general home appliances based
on the mobile communication. The idea behind this particular work is to give
user the full flexibility to control the appliances from remote distances when
there is a busy schedule concerned to his daily routine.
The main parts of this schematic diagram are:
1. POWER SUPPLY.
2. (AT89C52) MICROCONTROLLER UNIT.
3. RS 232 CABLE
4. RELAYS
5. GSM MODEM
6. BULB
7. BUZZER
8. FAN
The process to operate this project is first make a mobile to mobile
connection wirelessly or with a single mobile onboard wired. But here we are
using to mobiles to make is a wireless application. Start with making a
connection with the onboard mobile from remote distance, then when
connection is established lets control the project with the data as follows:
To operate the BULB just press “1” to switch ON and also to switch OFF
again press “0”. This ON/OFF condition of BULB is through Relay where
switching is very fast and accurate.
To operate the BUZZER just press “2” to switch ON and also to switch
OFF again press “0”. This ON/OFF condition of PLUG is through Relay where
switching is very fast and accurate
To operate the FAN just press “4” to switch ON and also to switch OFF
again press “0”. This ON/OFF condition of DC MOTOR is through Relay
where switching is very fast and accurate.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 9
CHAPTER 3
3. HARDWARE DESCRIPTION
The block diagram of the system is as shown in the fig. The system basically
consists of a
1. Micro controller
2. GSM module
3. LED
4. Relay
5. Power supply
3.1 Microcontroller Architecture 3.1.1 A Brief History of 8051 In 1981, Intel Corporation introduced an 8 bit microcontroller called
8051. This microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two
timers, one serial port, and four ports all on a single chip. At the time it was also
referred as “A SYSTEM ON A CHIP” The 8051 is an 8-bit processor meaning that the CPU can work only on 8
bits data at a time. Data larger than 8 bits has to be broken into 8 bits pieces to
be processed by the CPU. The 8051 has a total of four I\O ports each 8 bit wide.
There are many versions of 8051 with different speeds and amount of on-
chip ROM and they are all compatible with the original 8051. This means that if
you write a program for one it will run on any of them.
The 8052 is an original member of the 8051 family. There are two other
members in the 8051 family of microcontrollers. They are 8052 and 8031. All
the three microcontrollers will have the same internal architecture, but they
differ in the following aspects.
1. 8031 has 128 bytes of RAM, two timers and 6 interrupts.
2. 89S51 has 4KB ROM, 128 bytes of RAM, two timers and 6 interrupts
3. 89S52 has 8KB ROM, 128 bytes of RAM, three timers and 8 interrupts.
Of the three microcontrollers, 89S51 is the most preferable. Microcontroller
supports both serial and parallel communication.
In the concerned project 89S52 microcontroller is used. Here microcontroller
used is AT89S52, which is manufactured by ATMEL laboratories.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 10
3.1.2 Description of 89S52 Microcontroller The AT89S52 provides the following standard features: 8Kbytes of Flash,
256bytes of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level
interrupt architecture, a full duplex serial port, on-chip oscillator, and clock
circuitry. In addition, the AT89S52 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 freezes the oscillator, disabling all other chip
functions until the next hardware reset.
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
AT89S52 is a powerful microcomputer which provides a highly flexible and
cost effective solution to many embedded control applications.
Features of Microcontroller (89S52)
1. Compatible with MCS-51 Products
2. 8 Kbytes of In-System Reprogrammable Flash Memory
3. Endurance: 1,000 Write/Erase Cycles
4. Fully Static Operation: 0 Hz to 24 MHz
5. Three-Level Program Memory Lock
6. 256 x 8-Bit Internal RAM
7. 32 Programmable I/O Lines
8. Three 16-Bit Timer/Counter
9. Eight vector two level Interrupt Sources
10. Programmable Serial Channel
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 11
3.1.3 Pin Configurations
Figure 3.2 Pin Diagram of 89S52
Pin Description
VCC Pin 40 provides Supply voltage to the chip. The voltage source is +5v
GND
Pin 20 is the grounded
Port 0 Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. As an
output port each pin can sink eight TTL inputs. When 1s are written to port 0
pins, the pins can be used as high-impedance inputs. Port 0 may also be
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 12
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 1 Port 1 is an 8-bit bidirectional I/O port with internal pull-ups from pin 1 to 8.
The Port 1 output buffers can sink/source four TTL inputs. When 1s are written
to Port 1 pins they are pulled high by the internal pull-ups and can be used as
inputs. 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 following table.
Port 2 Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28.
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 uses 16-bit addresses
(MOVX @ DPTR). In this application it uses strong internal pull-ups when
emitting 1s. During accesses to external data memory that uses 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 from pin 10 to 17.
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
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 13
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 also serves the functions of various special features of the AT89C52 as
listed below:
Table 3.1 Special Features of port3
RST Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this pin,
the microcontroller will reset and terminate all activities. A high on this pin for
two machine cycles while the oscillator is running resets the device.
ALE/PROG Address Latch is an output pin and is active high. Address Latch Enable 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.
PSEN Program Store Enable 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 FFFFH. Note, however, that if lock bit 1 is programmed, EA will be
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 14
internally latched on reset. EA should be strapped to VCC for internal program
executions. This pin also receives the 12-volt programming enable voltage
(VPP) during Flash programming when 12-volt programming is selected.
XTAL1 Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2 Output from the inverting oscillator amplifier.
3.1.5 RELAYS A relay is an electrically operated switch. Current flowing through the coil of
the relay creates a magnetic field which attracts a lever and changes the switch
contacts.The coil current can be on or off so relays have two switch positions
and they are double throw (changeover) switches.
Relays allow one circuit to switch a second circuit which can be
completely separate from the first. For example a low voltage battery circuit can
use a relay to switch a 230V AC mains circuit. There is no electrical connection
inside the relay between the two circuits; the link is magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 100mA for relays designed to operate from
lower voltages. Most ICs (chips) cannot provide this current and a transistor is
usually used to amplify the small IC current to the larger value required for the
relay coil. The maximum output current for the popular 555 timer IC is 200mA
so these devices can supply relay coils directly without amplification.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 15
Most relays are designed for PCB mounting but you can solder wires
directly to the pins providing you take care to avoid melting the plastic case of
the relay. The supplier's catalogue should show you the relay's connections. The
coil will be obvious and it may be connected either way round. Relay coils
produce brief high voltage 'spikes' when they are switched off and this can
destroy transistors and ICs in the circuit. To prevent damage you must connect a
protection diode across the relay coil.
The relay's switch connections are usually labelled COM, NC and NO:
· COM = Common, always connect to this, it is the moving part of the switch.
· NC = Normally Closed, COM is connected to this when the relay coil is off.
· NO = Normally Open, COM is connected to this when the relay coil is on.
· Connect to COM and NO if you want the switched circuit to be on when the
Relay coil is on.
· Connect to COM and NC if you want the switched circuit to be on when the
Relay coil is off.
Advantages of relays: · Relays can switch AC and DC, transistors can only switch DC.
· Relays can switch high voltages, transistors cannot.
· Relays are 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.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 16
CHAPTER 4
POWER SUPPLY
All digital circuits require regulated power supply. In this article we are going to
learn how to get a regulated positive supply from the mains supply.
Figure shows the basic block diagram of a fixed regulated power supply. Let us
go through each block.
4.1 TRANSFORMER
A transformer consists of two coils also called as “WINDINGS” namely
PRIMARY & SECONDARY. They are linked together through inductively
coupled electrical conductors also called as CORE. A changing current in the
primary causes a change in the Magnetic Field in the core & this in turn induces
an alternating voltage in the secondary coil. If load is applied to the secondary
then an alternating current will flow through the load. If we consider an ideal
condition then all the energy from the primary circuit will be transferred to the
secondary circuit through the magnetic field.
So
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 17
The secondary voltage of the transformer depends on the number of turns in the Primary
as well as in the secondary.
4.2 RECTIFIER
A rectifier is a device that converts an AC signal into DC signal. For
rectification purpose we use a diode, a diode is a device that allows current to
pass only in one direction i.e. when the anode of the diode is positive with
respect to the cathode also called as forward biased condition & blocks current
in the reversed biased condition.
Bridge Rectifier.
As the name suggests it converts the full wave i.e. both the positive & the
negative half cycle into DC thus it is much more efficient than Half Wave
Rectifier & that too without using a center tapped transformer thus much more
cost effective than Full Wave Rectifier. Full Bridge Wave Rectifier consists of
four diodes namely D1, D2, D3 and D4. During the positive half cycle diodes
D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3 conduct
thus the diodes keep switching the transformer connections so we get positive
half cycles in the output.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 18
If we use a center tapped transformer for a bridge rectifier we can get both
positive & negative half cycles which can thus be used for generating fixed
positive & fixed negative voltages.
4.3 VOLTAGE REGULATOR
A Voltage regulator is a device which converts varying input voltage into a
constant regulated output voltage. The IC 7805 is used which is a three terminal
voltage regulator, to get the constant output voltage of 5V.
3 Circuit diagram:
Fig 2.3. Circuit Diagram of power supply
IC 7805:
7805 is an integrated three-terminal positive fixed linear voltage regulator. It
supports an input voltage of 10 volts to 35 volts and output voltage of 5 volts. It
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 19
has a current rating of 1 amp although lower current models are available. Its
output voltage is fixed at 5.0V. The 7805 also has a built-in current limiter as a
safety feature. 7805 is manufactured by many companies, including National
Semiconductors and Fairchild Semiconductors.
The 7805 will automatically reduce output current if it gets too hot.The last two
digits represent the voltage; for instance, the 7812 is a 12-volt regulator. The
78xx series of regulators is designed to work in complement with the 79xx
series of negative voltage regulators in systems that provide both positive and
negative regulated voltages, since the 78xx series can't regulate negative
voltages in such a system.
Design specifications
=5V, =500mA, f=50HZ
Calculations
=
=10Ω
Ripple factor, =0.1
√ =>C=962.25
Choose C=1000 Transformer rating
= +
=20+
=20.25V = + 2( ) =20.25+ 2(0.6) =21.45
=
√ =13.47V Choose 15V-0-15V Transformer
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 20
CHAPTER-5
LIQUID CRYSTAL DISPLAY
LCD stands for Liquid Crystal Display. LCD is finding wide spread use
replacing LEDs (seven segment LEDs or other multi segment LEDs) because of
the following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in
contrast to LEDs, which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving
the CPU of the task of refreshing the LCD. In contrast, the LED must be
refreshed by the CPU to keep displaying the data.
4. Ease of programming for characters and graphics.
5.1 LCD SCREEN
LCD screen consists of two lines with 16 characters each. Each character
consists of 5x7 dot matrix. Contrast on display depends on the power supply
voltage and whether messages are displayed in one or two lines. For that reason,
variable voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer
is usually used for that purpose. Some versions of displays have built in
backlight (blue or green diodes). When used during operating, a resistor for
current limitation should be used (like with any LE diode).
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 21
CHAPTER-6
RS-232
6.1 RS 232:
RS-232 is simple, universal, well understood and supported but it
has some serious shortcomings as a data interface. The standards to 256kbps or
less and line lengths of 15M (50 ft) or less but today we see high speed ports on
our home PC running very high speeds and with high quality cable maxim
distance has increased greatly. The rule of thumb for the length a data cable
depends on speed of the data, quality of the cable.
.
Sub-D15 Male Sub-D15 Female
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 22
6.1.1 APPLICATIONS:
TIA/EIA-232-F
Battery-Powered Systems
Terminals
Modems
Computers
ESD Protection Exceeds 2000 V Per
MIL-STD-883, Method 3015
Package Options Include Plastic
Small-Outline (D, DW) Packages and
Standard Plastic (N) DIPs
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 23
CHAPTER-7
GSM MODEM
7.1 THEORY
Unlike mobile phones, a GSM modem doesn’t have a keypad and display to
interact with. It just accepts certain commands through a serial interface and
acknowledges for those. These commands are called as AT commands. There
are lists of AT commands to instruct the modem to perform its functions. Every
command starts with "AT". That’s why they are called as AT commands. AT
stands for attention.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 24
SMS Related AT Commands
AT It is used to test the connection.
AT+CMGF=1
It is used to instruct the modem to operate in text mode.
AT+CMGF=0 will instruct the modem to operate in
PDU mode.
AT+CMGS="mobile
number"
It is used to send a text message. It accepts the recipient
mobile number. As soon as this command is accepted
the modem waits for the message content. The text
message has to be sent sequentially and terminated by
the char 0x1A.
AT+CMGW="mobile
number"
It is used to store a message in the memory. After
execution it returns an index for the message stored. Eg:
AT+CMGW=1 . Here 1 is the index for the saved
message. Later this index is used to process the message
like deleting it or forwarding to the recipient number.
AT+CMGD=2
It is used to delete a message from the storage. The
index of the stored message is used to delete it. Above
command deletes the message with index 2.
In our simple project, the program waits for the mobile number to be entered
through the keyboard. When a ten digit mobile number is provided, the program
instructs the modem to send the text message using a sequence of AT
commands.
Testing your GSM modem
The GSM modem can be tested by connecting it with a PC. The modem
is equipped with a RS232 cable. Just use a Serial to USB converter and
connect it with the PC.
Now you can proceed with sending the commands to the modem using
any serial communication program like Hyperterminal, minicom etc.
Ensure the serial paramters are configured to 8N1 and the baudrate is set
to 9600bps.
For each command you send the modem acknowledges with a message.
Example: Just try sending "AT" to the modem. It sends back a result code
"OK" which states that the modem is responding. If it’s not working fine,
it sends "ERROR".
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 25
7.2 APPLICATIONS
1. All the parameters can be viewed on the mobile phone.
2. Most reliable.
3. Cost effective.
4. Supports innumerable sensors to the system.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 26
CHAPTER-8
SOFTWARE IMPLEMENTATION
8.1 MAIN PROGRAM
#include<stdio.h>
#include<reg51.h>
#include <string.h>
#include "lcd.h"
#include "serial.h"
unsigned char idx=0,lc=0,rr=0,mno='1',okm,okl;
unsigned char buf[10];
unsigned char RCFLAG;
void main(void)
int i=0,k=0;
mno='1';
com_init_mm();
IE=0X90;
lcdinit();
MSDelay(100);
lcd_puts("Pls wait ....\0") ;
MSDelay(100);
MSDelay(100);
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 27
lcdcmd(0x01);
lcdinit();
MSDelay(100);
lcd_puts("HomeAutomation\0") ;
MSDelay(100);
MSDelay(100);
while(1)
lc=0; idx=0; rr=0;
ser_puts("AT+CMGL=\"ALL\"\r\n\0"); MSDelay(100);
MSDelay(100);
lcdcmd(LINE1);
//lcddata(okm);
//lcddata(okl);
if ((okm='O') && (okl=='K'))
lcdcmd(LINE1+2);
lcd_puts("nO mESSAGES") ;
else if (RCFLAG)
lcdcmd(LINE1+2);
lcdcmd(0x01);
lcd_puts(buf);
P1=buf[1] & 0X0F;
lcdcmd(LINE1); lcddata((lc&0X0F)+0x30);
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 28
lcdcmd(LINE1+2); lcddata(mno);
//----------------------
lc=0; idx=0; rr=0;
RCFLAG=0;
MSDelay(500);
Del_msg(mno);
lc=0; idx=0; rr=0; RCFLAG=0;
void rx(void) interrupt 4
unsigned char t;
if(RI)
t=SBUF;
RI=0;
if (rr<=25) rr++;
if (rr==10) mno=t;
if (rr==3) okm=t;
if (rr==4) okl=t;
if (t==0x0A) lc++ ;
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 29
if (( idx<=1)&&(lc==2)) buf[idx++]=t;
if ( lc==3)
RCFLAG=1;
buf[idx]=0;
else if (TI) TI=0;
`
8.2 LCD PROGRAM
#include<stdio.h>
#include<reg51.h>
#include "lcd.h"
void lcdcmd(unsigned char value)
lcdready();
ldata=value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 30
void lcddataxy(unsigned char x, unsigned char y, unsigned char value)
void lcddata( unsigned char value)
lcdready();
ldata=value;
rs=1;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
void lcdready(void)
MSDelay(10);
return;
void MSDelay(unsigned int itime)
unsigned int i,j,k ;
for(k=0;k<itime;k++)
for(i=0;i<100;i++)
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 31
for(j=0;j<1;j++);
void lcdinit(void)
lcdcmd(0X38);
lcdcmd(0Xe);
lcdcmd(0X01);
lcdcmd(0X06);
lcdcmd(0X80);
lcdcmd(0X84);
void lcdPutHexbyte(unsigned char v)
unsigned char asc[] = "0123456789ABCDEF";
unsigned char t,c;
t= ((unsigned char) (v)) ;
c= (t>>4) &0x0f;
lcddata(asc[c]);
c=(t & 0x0f);
lcddata(asc[c]);
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 32
void lcd_puts(unsigned char *str) //Function to send string to LCD
int i=0;
while(str[i]!='\0')
lcddata(str[i]);
i++;
MSDelay(20);
void lcd_nputs(unsigned char *str,unsigned char n) //Function to send string to
LCD
int i=0;
for( i=0;(i<=n)&&( str[i]!=0);i++ )
while(str[i]!='\0')
lcddata(str[i]);
MSDelay(20);
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 33
8.3 SERIAL PROGRAM
#include<stdio.h>
#include<reg51.h>
#include <string.h>
#include "lcd.h"
#include "serial.h"
extern void com_init_mm(void)
TMOD=0x22;
TH1=-3;
SCON =0X50;
TR1= 1;
PS = 0;
TH0= 25 ;
TR0=1;
void Del_msg(unsigned char c)
unsigned char y;
y=c;
lcdcmd(LINE2);
lcd_puts("AT+CMGD=\0"); lcddata(y);MSDelay(100);
if (y=='1') ser_puts("AT+CMGD=1,0\0"); MSDelay(100);
if (y=='2') ser_puts("AT+CMGD=2,0\0"); MSDelay(100);
if (y=='3') ser_puts("AT+CMGD=3,0\0"); MSDelay(100);
if (y=='4') ser_puts("AT+CMGD=4,0\0"); MSDelay(100);
if (y=='5') ser_puts("AT+CMGD=5,0\0"); MSDelay(100);
if (y=='6') ser_puts("AT+CMGD=6,0\0"); MSDelay(100);
if (y=='7') ser_puts("AT+CMGD=7,0\0"); MSDelay(100);
if (y=='8') ser_puts("AT+CMGD=8,0\0"); MSDelay(100);
if (y=='9') ser_puts("AT+CMGD=9,0\0"); MSDelay(100);
ser_putc('\r');
ser_putc('\n');
MSDelay(500);
MSDelay(500);
MSDelay(500);
MSDelay(500);
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 34
MSDelay(500);
MSDelay(500);
MSDelay(500);
MSDelay(500);
MSDelay(500);
MSDelay(500);
void Send_sms(unsigned char * msg)
ser_puts("AT+CMGF=1\r\n\0");
MSDelay(500);
ser_puts("AT+CMGS=\"+917411461316\"\r\n\0");
ser_puts(msg);
ser_putc(CNT_Z);
MSDelay(500);
void ser_putc(unsigned char s)
SBUF=s;
extern void ser_puts(unsigned char * s)
unsigned char id=0,jj;
while (s[id]!='\0')
jj=s[id];
ser_putc(s[id]) ;
MSDelay(10);
id++;
CHAPTER 9
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 35
CONCLUSIONS
8.1 Conclusion The project “GSM BASED WIRELESS HOME AUTOMATION
SYSTEM” has been successfully designed and tested. Integrating features of all
the hardware components used have developed it. Presence of every module has
been reasoned out and placed carefully thus contributing to the best working of
the unit. Secondly, using highly advanced IC’s and with the help of growing
technology the project has been successfully implemented.
Embedded systems are emerging as a technology with high potential.
In the past decades micro processor based embedded system ruled the market.
The last decade witnessed the revolution of Microcontroller based embedded
systems. With regards to the requirements gathered the manual work and the
complexity in counting can be achieved with the help of electronic devices.
WIRELESS HOME AUTOMATION SYSTEM USING GSM
Dept. Of Telecommunication, SIT Tumkur Page 36
REFERENCES: 1. 8051-MICROCONTROLLER AND EMBEDDED SYSTEM. Mohd. Mazidi. 2. EMBEDDED SOFTWARE PRIMER David .E. Simon 3. The 8051 MICROCONTROLLER K.J.AYALA