interfacing gsm modem with microcontroller

28
SECTION ONE 1.0 Introduction Life style in this modem society and human behaviour is changing with the change in ICT technology. This technology has helped us in various ways, which could be used in protecting our homes from theft or fire outbreaks. The advancement of ICT technology has improved the safety of people as well as their belongings. The busy lifestyle of people has made it necessary for us to monitor our homes of theft, breaking into the house gas leakage, food burns and water over flows which may lead to fire outbreaks and loss of property. We can do this monitoring from any part of the world with the help of ICT technology. Mobile phones these days are not just meant for making and answering class. The use of mobile services can also help to send messages to the owners of the house, the security service around the house or even fire services of any situation in the house. People don’t really understand how this system work, the interconnection between the microcontroller and GSM modem which is among the circuits needed to complete 1

Transcript of interfacing gsm modem with microcontroller

SECTION ONE

1.0 Introduction

Life style in this modem society and human behaviour

is changing with the change in ICT technology. This

technology has helped us in various ways, which could

be used in protecting our homes from theft or fire

outbreaks. The advancement of ICT technology has

improved the safety of people as well as their

belongings.

The busy lifestyle of people has made it necessary

for us to monitor our homes of theft, breaking into

the house gas leakage, food burns and water over

flows which may lead to fire outbreaks and loss of

property. We can do this monitoring from any part of

the world with the help of ICT technology. Mobile

phones these days are not just meant for making and

answering class. The use of mobile services can also

help to send messages to the owners of the house, the

security service around the house or even fire

services of any situation in the house. People don’t

really understand how this system work, the

interconnection between the microcontroller and GSM

modem which is among the circuits needed to complete1

any of the GSM modem based project. This is why i

want to talk about this connection between these two

IC and the communication between them.

1.1 Motive of this seminar

To explain the GSM system.

To explain the basics of microcontroller.

To explain the basics of a GSM modem.

To explain the interface between a

microcontroller and a GSM modem.

To explain AT command which is a code that helps

a system send message to the people involved.

1.2 GSM system overview

GSM stands for Global System For Mobile

communication. It was proposed by ESTI(European

telecommunication standard institute). It is a

digital cellular system designed to support a wide

variety of services offered by the system. It sends

and receives data at the rate of 9.6Kbps. The smart

card in charge of handling and storing subscribers

data is called SIM(subscriber identification module)

card while the radio equipment that contains this SIM

card is called the mobile equipment. The combination

2

of the mobile equipment and a SIM card is called a

mobile station.

1.3 Services of a GSM system

GSM network provides the following services

Data communication

SMS

Call waiting, call forwarding, caller

identification(ID)

But in this seminar we only interested in the SMS

service provided by the GSM system.

SMS(short messaging service): This is one service

integrated in the GSM which makes provision for

sending and receiving message of limited size to a

mobile station and from a mobile station. The

SMSC(short messaging services centre) is in charge

of handling the SMS which needs to be supported by

a GSM network to enable the transfer of messages

between the SMSC and the mobile station.

SECTION TWO3

2.0 Microcontroller

A microcontroller is a small computer on a single

integrated circuit containing a processor core,

memory and programmable input and output peripherals.

Program memory and small amount of RAM is also often

included on chip. Microcontroller is designed for

embedded systems. Microcontrollers are used in

automatic control devices like appliances, remote

controls and other embedded systems. Using

microcontroller in these devices reduces the size and

cost, when compared to a design that uses a separate

microprocessor, memory and input/output devices.

The microcontroller used for this seminar is Intel

MCS-51 also called 8051. It is Harvard architecture,

it has CISC instruction set and it has a single chip

microcontroller series which was developed by Intel

in 1980 for use in embedded systems.

The Intel 8051 is an 8-bit microcontroller and it has

40 pins where 32 pins are for input and output while

the remaining 8 pins are for the internal operations

of microcontroller. There are 3 basic "sizes" of the

8051: Short, Standard, and Extended. The Short and

Standard chips are often available in DIP (dual in-

4

line package) form, but the Extended 8051 models

often have a different form factor, and are not

"drop-in compatible". All these things are called

8051 because they can all be programmed using 8051

assembly language, and they all share certain

features (although the different models all have

their own special features).

2.1 Features of microcontroller 8051

There are many features of microcontroller but listed

below are few features of 8051 microcontroller.

4 KB on chip program memory.

128 bytes on chip data memory(RAM) [ 32 bank reg +

16 bit addressable reg + 80 general purpose reg ]

4 reg banks.

128 user defined software flags.

8-bit data bus

16-bit address bus

16 bit timers (usually 2, but may have more, or

less).

5

3 internal and 2 external interrupts.

