Know the Procedure of GSM Modem Interfacing with 8051

Summary of Know the Procedure of GSM Modem Interfacing with 8051


The article explains interfacing a GSM modem with an 8051 microcontroller to send/receive SMS for projects like car security and home automation. It covers inserting a SIM, using AT commands (example CNMI settings), testing via LEDs and SMS, voltage and serial-level conversion using MAX232/RS232, baud rate setup, and example 8051 serial routines (initialize UART, transmit char/string, receive char) including timer-based baud generation and flags TI/RI handling.

Parts used in the GSM Modem Interfacing with 8051 Microcontroller:

  • GSM modem (with SIM card slot)
  • SIM card
  • 8051 microcontroller
  • MAX232 level converter
  • RS232 cable (9 or 25 pin)
  • Power supply (12V for GSM modem)
  • Power supply (5V for 8051)
  • Serial connection (USB/serial or Bluetooth optional)
  • LED indicators on modem (green and red)

The acronym of the GSM modem is Global System for Mobile Communications, it is a wireless communication module, used to  make a computer or any processor to communicate over a network. This modem uses a variation of TDMA(Time Division Multiple Access) and is the most commonly used of the digital wireless telephony technologies like TDMA, GSM and CDMA.A GSM modem needs a SIM card to operate through a n/w range subscribed by the network operator. This modem can be connected to a computer via a serial, Bluetooth or USB connection. A GSM modem is also a standard GSM mobile phone with a suitable cable and software driver to connect to a USB port on your PC. Generally, this modem is preferred instead of a GSM mobile phone. This article describes how GSM modem interfacing with 8051 microcontroller.Know the Procedure of GSM Modem Interfacing with 8051

GSM Modem Interfacing with 8051 Microcontroller

Nowadays, many projects like  car security system, home automation, remote controlled industrial machines are controlled by an SMS using GSM modem. This modem uses a SIM card and operates through a subscription with the mobile operator. Many people they don’t know how GSM module interfacing with 8051 microcontroller. Therefore, the following steps explain the basics of how GSM modem interfacing with 8051 microcontroller.

Steps to Interfacing a GSM Modem to the Microcontroller

Step1: Arranging the GSM Modem

The GSM modem is a one type of modem, which uses the SIM card for communication. First, insert a SIM card into the modem which uses the same number/ account as the caller phone. It supports AT commands for handling the messages. These commands are programmed into the microcontroller ensures ending or receiving of the SMS from the modem.
For instance: Initializing commands for several types of modem are shown 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 arranged to send notifications to the microcontroller upon receiving a new text.
  • Arrange the modem port speed as a rule such as 9600 or 19200 bps baud rates.

Step2: GSM Modem Testing

The GSM modem comprises of two light emitting diodes like green and red LEDs, which are used for the network connection indication. If there is no network is available, then the red LED glows, and if a network is available, then the green LED glows so that one can observe the working of GSM modem. Connect a power supply to a GSM modem which contains a SIM card and wait till it registers in the GSM network. For the testing of the modem, you can send an SMS to the modem. If it receives the message from the mobile, it is working properly, or else it is damaged.

Step3: GSM Modem Interfacing with 8051 Microcontroller

GSM modem works with 12V DC and the microcontroller works with 5V. So, interfacing of this modem with microcontroller directly is not possible due to mismatch of voltage levels. GSM modem is interfaced with 8051 microcontroller through MAX232 with the help of RS232 cable for serial communication. MAX232 device is used to convert TTL logic level to RS232 level during serial communication of microcontroller to the GSM modem. The RS232 device is an interface between data terminal equipment and data communication equipment using serial binary data exchange. The RS232 cable is commonly available with the 9 or 25 pin wiring and has jumpers to provide handshaking pins for those devices that require it.Know the Procedure of GSM Modem Interfacing with 8051 schematic

Step4: Microcontroller Programming

  • Transmitting single character
  • Transmitting word
  • Receiving char

#include<reg51.h>
voidinit_RS 232();
voidTx_Char(unsigned char ch);
voidTx_String(unsigned char *str);
voidRx_Char();
voidinit_RS 232()
{
TMOD|=0×20;    //Timer 1 in mode 2 ( Auto Reload mode)
TH1=0XFD;        //0xFD for 9600bps
SCON=0×50;        //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(*str)
Tx_Char(str++);
}
voidRx_Char()
{
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
}
In addition to the above program,if an operator wants to make an SMS to any other persons mobile via  microcontroller upon interrupt either from internal or external device, the operator can follow the below program.

For more detail: Know the Procedure of GSM Modem Interfacing with 8051

Quick Solutions to Questions related to GSM Modem Interfacing with 8051 Microcontroller:

  • What does GSM stand for?
    GSM stands for Global System for Mobile Communications.
  • How is the GSM modem connected to the 8051 microcontroller?
    The GSM modem is interfaced to the 8051 through a MAX232 level converter using an RS232 cable for serial communication.
  • Does the GSM modem need a SIM card to operate?
    Yes, a GSM modem needs a SIM card to operate through the subscribed network operator.
  • What voltage levels do the GSM modem and 8051 use?
    The GSM modem works with 12V DC and the 8051 microcontroller works with 5V DC.
  • How can the modem notify the microcontroller of incoming SMS?
    The modem can be arranged to send notifications to the microcontroller using AT command settings such as AT+CNMI for different modems.
  • How do you test if the GSM modem is working?
    Insert a SIM, power the modem, wait for network registration indicated by LEDs, then send an SMS to the modem and verify it receives the message.
  • What baud rates are recommended for modem serial port speed?
    Common port speeds mentioned are 9600 or 19200 bps.
  • Which AT command examples are given for CNMI settings?
    Examples include 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.
  • How is serial communication initialized in the sample 8051 code?
    Timer1 is set in mode 2 with TH1=0xFD for 9600 bps, SCON=0x50 to enable TI and RI, and TR1=1 to start Timer1.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter