Академический Документы
Профессиональный Документы
Культура Документы
Abstract--In this work, a microcontroller based SMS gateway case microcontroller IC plays an important role in
for GSM mobile has been designed and developed. Most of the controlling any devices or appliances. Here microcontroller
T
SMS gateway system was controlled by PC based software also gets instruction through SMS and then goes for the
where microcontroller only used for controlling and sending next step. The overall system then becomes both costly and
status of devices or any appliances connected with the system.
An Ericsson T68i, one of the cheapest GSM mobile phone sets
power consuming as the PC works round the clock. If that
available with most of the advanced features, has been PC is a clone then may not run for all the time and power is
interfaced with a PC via RS232 serial port. The SMS packet a matter of availability and cost also.
has been analyzed and its different fields have been identified The serial communication between PC and Mobile uses
ES
for the Grameen Phone, the largest GSM operator in RS232 protocol. Data in digital form i.e. „1‟ and „0‟ for
Bangladesh. Then the PC has been removed from the system RS232 port are represented by the voltage level of 3V to
and the transmission and reception technique of SMS have 25V and -3V to -25V respectively. But Mobile phones in
been implemented into the PIC microcontroller. The general use only 3V or 1.8V for its internal communication.
developed system has been tested successfully. The system is Therefore, to make communication between the GSM
also simple, smarter, portable, cost effective (as the PC has
been removed) and low power consuming.
Mobile and PC a voltage conversion device called
MAX232 plays an important role here [2].
Index term—Microcontroller, SMS, LCD, PICmicro In most of the centralized device-controlling system, PC
is interfaced to mobile and then used as a server to control
I. INTRODUCTION the devices through the developed software. PC-based-
People now in the age of modern science need the real- software is easy to develop and control, so people usually
time information whenever they desire. And this can be depends on PC. PIC Single-Chip-Microcontrollers are
A
achieved by the various technological advancement of sufficient enough to encode and decode the sending and
communication system. Introduction of GSM mobile phone receiving message through GSM mobile and control the
is one of them which are no longer a luxurious item, easily devices according to the instruction given by the SMS. PIC
available, accessible, portable, cost-effective and have microcontroller can also be used as a web-server by
device availability throughout the country and the world removing the mobile device at the end used part so that user
even. So, the idea of introducing SMS should be an can also control the appliances through the Internet. The
PIC are also less-expensive as well as they need not much
IJ
(a)
Serial
Data cable
(b)
Figure 1: Block diagram of (a) PC based (b) microcontroller based SMS Gateway
But the resources, documentation and procedure are not The serial RS232 connection is driven by the PIC
available to interface the PIC with GSM mobile. Therefore USART with a high data transmission rate. Data in the
in this present work, an attempt has been taken to design a digital form i.e. „1‟ and „0‟ for PIC USART are represented
PIC microcontroller based SMS gateway for GSM mobile by the voltage level of 5V and 0V respectively. Therefore,
system in a well-organized and systematic way so that any to make communication between the GSM Mobile and
one can develop the interfacing part and design the PIC for Microcontroller, no voltage conversion device is needed.
SMS gateway to control any appliances or for any other
security purpose. A system has been developed and tested A. RS232 serial communication
as a prototype for either remote or accessible appliance RS232 is the most known serial port used to interface
T
controlling. Figure 1 shows the block diagram of (b) the and transmit the desired data in communication. Though
developed PIC based SMS Gateway which replaces the the serial port is hard enough to program than the parallel
existing (a) PC based SMS Gateway system for GSM port, this is the most effective method in which the data
Mobile. transmission requires less wire (only three links – transmit,
receive and common ground) that yields the low system
II. SYSTEM ARCHITECTURE , INTERFACING cost. The two pins TxD & RxD are used for transmit and
ES
& HARDWARE CONFIGURATION
This system runs on a 28 pins flash-based 8-bit CMOS
microcontroller, PIC 16F876 with a 4 MHz external clock.
The chip has up to 8K x 14 words of FLASH Program
Memory, 368 x 8 bytes of Data Memory (RAM) and 256 x
8 bytes of EEPROM Data Memory. It has more I/O
capabilities than the other PIC of this series and also has
receive data between the communication devices. There are
some other lines in this port which are set as default [4].
The data format frame for both the PIC and RS232
protocol has been shown in figure 2. For checking the
RS232 communication between microcontroller and mobile
phone, another PC with running hyper terminal (the Micro
Soft standard terminal program) has been used and Mobile
two PWM which are useful to control any kind of motors has been connected to the GND, RxD and TxD to the serial
speed [3]. port of that PC via a MAX232 voltage conversion IC.
A
(a)
IJ
(b)
Figure 2: Format of data frame for serial communication (a) for PIC (b) for RS-232 I/O.
B. PIC USART Configuration RC6 and RC7 for the PIC 16F876 and RC6 & RC7 act as
USART, Universal Synchronous Asynchronous Receiver data transmitter (Tx) and receiver (Rx) respectively
Transmitter, also known as Serial Communications [3].Data is usually transmitted in 8-bit words (9 is an
Interface can be configured into two operating mode called option), with the least significant bit sent first. Standard
synchronous and asynchronous. In this present work the clock (baud) rate is used so that the receiver can sample the
later one has been used which is accessed through the pins
Input at the same rate as the data is sent. 9600 baud is used previous load. As soon as the STOP bit is transmitted, the
in this work, i.e., the bits are transmitted at about 10kbps. TSR is loaded with new data from the TXREG register (if
In this mode, the USART uses standard non-return-to available). Once the TXREG register transfers the data to
zero (NRZ) format (one START bit, eight or nine data bits, the TSR register, the TXREG register is empty and flag bit
and one STOP bit). The most common data format is 8-bits. TXIF (PIR1<4>) is
An on-chip, dedicated, 8-bit baud rate generator can be
used to derive standard baud rate frequencies from the D. Transmitter Configuration
oscillator. The transmitter and receiver are functionally The data is transmitted through the RC6/TX/CK pin
independent, but use the same data format and baud rate. from the transmit shift register (TSR) which obtains its data
To configure a USART of the PIC; INTCON, PIR1, from the read/write transmit buffer, TXREG. The TXREG
RCSTA, RCREG, PIE1, TXSTA, TXREG and SPBRG register is loaded with data in software. The TSR register is
registers are needed to configure. not loaded until the STOP bit has been transmitted from the
C. Transmitter Configuration previous load. As soon as the STOP bit is transmitted, the
The data is transmitted through the RC6/TX/CK pin from TSR is loaded with new data from the TXREG register (if
the transmit shift register (TSR) which obtains its data from available). Once the TXREG register transfers the data to
the read/write transmit buffer, TXREG. The TXREG the TSR register, the TXREG register is empty and flag bit
T
register is loaded with data in software. The TSR register is TXIF (PIR1<4>) is
not loaded until the STOP bit has been transmitted from the
TSR is loaded with new data from the TXREG register (if If the transfer is complete, flag bit RCIF (PIR1<5>) is set.
available). Once the TXREG register transfers the data to The actual interrupt can be enabled/disabled by
the TSR register, the TXREG register is empty and flag bit setting/clearing enable bit RCIE (PIE1<5>). Flag bit RCIF
TXIF (PIR1<4>) is set. This interrupt can be is a read only bit, which is cleared by the hardware. It is
ES
enabled/disabled by setting/clearing enable bit TXIE
(PIE1<4>). Flag bit TXIF will be set, regardless of the state
of enable bit TXIE and cannot be cleared in software. It
will reset only when new data is loaded into the TXREG
register. While flag bit TXIF indicates the status of the
TXREG register, another bit TRMT (TXSTA<1>) shows
the status of the TSR register. Status bit TRMT is a read
cleared when the RCREG register has been read and is
empty. The RCREG is a double buffered register (i.e., it is
a two deep FIFO). It is possible for two bytes of data to be
received and transferred to the RCREG FIFO and a third
byte to begin shifting to the RSR register. On the detection
of the STOP bit of the third byte, if the RCREG register is
still full, the overrun error bit OERR (RCSTA<1>) will be
only bit, which is set when the TSR register is empty [3]. set. The word in the RSR will be lost. The RCREG register
Transmission is enabled by setting enable bit TXEN can be read twice to retrieve the two bytes in the FIFO.
(TXSTA<5>). The transmission can be started by first Then the Overrun bit OERR has to be cleared in software.
loading the TXREG register and then setting enable bit This is done by resetting the receive logic (CREN is cleared
A
TXEN. Normally, when transmission is first started, the and then set). If bit OERR is set, transfers from the RSR
TSR register is empty. At that point, transfer to the TXREG register to the RCREG register are inhibited, and no further
register will result in an immediate transfer to TSR, data will be received. It is, therefore, essential to clear error
resulting in an empty TXREG. A back-to-back transfer is bit OERR if it is set. Framing error bit FERR (RCSTA<2>)
thus possible. CLRC bit (TXSTA<7>) is ignored in is set if a STOP bit is detected as clear [3]
asynchronous mode. The baud rate generator produces a
clock, either x16 or x64 of the bit shift rate, depending on F. LCD interfacing
IJ
bit BRGH (TXSTA<2>).If clock frequency is 4MHz & The display is a standard LM020a which displays 4 lines
BRGH is set and then generated baud rate is less deviated of 20 characters (20×4). Each character is of 5×10 pixels.
from the required data rate. Parity is not supported by the The display receives ASCII codes for each character at the
hardware, but can be implemented in software (and stored data inputs (D0–D7). The data is presented to the display
as the ninth data bit) [3]. inputs by the MCU, and latched in by the pulsation of the E
(Enable) input. The RW (Read/Write) line can be tied low
E. Receiver Configuration (write mode), as the LCD is receiving data only. The RS
The data is received on the RC7/RX/DT pin and drives (Register Select) input allows commands to be sent to the
the data recovery block. Once Asynchronous mode is display. RS = 0 selects command mode, RS = 1 data mode.
selected, reception is enabled by setting bit SPEN The display itself contains a microcontroller; the standard
(RCSTA<7>) & CREN (RCSTA<4>). After sampling the chip in this type of display is the Hitachi HD44780. It must
STOP bit, the received data in the receive shift register be initialized according to the data and display options
(RSR) is transferred to the RCREG register (if it is empty). required. More details can be found in the web-site [5].
T
G. LCD interfacing
ES
Figure 3: Schematic diagram of SMS Gateway System
required. More details can be found in the web-site [5]. IV. ENCODING DECODING TECHNIQUE OF
SMS PACKET
III. MICROCONTROLLER SMS G ATEWAY
Modern mobile phones are able to send & receive SMS The SMS message can be up to 160 characters long,
with appropriate AT command originated from the where each character is 7 bits according to the 7-bit default
microcontroller. The microcontroller circuit is used to alphabet. There are two ways of sending and receiving
control and interface hardware devices and the SMS is SMS messages: Text mode and PDU (protocol description
generated, received, decoded and displayed through it. The unit) mode. As text mode is unavailable on some phones,
complete system for SMS Gateway can be setup for many the PDU mode is used in this work. The PDU string
applications. Some of the examples are Smart Home contains not only the message, but also a lot of meta-
System and Remote Data Collection System. The SMS information about the sender, SMS service centre, the time
Gateway main program is written using PIC Assembly stamp etc. It is all in the form of hexa-decimal octets or
Language which is assembled using MPLAB 7.60 [3]. The decimal semi-octets [7, 8]. Figure 4 shows details data
main program communicates to mobile equipment (ME) format, frame and instruction uses within an SMS packet.
via GSM 07.07 protocol [6] is applied to send and receive
SMS packet
08 91 88 10 07 00 00 06 F0 11 40 0D 91 88 10 17 43 88 39 F0
88 01 70 00 00 60 0F 88 01 71 34 88 93 0F
8801713488930
8801700000600
Validity User data
User Data
T
PID DCS Period length
00 00 A7 0B D4F29C9E769F41D3E614
Testing SMS
T
<index>.
V. TESTING & RESULT accessed for controlling various devices in the remote place
The total system has been designed and a prototype has through the Internet.
also been developed based on the flowchart shown in figure
5. The designed system has been tested whether it
responses according to algorithm or not. A start pulse was
generated to initiate the system. The PIC microcontroller
ES
issues an AT command to check whether the connection
with mobile is established or not. It executes AT+CPMS
command to select the preferred storage for SMS which is
chosen the phone memory. Then the microcontroller
generates the “Testing SMS” which it sends to the default
cell number. At the same time it displays the SMS in the
LCD panel. An SMS containing “OK” was then sent back
from the default number manually as an acknowledgement
which is read in the microcontroller as a TPDU format
“0891881007000006F0240D91881017257845F200008050
620291324202CF25”. Microcontroller then checks the
A
sender authentication by reading the encoded sender
number between the 13th and 19th octet of the TPDU part.
Message is then decoded from 30th octet where 29th
indicates the length of the PDU. Then microcontroller
decoded the PDU and shows it in LCD which is seen “OK”
as expected. The overall procedure indicates that the
developed SMS Gateway system can be used for any kind
IJ
Power ON Start
Read PDU,ctrl-z
& transmit byte wise
Initialize Process Suppress answer from mobile
PORTB for LCD interface Display “Testing SMS”
PORTC<7:6> for USART
PORTC<2:1:0> for RS, R/W, E
BAUD rate = 9600
5 sec Timer
SPBRG = 25; BRGH = 1
8bit, No parity & 1stop bit for Tx/Rx
LCD initialization Read
“AT+CNMI=3,3,0,0,0”,CR,LF
& transmit byte wise
Save in EEPROM:
AT,CR,LF
AT+CPMS=“ME”,“ME”,“ME” Receive data
AT+CMGS=25,CR & save in GPR byte wise
AT+CNMI=3,3,0,0,0,CR,LF
T
AT+CMGD=1,CR,LF
PDU, ctrl-z
Receive
LF?
Display “SMS Gateway” NO
Yes
NO
Start pulse?
Yes
Read “AT”,CR,LR
& transmit byte wise
ES Authorized?
Yes
Skip 28 byte & set data
length=29th byte NO
Display
“Unauthorized”
Decode
Receive Complete?
NO To start
NO “OK” ?
Yes
A
Yes
Read “AT+CPMS=“ME”,“ME”,“ME” ”,CR,LF Display the
& transmit byte wise received SMS
To start
Receive
“<” ?
NO
Yes
REFERENCE
2. Siang, B.K.; Bin Ramli, A.R.; Prakash, V.; Bin Syed
1. A.Y. Al-Zoubi, A.A. Tahat, and O.M. Hasan, “ Mobile Mohamed, S.A.R., “SMS gateway interface remote
virtual experimentation utilizing SMS”, proceedings of the monitoring and controlling via GSM SMS”,
Fourth IASTED International Conference Communication, Telecommunication Technology, 2003. NCTT 2003
Internet, and Information Technology, October31- proceedings. 4th National Conference on Volume, Issue
November2, 2005, Cambridge, USA 14-15, Jan.2003 Page(s): 84 – 87
6. GSM 07.05 TECHNICAL SPECIFICATION, January 8. Michael Harrington, “Understanding SMS: Practitioner‟s
1998,Ver 5.5.0 www.ctiforum.com/standard/standard/etsi Basics”
accessed on 30 September, 2008 http://mobileforensics.files.wordpress.com/2007/06/unders
tanding_sms.pdf accessed on 24 February, 2008
7. GSM SMS and the PDU format,
http://www.dreamfabric.com/sms accessed on 5 March, 9. Mobile PhoneT68i Developers. Guidelines AT Commands
2008 Online Reference http://pupius.co.uk/download/misc/t68i-
at-commands.pdf accessed on 30 June, 2008
T
ES
A
IJ