Bit as well as byte addressable RAM area of 16

bytes.

Four 8-bit ports, (short models have two 8-bit

ports).

16-bit program counter and data pointer.

1 Microsecond instruction cycle with 12 MHz

Crystal.

2.2 Pin out Description of 8051

microcontroller

The 8051 microcontroller is made up 40 pins and these

pins are described as follows:

 Pin 1-8(port 1): Each of these pins can be

configured as an input or an output.

 Pin 9(RS): A logic one on this pin disables the

microcontroller and clears the contents of most

registers. In other words, the positive voltage on

this pin resets the microcontroller. By applying

logic zero to this pin, the program starts execution

from the beginning.

 Pins 10-17(port 3): Similar to port 1, each of these

pins can serve as general input or output. PORT P3

6

acts as a normal IO port, but Port P3 has additional

functions such as, serial transmit and receive pins,

2 external interrupt pins, 2 external counter inputs,

read and write pins for memory access.

 Pin10(RXD): Serial asynchronous communication input

or Serial synchronous communication output.

Pin 11(TXD): Serial asynchronous communication output

or Serial synchronous communication clock output.

Pin 12(INTO): Interrupt 0 input.

Pin 13(INT1): Interrupt 1 input.

Pin 14(TO): Counter 0 clock input.

Pin 15(T1): Counter 1 clock input.

Pin 16(WR): Write to external (additional) RAM.

Pin 17(RD): Read from external RAM.

7

Fig 2.1: 8051 Basic circuit configuration.

Pin 18,19(X1,X2): Internal oscillator input and

output. A quartz crystal which specifies operating

frequency is usually connected to these pins. Instead

of it, miniature ceramics resonators can also be used

for frequency stability. Later versions of

microcontrollers operate at a frequency of 0 Hz up to

over 50 Hz.

Pin 20(GND): Ground.

Pins 21 – 28(Port 2): PORT P2 can also be used as a

general purpose 8 bit port when no external memory is

present, but if external memory access is required

8

then PORT P2 will act as an address bus in

conjunction with PORT P0 to access external memory.

PORT P2 acts as A8-A15.

Pin 29(PSEN): If external ROM is used for storing

program then a logic zero (0) appears on it every

time the microcontroller reads a byte from memory.

Pin 30(ALE): Prior to reading from external memory,

the microcontroller puts the lower address byte (A0-

A7) on P0 and activates the ALE output. After

receiving signal from the ALE pin, the external

register (usually 74HCT373 or 74HCT375 add-on chip)

memorizes the state of P0 and uses it as a memory

chip address. Immediately after that, the ALU pin is

returned to its previous logic state and P0 is now

used as a Data Bus. As seen, port data multiplexing

is performed by means of only one additional (and

cheap) integrated circuit. In other words, this port

is used for both data and address transmission.

Pin 31(EA): By applying logic zero to this pin, P2

and P3 are used for data and address transmission

with no regard to whether there is internal memory or

not. It means that even if there is a program written

to the microcontroller, it will not be executed.

Instead, the program written to external ROM will be

9

executed. By applying logic one to the EA pin, the

microcontroller will use both memories, first

internal then external (if it exists).

Pin 32-39(Port 0): Similar to P2, if external memory

is not used, these pins can be used as general

inputs/outputs. PORT P0 can be used as a general

purpose 8 bit port when no external memory is

present, but if external memory access is required

then PORT P0 acts as a multiplexed address and data

bus that can be used to access external memory in

conjunction with PORT P2.

Pin 40(VCC): +5V power supply.

10

SECTION THREE3.0 GSM modem

A GSM modem is a specialized type of modem which

accepts a SIM card and operates over a subscription

to a mobile operator. It is a wireless modem that

works with a GSM wireless network, it behaves like a

dial-up modem except that dial-up modem sends and

receives data through a fixed telephone line while

GSM modem sends and receives data through radio

waves. Some GSM modems also have GPRS feature that

allows transmission of data over TCP/IP (internet).

11

To transmit data using GSM Modem, there are various

methods that can be used, such as:

SMS

GPRS / UMTS

Even though a normal mobile phone can be used as GSM

modem, it is highly recommended that a special

industrial grade terminal be used as a GSM modem due

to its stability, and reliability.

A GSM modem can be used to build the following

applications:

SMS Gateway ie. to send and receive SMS.

Telemetric ie. to collect data from remote

terminals.

Call-back service for VOIP.

SMS application, SMS solution, or SMS programme.

sending SMS from PC

vehicle tracking with cell broadcast feature or

with integrated GPS terminal

It is called a modem because it can modulate and

demodulate.

A GSM modem exposes an interface that allows

applications to send and receive message over the

12

modem interface. To connect the microcontroller with

GSM modem AT commands are required. The micro

controller sends these commands to the GSM modem,

which is then activated to perform the required

operation.

3.1 Interfaces Between GSM Modem And

Microcontroller

The micro controller level is 5v and the GSM modem

voltage level is 12v.

As a result of the difference in voltage levels, it

is difficult to establish a direct link or

communication between them. To make that

communication possible, there is need for a link

between two of them and MAX232 IC provides that link.

13

FIG 3.1: Interfacing GSM modem with microcontroller

3.2: MAX232 IC

The MAX232 is an integrated circuit first created in

1987 by Maxim Integrated Products. This integrated

circuit is used for converting the logic levels. It

helps to interface the GSM modem which has an RS232

interface for serial communication with the

microcontroller which has TTL/CMOS logic levels.

MAX232 IC has two receivers which convert from RS232

to TTL voltage level and two drivers that convert

from TTL logic to RS232 voltage level where the Tx

and Rx are the drivers and CTS and RTS are for the

receivers. This means that only two of the RS232

signals can be converted in each direction. The

14

MAX232 would need about four external capacitors

whose value will range from 1uf to 22uf.

Interfacing GSM with microcontroller: Interfacing of

GSM to AT89C51 microcontroller uses only one receiver

and transmitter. The transmitter pinT1in of MAX232 is

connected to the transmitter pin of the

microcontroller while the receiver pin R1out of

MAX232 is connected to the receiver pin of the

microcontroller. The T1out pin of MAX232 is connected

to the transmitter pin of the GSM modem and the R1in

pin of the MAX232 is connected to the receiver pin of

the GSM modem.

FIG 3.2: MAX232 IC [www.engineersgarage.com]

15

FIG 3.3: Pin out of MAX232 IC[1]

3.3 Pin Description of MAX232 IC

Pin

NoFunction Name

1Capacitor connection pins Capacitor

1 +

2Capacitor

3 +

3 Capacitor

1 -

16

4Capacitor

2 +

5Capacitor

2 -

6Capacitor

4 -

7

Output pin; outputs the serially

transmitted data at RS232 logic

level; connected to receiver pin of

PC serial port 

T2 Out

8

Input pin; receives serially

transmitted data at RS 232 logic

level; connected to transmitter pin

of PC serial port

R2 In

9

Output pin; outputs the serially

transmitted data at TTL logic level;

connected to receiver pin of

controller.

R2 Out

10 Input pins; receive the serial data

at TTL logic level; connected to

serial transmitter pin of

controller.

T2 In

11 T1 In

17

12

Output pin; outputs the serially

transmitted data at TTL logic level;

connected to receiver pin of

controller.

R1 Out

13

Input pin; receives serially

transmitted data at RS 232 logic

level; connected to transmitter pin

of PC serial port

R1 In

14

Output pin; outputs the serially

transmitted data at RS232 logic

level; connected to receiver pin of

PC serial port

T1 Out

15 Ground (0V) Ground

16 Supply voltage; 5V (4.5V – 5.5V) Vcc

3.3: voltage Level

The driver provides RS232 voltage level output of

approximately ±7.5v from a single +5v supply which

makes it useful for devices that do not any voltage

18

outside 0v to +5v range while the receiver reduces

RS232 input which is around ±25v to a standard 5v TTL

level, the receiver has a typical threshold of 1.3v

and typical hysteresis of 0.5sv. When a MAX232 IC

receives a TTL level for conversion, it changes the

TTL logic 0 (i.e 0v) to between +3v and +15v and

equally changes TTL logic 1 (that is 5v) to -3v to -

15v while when also converting from RS232 to TTL

level, a MAX232 IC receives a RS232 for conversion,

it changes the RS232 level 0 (that is 5v) to between

-3v to -15v and changes RS232 level 1(that is 0v) to

between +3v to +15v.

3.4: AT Command Description

AT commands are instructions used to control a modem.

AT is an abbreviation which means Attention. These

commands come from Hayes commands that were used by

the Hayes smart modems. The Hayes commands started

with AT to indicate the attention from the modem. The

dial up and wireless MODEMs (devices that involve

machine to machine communication) need AT commands to

interact with a computer. Every command line always

starts with “AT” or “at” which is why they are called

AT command. AT commands are used to control MODEMs

19

3.4.1 Basic groups of AT command

AT commands could be of two groups, they are basic

command and extended command

1)Basic commands: These are AT commands that do not

start with a “+”. Examples of basic commands are;

D(Dial), H(Hook control) and O(Return to the

online data state).

2)Extended commands: These are AT commands that

start with a “+”. Examples of these commands are;

