Documente Academic
Documente Profesional
Documente Cultură
1.Introduction
2. Literature survey
4.System specification
5.Design of solution
6.Implementation
8.System testing
10.References
List of Figures
Intelligent system for Gas, Human detection and Temperature Monitor control using GSM
Aim: The main aim of this project is to develop intelligent system for gas, Human detection and
Temperature Monitor control using GSM
Project Description:
In this project we are connecting different sensors like Temperature, gas and PIR sensor to the
controller. The Controller continuously monitors the values from all the sensors. If the values are not with
in the range it will take decision and indicates using GSM network. Any person can receive the SMS sent
by GSM modem and further can decide what to do.In this project we are implementing safety and at the
same time security also.The safety is against gas and temperature and security is like to detect human
being in prohibited areas.This kind of system is useful in areas like industries where we should avoid the
existence of gas and fire at any cost.
Block diagram:
CONTROLLING
LM35
AT89C51 PART
GAS GSM
MODEM
PIR
SENSOR
Hardware :
AT89C51
GSM Modem
LM35
Software:
Keil uVision 2
8051 programmer
Application Areas:
Security systems
CHAPTER 1
Introduction
1.1Overview
The overview of this project is to implement intelligent system which can detect temperature,gas
and humanbeings using 8051 controller.8051 is very efficient architechture which can be used
for low end security systems and GSM is widely adapted technology for communication.
1.2Purpose
Purpose of the current work is to study and analyse the design of intelligent system with the help
of 8051 controller and GSM technology..
1.3 Scope
Current work focuses on how to effectively use GSM technology and 8051 controller for
intelligent security systems.
Literature survey
An embedded system is a special-purpose computer system designed to perform one or a few dedicated
functions, often with real-time computing constraints. It is usually embedded as part of a complete device
including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal
computer, can do many different tasks depending on programming. Embedded systems control many of
the common devices in use today.
Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the
size and cost of the product, or increasing the reliability and performance. Some embedded systems are
mass-produced, benefiting from economics of scale. Physically, embedded systems range from portable
devices such as digital watches and mp4 players, to large stationary installations like traffic lights, factory
controllers, or the systems controlling nuclear power stations. Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large
chassis or enclosure.
In general, "embedded system" is not an exactly defined term, as many systems have some element of
programmability. For example, handheld computers share some elements with embedded systems — such
as the operating systems and microprocessors which power them — but are not truly embedded systems,
because they allow different applications to be loaded and peripherals to be connected
2.2 Characteristics
1. Embedded systems are designed to do some specific task, rather than be a general-purpose
computer for multiple tasks. Some also have real-time performance constraints that must be met,
for reasons such as safety and usability; others may have low or no performance requirements,
allowing the system hardware to be simplified to reduce costs.
2. Embedded systems are not always standalone devices. Many embedded systems consist of small,
computerized parts within a larger device that serves a more general purpose. For example, the
features an embedded system for tuning the strings, but the overall purpose of the Robot Guitar
is, of course, to play music. Similarly, an embedded system in automobiles provides a specific
function as a subsystem of the car itself.
3. The program instructions written for embedded systems are referred to as firmware, and are
stored in read-only memory or flash memory chips. They run with limited computer hardware
resources: little memory, small or non-existent keyboard and/or screen.
A bye product of microprocessor development was the micro controller. The same fabrication
techniques and programming concepts that make possible general-purpose microprocessor also
yielded the micro controller.
Despite it’s relatively old age, the 8051 is one of the most popular micro
controllers in use today. Many derivative micro controllers have since been developed that are
based on--and compatible with--the 8051. Thus, the ability to program an 8051 is an important
skill for anyone who plans to develop products that will take advantage of micro controllers.In
8051 architecture there are so many controllers developed by different semiconductor
companies.Here we are going to use the controller manufactured by Atmel semiconductors
which is AT89C51.All the controllers belongs to 8051 architecture follow harward architecture
and CISC design.
Newer versions of the standard were backward-compatible with the original GSM system. For
example, Release '97 of the standard added packet data capabilities by means of General Packet
Radio Service(GPRS). Release '99 introduced higher speed data transmission using Enhanced
Data Rates for GSM Evolution(EDGE).
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 first-generation systems.
Most 3G GSM EDGE networks in Europe operate in the 2100 MHz frequency band.
Now a days intelligent systems became very serious issue at any where.To get good results at
any time, we need a system which can work at any circumstances.In this project we are going to
use GSM technology which is widely accepted technology for mobile communications.With the
use of 8051 controller and GSM technogy we are going to implement an intelligent system.
CHAPTER 3
Problem formulation
The problem with the intelligent systems is they should work at any time without any fail.Here in
this project we are going to implement safety against temperature and gas.Along with this human
detection also we are implementing.These things are very important in areas like industries
where we should monitor the status of temperature and gas at the same time if it ios restricted
area we need to monitor the presense of human beings also.
CHAPTER 4
System Specification
The 8051 micro controller unit is a high-performance, synthesizable 80C51 function specifically
designed for reusability. It can operate at frequencies up to 14 MHz in FLEX® devices.
Program memory—Internal_Program_Memory
Data memory—Internal_Data_Memory
The 8051 is an 8-bit microprocessor originally designed in the 1980's by Intel that has gained
great popularity since its introduction. Its standard form includes several standard on-chip
peripherals, including timers, counters, and UART's, plus 4kbytes of on-chip program memory
and 128 bytes (note: bytes, not Kbytes) of data memory, making single-chip implementations
possible. Its hundreds of derivatives, manufactured by several different companies (like Philips)
include even more on-chip peripherals, such as analog-digital converters, pulse-width
modulators, I2C bus interfaces, etc. Costing only a few dollars per IC, the 8051 is estimated to be
used in a large percentage (maybe 1/2?) all embedded system products. The 8051 memory
architecture includes 128 bytes of data memory that are accessible directly by its instructions. A
32-byte segment of this 128-byte memory block is bit addressable by a subset of the 8051
instructions, namely the bit-instructions. External memory of up to 64 Kbytes is accessable by a
special "movx" instruction. Up to 4 Kbytes of program instructions can be stored in the internal
memory of the 8051, or the 8051 can be configured to use up to 64 Kbytes of external program
memory The majority of the 8051's instructions are executed within 12 clock cycles.
1 A T89C 51 40
2 P 1 .0 V C C 39
3 P 1 .1 P 0 .0 /A D 0 38
4 P 1 .2 P 0 .1 /A D 1 37
5 P 1 .3 P 0 .2 /A D 2 36
6 P 1 .4 P 0 .3 /A D 3 35
7 P 1 .5 P 0 .4 /A D 4 34
8 P 1 .6 P 0 .5 /A D 5 33
9 P 1 .7 P 0 .6 /A D 6 32
10 R S T P 0 .7 /A D 7 31
11 P 3 .0 /R X D E A /V P P 30
12 P 3 .1 /T X D A L E /P R O G 29
13 P 3 .2 /IN T 0 P S E N 28
14 P 3 .3 /IN T 1 P 2 .7 /A 1 5 27
15 P 3 .4 /T 0 P 2 .6 /A 1 4 26
16 P 3 .5 /T 1 P 2 .5 /A 1 3 25
17 P 3 .6 /W R P 2 .4 /A 1 2 24
18 P 3 .7 /R D P 2 .3 /A 1 1 23
19 X TA L2 P 2 .2 /A 1 0 22
20 X TA L1 P 2 .1 /A 9 21
G N D P 2 .0 /A 8
Figure 4.1: AT89C51 Pin Diagram
8051 has four I/O port (P0, P1, P2, and P3), ored in an external ROM or EPROM chip or if
you are using external RAM chips) you may not use P0 or P2. This is because the 8051 uses
ports P0 and P2 to address the external memory. Thus if you are using external RAM or code
memory you may only use ports P1 and P3 for your own use. One strong point of the 8051 is the
way it handles interrupts. Most interrupt routines are very short, and generally can fit into the 8-
byte area. Of course if your interrupt routine is longer, you can still jump to the appropriate
routine from within the 8 byte interrupt region. The 8051 instruction set is optimized for the one-
bit operations so often desired in real-world, real-time control applications. The Boolean
processor provides direct support for bit manipulation. This leads to more efficient programs
that need to deal with binary input and output conditions inherent in digital-control problems.
Bit addressing can be used for test pin monitoring or program control flags.
4.5.4.Data pointer
The SFRs DPL and DPH work together work together to represent a 16-bit value called
the data pointer. The data pointer is used in operations regarding external RAM and some
instructions code memory. It is a 16-bit SFR and also an addressable SFR.
4.6.1.PORT 0
Port 0 pins may serve as inputs, outputs, or, when used together, as a bi directional low-
order address and data bus for external memory. To configure a pin as input, 1 must be written
into the corresponding port 0 latch by the program. When used for interfacing with the external
memory, the lower byte of address is first sent via PORT0, latched using Address latch enable
(ALE) pulse and then the bus is turned around to become the data bus for external memory.
4.6.2.PORT 1
Port 1 is exclusively used for input/output operations. PORT 1 pins have no dual
function. When a pin is to be configured as input, 1 is to be written into the corresponding Port 1
latch.
4.6.3.PORT 2
Port 2 may be used as an input/output port. It may also be used to supply a high –order
address byte in conjunction with Port 0 low-order byte to address external memory. Port 2 pins
are momentarily changed by the address control signals when supplying the high byte a 16-bit
address. Port 2 latches remain stable when external memory is addressed, as they do not have to
be turned around (set to 1) for data input as in the case for Port 0.
4.6.4.PORT 3
Port 3 may be used to input /output port. The input and output functions can be
programmed under the control of the P3 latches or under the control of various special function
registers. Unlike Port 0 and Port 2, which can have external addressing functions and change all
eight-port b se, each pin of port 3 maybe individually programmed to be used as I/O or as one of
the alternate functions. The Port 3 alternate uses are:
Interrupt Address
RESET 0000
IE0 (External interrupt 0003
0)
TF0 (Timer 0 interrupt) 000B
IE1 (External interrupt 0013
1)
TF1 (Timer 1 interrupt) 001B
SERIAL 0023
EA disable all interrupts. If EA=0, now interrupt is acknowledged. If EA=1, each interrupt
source is individually enabled or disabled by setting its enable a lap bit.
---- Not implemented, reserved for future use.
ET2 Enables or disables timer 2 overflow or capturer interrupt.
ES Enables or disables the serial port interrupt.
ET1 Enables or disables timer 1 overflow interrupt.
EX1 Enables or disables timer external interrupt 1.
ET0 Enables or disables timer 0 overflow interrupt.
EX0 Enables or disables timer external interrupt 0.
4.10.MAX232 Driver/Receiver:
This module is primary of interest for people building their own electronics with an RS-232
interface. Off-the-shelf computers with RS-232 interfaces already contain the necessary
electronics, and there is no need to add the circuitry as described here.
Serial RS-232 (V.24) communication works with voltages (-15V ... -3V for high [sic]) and
+3V ... +15V for low [sic]) which are not compatible with normal computer logic voltages. On
the other hand, classic TTL computer logic operates between 0V ... +5V (roughly 0V ... +0.8V
for low, +2V ... +5V for high). Modern low-power logic operates in the range of 0V ... +3.3V or
even lower.
So, the maximum RS-232 signal levels are far too high for computer logic electronics, and the
negative RS-232 voltage for high can't be grokked at all by computer logic. Therefore, to receive
serial data from an RS-232 interface the voltage has to be reduced, and the low and high voltage
level inverted. In the other direction (sending data from some logic over RS-232) the low logic
voltage has to be "bumped up", and a negative voltage has to be generated, too.
-----------------------------------------------
All this can be done with conventional analog electronics, e.g. a particular power supply and a
couple of transistors or the once popular 1488 (transmitter) and 1489 (receiver) ICs. However,
since more than a decade it has become standard in amateur electronics to do the necessary
signal level conversion with an integrated circuit (IC) from the MAX232 family (typically a
MAX232A or some clone). In fact, it is hard to find some RS-232 circuitry in amateur
electronics without a MAX232A or some clone.
The MAX232 from Maxim was the first IC which in one package contains the necessary drivers
(two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It became
popular, because it just needs one voltage (+5V) and generates the necessary RS-232 voltage
levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry.
Circuitry designers no longer need to design and build a power supply with three voltages (e.g.
-12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a
simple 78x05 voltage converter.
The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the
MAX232A is much more often used (and easier to get) than the original MAX232, and the
MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232
needs.
It should be noted that the MAX232(A) is just a driver/receiver. It does not generate the
necessary RS-232 sequence of marks and spaces with the right timing, it does not decode the RS-
232 signal, it does not provide a serial/parallel conversion. All it does is to convert signal voltage
levels. Generating serial data with the right timing and decoding serial data has to be done by
additional circuitry, e.g. by a 16550 UART or one of these small micro controllers (e.g. Atmel
AVR, Microchip PIC) getting more and more popular.
The MAX232 and MAX232A were once rather expensive ICs, but today they are cheap. It has
also helped that many companies now produce clones (ie. Sipex). These clones sometimes need
different external circuitry, e.g. the capacities of the external capacitors vary. It is recommended
to check the data sheet of the particular manufacturer of an IC instead of relying on Maxim's
original data sheet.
The original manufacturer (and now some clone manufacturers, too) offers a large series of
similar ICs, with different numbers of receivers and drivers, voltages, built-in or external
capacitors, etc. E.g. The MAX232 and MAX232A need external capacitors for the internal
voltage pump, while the MAX233 has these capacitors built-in. The MAX233 is also between
three and ten times more expensive in electronic shops than the MAX232A because of its
internal capacitors. It is also more difficult to get the MAX233 than the garden variety
MAX232A.A similar IC, the MAX3232 is nowadays available for low-power 3V logic.
4.11 MAX232Application:
The MAX232(A) has two receivers (converts from RS-232 to TTL voltage levels) and two
drivers (converts from TTL logic to RS-232 voltage levels). This means only two of the RS-232
signals can be converted in each direction. The old MC1488/1498 combo provided four drivers
and receivers.
Typically a pair of a driver/receiver of the MAX232 is used for TX and RX and the second one
for CTS and RTS. There are not enough drivers/receivers in the MAX232 to also connect the
DTR, DSR, and DCD signals. Usually these signals can be omitted when e.g. communicating
with a PC's serial interface. If the DTE really requires these signals either a second MAX232 is
needed, or some other IC from the MAX232 family can be used (if it can be found in consumer
electronic shops at all). An alternative for DTR/DSR is also given below.Maxim's data sheet
explains the MAX232 family in great detail, including the pin configuration and how to connect
such an IC to external circuitry. Exactly to connect the RS-232 signals to the IC. So here is one
possible example:
MAX232 Pin Nbr. MAX232 Pin Name Signal Voltage DB9 Pin
7 T2out CTS RS-232 7
13 R1in RX RS-232 2
14 T1out TX RS-232 3
15 GND GND 0 5
4.12.LM35
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius (Centigrade) temperature.
The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the
user is not required to subtract a large constant voltage from its output to obtain convenient
Centigrade scaling. The LM35 does not require any external calibration or trimming to provide
typical accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C
temperature range.
Low cost is assured by trimming and calibration at the wafer level. The LM35’s low output
impedance,linear output, and precise inherent calibration make interfacing to readout or control
circuitry especially easy. It can be used with single power supplies, or with plus andminus
supplies. As it draws only 60 μA from its supply, it hasvery low self-heating, less than 0.1°C in
still air. The LM35 is rated to operate over a −55° to +150°C temperature range,while the
LM35C is rated for a −40° to +110°C range (−10°with improved accuracy).
The LM35 series is available packaged in hermetic TO-46 transistor packages, while the
LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The
LM35D is also available in an 8-lead surface mount small outline package and a
plastic TO-220 package.
4.12.1.Features
4.13.GAS sensor
The sensor we are going to use is LPG gas sensor MQ-6. This is a simple-to-use liquefied petroleum
gas (LPG) sensor, suitable for sensing LPG (composed of mostly propane and butane) concentrations in
the air. The MQ-6 can detect gas concentrations anywhere from 200 to 10000ppm.
This sensor has a high sensitivity and fast response time. The sensor's output is an analog resistance. The
drive circuit is very simple; all you need to do is power the heater coil with 5V, add a load resistance, and
connect the output to an ADC.
4.13.1.Features
They are used in gas leakage detecting equipments in family and industry, are suitable for
detecting of LPG, iso-butane, propane, LNG, avoid the noise of alcohol and cooking fumes and
cigarette smoke. Sensor composed by micro AL2O3 ceramic tube, Tin Dioxide (SnO2) sensitive
layer, measuring electrode and heater are fixed into a crust made by plastic and stainless steel
net. The heater provides necessary work conditions for work of sensitive components. The
enveloped MQ-6 have 6 pin ,4 of them are used to fetch signals, and other 2 are used for
providing heating current.
Pyroelectric devices, such as the PIR sensor, have elements made of a crystalline material that
generates an electric charge when exposed to infrared radiation. The changes in the amount of
infrared striking the element change the voltages generated, which are measured by an on-board
amplifier. The devicecontains a special filter called a Fresnel lens, which focuses the infrared
signals onto the element. As the ambient infrared signals change rapidly, the on-board amplifier
trips the output to indicate motion.
The PIR Sensor has a range of approximately 20 feet. This can vary with environmental
conditions. The sensor is designed to adjust to slowly changing conditions that would happen
normally as the day progresses and the environmental conditions change, but responds by
making its output high when sudden changes occur, such as when there is motion.
The ADC0808, ADC0809 data acquisition component is a monolithic CMOS device with an 8-
bit analog-to-digital converter,8-channel multiplexer and microprocessor compatible control
logic. The 8-bit A/D converter uses successive approximation as the conversion technique. The
converter features a high impedance chopper stabilized comparator, a 256R voltage divider with
analog switch tree and a successive approximation register. The 8-channel multiplexer can
directly access any of 8-single-ended analog signals. The device eliminates the need for external
zero and full-scale adjustments. Easy interfacing to microprocessors is provided by the latched
and decoded multiplexer address inputs and latched TTL TRI-STATE outputs. The design of the
ADC0808, ADC0809 has been optimized by incorporating the most desirable aspects of several
A/Dconversion techniques. The ADC0808, ADC0809 offers highspeed, high accuracy, minimal
temperature dependence, excellentlong-term accuracy and repeatability, and consumes minimal
power. These features make this device ideally suitedto applications from process and machine
control to consumerand automotive applications. For 16-channel multiplexer with common
output .
4.16 LCD
AT+CSCA="+xxxxx" Set your SMS center's number. Check with your provider.
AT+CNMI=1,2,0,0,0 Set how the modem will response when a SMS is received
When a new SMS is received by the GSM modem, the DTE will receive the following
AT+CMGD=3 <Enter> To clear the SMS receive memory location in the GSM modem.
CHAPTER 5
System Design
Designing of this system is possible when you select the specific controller to suite.For this we
selected 8051 controller.With the help of 8051 controller intelligent system can be developed by
connecting LM35,gas sensor and PIR sensor ant the same time GSM modem also.
CHAPTER 6
Implementation
The applications as discussed in the design are implemented and the source code related to the
current work is pasted in the appendix.
CHAPTER 7
System Testing
The system can be tested with the use of KEIL compiler.This one we are using to write programs
for 8051 controller.After writing programs using 8051 programmer we can dump code in to the
controller.Gsm modem we can connect to the controller by using one UART of 8051.Now this
controller will monitor the status the three different sensors and sends message if there is any
problem.
CHAPTER 8
This chpater lists down the results realized from the practical work and examines whether
ideas/solution approaches recommended in research are met by the practical implementation.
Because now a days GSM technology became very popular,here its very easy to use for
intelligent systems with the help of 8051 controller.In all low end applications now a days we
are using 8051 controllers like industrial automation and data acquisition.
CHAPTER 9
The controller we used having the following featurtes like 8 bit 8051 architecture in a tiny 40 pin
DIP package,128B RAM and 4kB on-chip Flash Program Memory. For low end applications this
controller is very easy to use and at the same time GSM also widely accepted protocol for mobile
communication.
Future Scope
In future small scale intelligent systems based on 8051 controllers can be widely used along with
the help of GSM technology.
References
[1] 8051 Architecture and Programming by Mazidi
[5] Wikipedia
[6]Sparkfun.com
[7]national.com
Source code:
sbit adc_ale=P1^4;
//DATA0-DATA7 TO P2
unsigned char i;
void GSM_Init(void);
void Modem_send(unsigned char *);
void send_sms(unsigned char *,unsigned char *,unsigned char *,unsigned char *,unsigned char
*);
void uart_init(void);
main()
{
unsigned char j,key,pw[5];
lcd_init();
lcd_print("LCD is Ready");
Delay1(100);
uart_init();
lcd_clear();
lcd_print("uart is Ready");
Delay1(100);
GSM_Init();
Delay1(50);
lcd_clear();
Delay1(100);
cd_print("gsm is Ready");
while(1)
lcd_clear();
adc_ale=0;
adc_start=0
adc_a=0;
adc_b=0;
adc_c=0;
Delay1(10);
adc_ale=1;
Delay1(10);
adc_start=1;
Delay1(10);
adc_ale=0;
Delay1(10);
adc_start=0;
Delay1(10);
Value=P1;
If(value>200)
{
send_sms("AT+CMGS=\"","\"",”gas detected”);
adc_a=0;
adc_b=0;
adc_c=0;
Delay1(10);
adc_ale=1;
Delay1(10);
adc_start=1;
Delay1(10);
adc_ale=0;
Delay1(10);
adc_start=0;
Delay1(10);
Value=P1;
If(value>50)
send_sms("AT+CMGS=\"","\"",”Temp high”);
If(PIR==1)
send_sms("AT+CMGS=\"","\"",”object detected”);
//===============================================
//Delays
void Delay_1ms()
{
unsigned int d;
for( d=0;d<335;d++);
}
void Delay_30ms()
{
unsigned char j;
for(i=0;i<15;i++)
for(j=0;j<95;j++);
}
void Delay(unsigned int v) //Here we are generating ms delay
{
unsigned int t;
for(t=0;t<v;t++)
Delay_1ms();
}
//===============================================
void lcd_init()
{
Delay(1); //only for avoiding warning
Delay_30ms();
lcd_cmd(0x38);
Delay_30ms();
lcd_cmd(0x01);
Delay_30ms();
lcd_cmd(0x0C);
Delay_30ms();
lcd_cmd(0x06);
Delay_30ms();
lcd_cmd(0x80);
Delay_30ms();
}
//===============================================
void lcd_clear(void)
{
lcd_cmd(0x01);
lcd_cmd(0x80);
}
//===============================================
//THIS IS THE FUNCTION FOR WRITE THE DATAS IN INSTRUCTION REG
}
//===============================================
//DISPLAY STRING IN of data in LCD
void lcd_print(unsigned char *str)
{
while(*str!='\0')
{
LCD =*str;
RS =1;
RW =0;
EN =1;
Delay_30ms();
EN =0;
str++;
}
}
//===============================================//
// Delays //
//===============================================//
void Delay_1ms()
{
unsigned int d;
for( d=0;d<335;d++);
}
//===============================================
void Delay_30ms()
{
unsigned char j;
for(i=0;i<15;i++)
for(j=0;j<95;j++);
}
//===============================================
void Delay(unsigned int v) //Here we are generating ms
delay
{
unsigned int t;
for(t=0;t<v;t++)
Delay_1ms();
}
//===============================================
void MSDelay(unsigned char itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1257;j++);
}
//===============================================
void GSM_Init(void)
{
lcd_clear();
lcd_print("GSM Initializing");
Delay(200);
Modem_send("AT");
Modem_send("ATE0");
Modem_send("AT+CSMS=0");
Modem_send("AT+IPR=9600");
Modem_send("AT+CMGF=1");
Modem_send("AT&W");
Modem_send("AT+CNMI=2,1,0,0,0");
lcd_print("GSM Initialized");
Delay(200);
}
void Modem_send(unsigned char *ch)
{
unsigned char cha;
while(*ch)
{
SBUF = *ch;
while(TI == 0);
TI = 0;
ch++;
}
Enter();
TI = 0;
RI = 0;
while(1)
{
while(RI == 0);
RI = 0;
cha = SBUF;
if(cha == 'O');
while(RI == 0);
RI = 0;
cha = SBUF;
if(cha == 'K')
break;
SBUF = 'A';
while(TI == 0);
TI = 0;
SBUF = '/';
while(TI == 0);
TI = 0;
}
TI = 0;
RI = 0;
}
void send_sms(unsigned char *cmd1,unsigned char *cmd2,unsigned char *ch1)
{
unsigned char number[11]={"9885514414"};
unsigned char cha='X',P;
while(*cmd1)
{
RI=0;
TI=0;
SBUF=*cmd1;
while(TI==0);
TI=0;
RI=0;
cmd1++;
}
for(P=0;P<10;P++)
{
RI=0;
TI=0;
SBUF=number[P];
while(TI==0);
TI=0;
RI=0;
}
while(*cmd2)
{
RI=0;
TI=0;
SBUF=*cmd2;
while(TI==0);
TI=0;
RI=0;
cmd2++;
}
Enter();
while(cha!='>')
{
while(RI==0);
cha=SBUF;
RI=0;
}
for(P=0;P<10;P++)
{
RI=0;
TI=0;
SBUF=*ch1;
while(TI==0);
TI=0;
RI=0;
ch1++;
}
for(P=0;P<15;P++)
{
RI=0;
TI=0;
SBUF=*ch2;
while(TI==0);
TI=0;
RI=0;
ch2++;
}
for(P=0;P<15;P++)
{
RI=0;
TI=0;
SBUF=*ch3;
while(TI==0);
TI=0;
RI=0;
ch3++;
}
RI=0;
TI=0;
SBUF=0x1A;
while(TI==0);
TI=0;
RI=0;
}
void uart_init(void)
{
SCON = 0x50; //Mode 1..8 bit data,..1 stop bit,..1 start bit
TMOD = 0x20; //Timer 1....Mode 2...8 bit Auto Reload
TL1 = 0xFD;
TH1 = 0xFD; //Baud Rate 9600
TR1 = 1;
}