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.
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.
Step4: Microcontroller Programming
- Transmitting single character
- Transmitting word
- Receiving char
voidTx_Char(unsigned char ch);
voidTx_String(unsigned char *str);
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(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.
Serial Interrupt Programming
Hardware Interrupt Program
Step5: Circuit Connections
This circuit gets power supply when the power supply is given to the 40th pin of the microcontroller. The GSM modem is interfaced to the 10&11 pins of the microcontroller using the MAX232 device for transmitting and receiving of the information serially. The LCD display is connected to the port0 of the microcontroller for displaying the information. A crystal oscillator is connected to the 18th and 19th pins of the microcontroller to generate clock pulses.The RESET button is connected to the 9th pin of the microcontroller for rebooting the controller when it is not working correctly.
The Working Procedure of a GSM Modem
When the GSM modem is connected to the microcontroller, then it communicates with a mobile via a UART protocol and requires three basic signals such as TXD, RXD and GND.The GSm modem is connected to the microcontroller, it controls the industrial appliances through an SMS. As each load is assigned with a unique identifier number like load1 is assigned with 1111, load2 is 0000 is the program in the microcontroller. This modem always monitors the signals from the i/p. When the modem receives the SMS from an operational phone, serially that data is sent to the microcontroller. This microcontroller compares this data with the stored data. If the compared data match with the stored data, then the microcontroller generates corresponding signals to control the load.
Applications of GSM Modem
- Prepaid Energy Meter with GSM Interface
- Microcontroller Based Projects on Car Security System
- GSM based Electricity Energy Meter Billing with Onsite Display
- Detecting Power Theft prior to feeding energy Meter and Intimating to Control Room by GSM
- Vehicle Theft Location Intimation by GPS/GSM to the Owner
- Vehicle tracking by GPS – GSM
- Vehicle Theft Intimation to the Owner on his Cell Phone by GSM with User Programmable Number Features using PIC Microcontroller
- Theft Intimation of the Vehicle Over GSM by SMS with User Programmable Number Feature to Owner who can Stop the engine automatically
- GSM based Monthly Electricity Energy Meter Billing and SMS upon GSMwith User Programmable Number Features together with Onsite Display to the user
- Railway Level Crossing Gate Control through GSM by SMS with User Programmable Number Features by the Station Master or the Driver
- Flash Flood Intimation over GSM with User Programmable Number Features to The Station Master
- Integrated Energy Management System based on GSM with User Programmable Number Features and acknowledgement features
- Energy Meter Billing with Load Control over GSM with User Programmable Number Features
- Railway Track Security by GSM With User Programmable Number Features
- Wireless Electronic Notice Board by GSM With User Programmable Number Features
- Tampered Energy Meter Monitoring Conveyed to Control Room by GSM with User Programmable Number Features
- Energy Meter Billing with Load Control over GSM with User Programmable Number Features by PIC Microcontroller
This is all about GSM modem interfacing with 8051 circuits with an example. We hope that you will find the information about interfacing procedure immensely helpful, and therefore, anticipate your comments, suggestions, feedback and doubts regarding this article or GSM based projects please comment in the comments section given below.