Posts Tagged ‘8051 sms’

With the advent of internet of things and more powerful microcontrollers, the 8051 and its derivative and a GSM modem is a cheaper alternative if you want to remotely control lights or actuators, monitor sensors in places where there is no internet or mobile data connection.

Various GSM modules are available in the market like SIM900 and SIM800 from Simcom. In this tutorial we will be using a SIM900A module. This modules allows users to send and receive SMS, make and receive calls as well as to send data not too large through GPRS network.

SIM900A GSM Module

GSM/GPRS Module

This modems communicate with the computer or a microcontroller through the serial port with AT commands. With this said, we will be using the UART of the 8051 to communicate with the GSM Modem. But, with the limited amount of memory, we could use the 8051 to send and receive SMS, but if you want to use HTTP, a microcontroller with a larger ROM and RAM is suggested. In addition, this modules requires a large amount of current and your power supply must be at least 1A – 2A. The above module requires at 5V 1A power supply.

Insert sim card, connect the tx and rx pins of the modem to the UART of the 8051, apply power and we are now ready to issue commands. AT commands are sent to the modem and the modem replies with a response in the following format:

<CR><LF><Response><CR><LF>

Shown in the table below is the commonly used AT commands to send and receive SMS.

AT Commands

We connect our hardware as follows:

Connection

Hardware Connections

Connect the GSM Modem to the Hardware UART of the 8051 and connect a LED to P2.7 and a switch to P0.0 (can be changed accordingly). In the later part a RGB LED was added to indicate the status of the system.

Going to the firmware. We designed the program to send an SMS if a button is pressed, and toggle the LED if the “toggle” message is received.

Loop

The program is divided into several parts such as serial port initialization, receiving sms, decoding response, sending sms, decoding received sms and processing received SMS. The whole Keil Project file can be downloaded from here.

Let’s see how it works!