+CMGL(list SMS message), +CMGR(read SMS message),

and +CMGS(send SMS message).

Explanation of commonly used AT commands:

1)   AT - This command is used to check communication

between the module and the computer.

For example,

AT        

OK

The command returns a result code OK if the computer

(serial port) and module are connected properly. If

any of module or SIM is not working, it would return

a result code ERROR.

 

20

2)   +CMGF - This command is used to set the SMS

mode. Either text or PDU mode can be selected by

assigning 1 or 0 in the command.  

SYNTAX:         AT+CMGF=<mode>

0: for PDU mode

1: for text mode

The text mode of SMS is easier to operate but it

allows limited features of SMS. The PDU     

(protocol data unit) allows more access to SMS

services but the operator requires bit level

knowledge of TPDUs. The headers and body of SMS are

accessed in hex format in PDU mode so it allows

availing more features.

For example,  

        AT+CMGF=1

        OK

3)  +CMGW - This command is used to store message

in the SIM.

SYNTAX:         AT+CMGW=” Phone number”> Message to be

stored Ctrl+z

As one types AT+CMGW and phone number, ‘>’ sign

appears on next line where one can type the message.

Multiple line messages can be typed in this case.

This is why the message is terminated by providing a

21

‘Ctrl+z’ combination. As Ctrl+z is pressed, the

following information response is displayed on the

screen.

+CMGW: Number on which message has been stored

 

4)  +CMGS - This command is used to send a SMS

message to a phone number.

SYNTAX:         AT+CMGS= serial number of message to

be send. 

As the command AT+CMGS and serial number of message

are entered, SMS is sent to the particular SIM.

         For example,

         AT+CMGS=1

OK

5) ATD - This command is used to dial or call a

number.

SYNTAX:         ATD<Phone number>;(Enter)

For example,

ATD123456789;

6) ATA - This command is used to answer a call. An

incoming call is indicated by a message ‘RING’ which

is repeated for every ring of the call. When the call

ends ‘NO CARRIER’ is displayed on the screen. 

22

SYNTAX:         ATA(Enter)    

As ATA followed by enter key is pressed, incoming

call is answered.

For example,

RING

RING

ATA

7)      ATH - This command is used to disconnect

remote user link with the GSM module.

SYNTAX:         ATH (Enter)

3.7 OPERATING MODE

The SMS specification has defined two modes in which

GSM modem can operate and they are called

a) SMS(short message system)

b) SMS PDU(protocol data unit) mode.

The mode in which GSM modem is operating determines

the syntax of some SMS AT commands and the format of

the response returned after execution.

23

SECTION FOUR4.0 Advantages of GSM based systemsThere are so many advantages of a GSM based systems

and few of them are listed below:

1) Devices can be controlled from a long distance.

2) We can monitor our homes from any part of the

world.

3) It can easily be implemented in our homes, offices

e.t.c

4) It is an economical design.

5) It can be used by everyone.24

4.1 Limitations of GSM based systemThe major limitations of a GSM based system is

network. Once there is no network available in a

particular area, the GSM modem may not function in

such an area or even when there is network

congestion, the rate at which the message will be

delivered will be slowed down.

 

4.2 CONCLUSIONThis seminar explained the basics of interfacing a

GSM modem with a microcontroller. It showed how25

efficient and important it is to interface them to

appliances. This interface showed the importance of

AT commands and the serial interface

communication.GSM (Global System for Mobile

Communications) is the most popular standard for

mobile telephony systems in the world. The

communication between Microcontrollers with GSM is

done by using AT commands. This link or interface

between the microcontroller and GSM modem is made

possible using MAX232 IC, this is due to the

difference in their voltage level and their means of

communication. The MAX232 is an integrated circuit

that converts signals from an RS-232 serial port to

signals suitable for use in TTL compatible digital

logic circuits.

26

REFERENCE1) Himanshu Choudhary, How to interface GSM modem

with microcontroller, Retrieved from

http://www.engineersgarage.com

2) Vandana Pandya(asst. professor) Deepali

Shukla(Asst.Professor), September 2012, GSM Modem

Based Data Acquisition System, retrieved from

International Journal Of Computational Engineering

Research (ijceronline.com) Vol. 2.

3) Retrieved from

https://iclubcharusat.files.wordpress.com,

interfacing GSM modems PDF.

4) Retrieved from http://www.zembedded.com/gsm-

modem-interfacing-with-microcontroller-8051-for-sms-

control-of-industrial-equipments,GSM modem

interfacing with 8051 for SMS written by the admin

posted on August 22,2012.

27

5) Network engineer training slide for HUAWEI

TECHNOLOGIES LTD.

28