A GSM modem is either a wireless communication module or a modem device, which can be used to make a computer or any other processor communicate over a network. A GSM modem requires a SIM card for operation and operates over a network range subscribed by the network operator. It can be connected to a computer through a serial, USB or Bluetooth connection.
A GSM modem can also be a standard GSM mobile phone with an appropriate cable and software driver to connect to a serial port or USB port on your computer. The GSM modem is usually preferred instead of a GSM mobile phone. The GSM modem has a wide range of applications in transaction terminals, supply chain management, security applications, weather stations and GPRS mode remote-data logging.
GSM Modem Interfacing
Nowadays many applications of the projects such as home automation, remote control industrial machines and security system, etc., are controlled by a SMS using microcontroller and GSM Modem. A GSM modem is a specialized type of modem which accepts a SIM card, and operates through a subscription with the mobile operator. Many people don’t know how to interface a GSM modem to a microcontroller and, therefore,the following steps explain the basics of interfacing a GSM module to the microcontroller.
Steps For Connecting a GSM Modem to the Microcontroller
Step1: Configuring the GSM Modem
The GSM modem is a specific type of modem which accepts the SIM for communication. First, insert a SIM into the GSM modem which uses the same number/ account asthe caller phone.
The modem supports a list of ‘AT commands’ for handling the text messages. These AT commands programmed in the microcontroller ensures ending or receiving of the SMS from the GSM modem,without which the text messages cannot be sent or received.
For example : Initializing commands for different types of modem are given below:
- Siemens: AT+CNMI=1,1,0,2,1
- WaveCom: AT+CNMI=2,1,0,1,1
- SonyEricsson: AT+CNMI=3,1,0,1,0
- Motorola USB modem: AT+CNMI=3,1,0,0,0
- The modem is configured to send notifications to the microcontroller upon receiving a new text.
- Configure the modem port speed as a rule such as 9600 or 19200 bps baud rates.
Step2: Testing the GSM Modem
The GSM modem consists of two LEDs such as green and red LEDs for the indication of network connection. If there is no network, then the red LED glows, and if a network is available then the green LEDglows so that one can observe the GSM modem’s working.
Connect a power supply to a SIM contained GSM modem and wait till it is registered in the GSM network.Then you can send a SMS to the GSM modem for testing;if it receives the message from the mobile –it is working fine, or else – it is faulty.
Step3: Interfacing the GSM Modem with the Microcontroller
The GSM modem cannot be connected directly to the microcontroller because the microcontroller works with 5v DC power supply,whereas the GSM modem with a12V DC. Therefore,the voltages levels mismatch.
The GSM modem is interfaced to the microcontroller through a MAX-232 device with the help of RS-232 cable for serial data communication where in the MAX-232 device is used to convert the TTL/COM logic levels to RS-232 logic levels during serial communication of microcontroller to the GSM modem.
The RS-232 defines the interface between data terminal equipment and data communication equipment using serial binary data exchange. The RS-232 cable is commonly available with the 9 or 25 pin wiring and has jumpers to provide ‘handshaking’ pins for those devices that require it.
GSM Modem Interfacing with 8051 Microcontroller
Step4: Program to the Microcontroller
- Transmitting single character
- Transmitting word
- Receiving char
voidTx_Char(unsigned char ch);
voidTx_String(unsigned char *str);
TMOD|=0x20; //Timer 1 in mode 2 ( Auto Reload mode)
TH1=0XFD; //0xFD for 9600bps
SCON=0x50; //Enable TI and RI pins using Serial control Register
TR1=1; //Start Timer 1;
voidTx_Char(unsigned char ch)
SBUF=ch; // Load the character into SBUF register to transmit.
while(!TI); //wait for TI flag to raise high
TI=0; //clear TI for further transmission.
voidTx_String(unsigned char *str)
while(RI==1); //wait for RI flag to receive any character
Ch=SBUF; // capture the character from SBUF into Ch variable
RI=0; //clear RI flag for further reception
If a user wants to create an SMS to some other mobile through microcontroller upon interrupt either from internal or external device, he/she can follow the below program in addition to the above one.
Serial Interrupt Programming
Hardware Interrupt Program
Step5: Circuit Connections
The 5v DC power supply is given 40th pin of the microcontroller to run the circuit. The GSM modem is interfaced with the 10 and11 pins of the microcontroller with the help of the MAX-232 device for transmitting and receiving the information serially. The LCD display is connected toport0 of the microcontroller for displaying the predefined information. A crystal is oscillator connected to the 18th and19th pins of the microcontroller to provide clock pulses. The RESET button is connected to the 9th pin of the microcontroller for rebooting the controller when it is not functioning properly.
The Working Procedure of a GSM Modem
A GSM modem communicates with the microcontroller with a mobile phone through a UART protocol and needs three basic signals: RXD (receive), TXD (transmit), GND (ground), respectively.
The GSM modem interfaced with the microcontroller controls industrial appliances by SMS. As each load has an assigned unique-identify number like ‘1111’ is load1, and ‘0000’ is load2 is the program in the microcontroller.
The GSM modem continuously monitors the signals from the input. When the GSM modem receives the SMS from a user phone, that data is sent to the microcontroller,serially.
The microcontroller compares this data with the stored one,and if the data matches,the microcontroller generates corresponding signals to control the electrical load.