Sim900 GSM Module Arduino Tutorial

In this beginner tutorial on Sim900A GSM(Global System for Mobile Communication) module with Arduino, we illustrate how to interface the Sm900A GSM module with Arduino and perform basic test via AT commands. This will give users basic knowledge on how to interface GSM module with Arduino and check whether Sim900 GSM module is working with Arduino. We will explain briefly what Sim900A is and what is GSM, GPRS is and then illustrate AT command communication between Arduino and the GSM module. The example provided includes how to inquire GSM network parameters such as signal strength, send and receive SMS and make and hang voice call. So with this tutorial you will be able to use AT command which then can be implemented in your next Arduino SMS projects or voice call projects.

What is Sim900A and Sim900A module?

Sim900A GSM module(and other GSM module) is a board that contain contains the Sim900A integrated chip with supporting components such as RS232 port, Power Regular IC, SIM insert capsule, antenna, Ports Pins, LEDs, switch, resistors, capacitors etc. The board also called shield is designed to support Sim900A integrated chip(IC). The chip itself is designed and produced for GSM radio communication operation along with data packet application. The chip contains integrated processor, radio front end, DSP filters etc that adheres to the required hardware and firmware criteria for GSM and GPRS protocols(explained below). That is it contains GSM, GPRS protocol stack, TCP IP protocol stack and other firmware. The Sim900A supports 900MHz and 1800MHz GSM frequency band and therefore is called dual band GSM chip. 

The Sim900A can therefore be used GSM voice and data communication applications. The Sim900A GSM shield has ports with the help of which we can communicate with the Sim900A chip using AT command. That is we can use microcontroller like ATmega328p, ATmega32, PIC microcontroller or use microcontroller board like Arduino to communicate or control Sim900A GSM shield. The Arduino or any other microcontroller or PC can be used to send/receive voice, SMS and data with Sim900A via AT commands.

The following picture shows Sim900A GSM module.

Sim900A GSM Shield

 

What is GSM & GPRS?

GSM stands for Global System for Mobile Communication and is a standard(sets of protocols) for digital mobile communication network and was developed by the European Telecommunications Standards Institute (ETSI). It specifies among many things the mobile network components(core switching network, base station, mobile station etc), frequencies and frequency channels, security protocols, interfacing to other networks such as PSTN(Publick Switched Telephone Network), CDMA network and other standards.

GPRS stand for General Packet Radio Service and is a standard(sets of protocols or rules to be followed) for packet oriented service for digital mobile network. It basically sets standard or rules for how the packet based communication such as Internet should be incorporated with digital mobile network.

Arduino & Sim900 GSM module in GSM mobile network

Sim900 module essentially is a mobile station(MS) in a GSM network much like a regular mobile phone. It communicates with GSM network core network as depicted in the following GSM network diagram. Also shown is Arduino which is connected with Sim900A GSM shield.

Arduino & Sim900 GSM module in GSM mobile network

In the GSM network architecture shown above, if the Sim900 with Arduino  originates a call/data then it is first communicates with a BTS(Base Transceiver Station). The voice/data from BTS goes to Base Station Controller(BSC) which then transfers to the Mobile Switching Center(MSC). The Mobile Switching Center transfers the call or SMS or internet data to the dialed recipient. The same thing happens in reverse direction if the Sim900/Arduino is the receiver. The MSC is where the SMS server called Short Message Service Center (SMSC), voice switching server, internet router, email server, FTP server etc installed. It is also the place where the mobile network and other network are connected such as PSTN(Public Switch Telephone Network), satellite etc. A number of BSC are controlled by a single MSC and a number of BTS are controlled with a Base Station Controller(BSC).

Interfacing Arduino with Sim900A GSM module

 The following picture shows how interface Arduino with Sim900A GSM module. The Arduino Tx is connected to the Sim900 GSM module RXD pin, Arduino Rx is connected to the module TXD pin and the ground GND of the Arduino must be connected to the module ground GND pin. Furthermore, the Arduino should be power supplied using 5V and the Sim900 module should be power supplied using another +5V power supply. The Arduino 5V should not be used to power the module.

Interfacing Arduino with Sim900A GSM module

Programming Sim900 with Arduino

In this tutorial we will show Arduino can be programmed to send and receive AT command to/from Sim900 GSM module. The following is the Arduino program code to send/receive AT command to/from GSM module.


 #include <SoftwareSerial.h>
    
    SoftwareSerial sim900(8,7); // Rx,Tx
    char c;
  
    void setup() {
    // set serial communication with Terminal
    Serial.begin(9600);
    // set serial communication with Sim900
    sim900.begin(9600); 
    while(!Serial);
      Serial.println("Arduino is ready.");
    }
    
    void loop(){
        //Read from SIM800 and send to Terminal Serial Monitor
        if (sim900.available()){ 
          c = sim900.read();
          Serial.write(c);
          }
          //Read from Terminal Serial Monitor and send to sim900
          if (Serial.available()){ 
            c = Serial.read();
            sim900.write(c); 
          }        
    }


Since Arduino Tx and Rx pins are used for communication with PC for USB serial program transfer we cannot use it. Hence we create another serial port using SoftwareSerial library. Using SoftwareSerial library we have configured pin 8 and pin 7 of Arduino as Rx and Tx pins. We have setup the serial baud rate for communication with the terminal and for communication with the sim900 module. Both the baud rate is configured as 9600.

AT command

 Once the code is uploaded we can perform AT communication with Sim900 GSM shield. Though we can use any terminal, the Arduino serial monitor is not suitable for doing AT communication because it does not support key controls like Ctrl+Z and Esc which are often required during AT communication such as in SMS mode. Therefore here we will use Tera Term terminal software which is free for download(just google it). You can also use other terminal like Putty which is also free for download. 

After you open the terminal select the proper serial COM port. With tera term this is as shown below.

Then you should also make sure you have set up your terminal baud rate to 9600.


After this we are ready to perform AT tests. In the following examples we will show briefly some AT basic command to see settings, send/receive SMS message and call receive and making call using Sim900 GSM module.

AT commands to check Network and Sim status and other setting

The usual way to start AT command is to actually see whether there is any successful AT communication, that is whether Sim900A gives response to AT command. For this type AT and hit enter in the terminal, if the reply is OK then AT command works and you are good to go.


We can then inquire many information related to GSM network and Sim card. For example we can inquire whether the sim card in the sim900 module is registered or not using the AT command AT+CREG? We can get signal strength parameter using the AT command AT+CSQ. We can get sim information using the AT+CCID command. The command AT+CPIN can be used to check whether the sim card is inserted or not. We can also ask for baud rate setting using the AT+IPR=? command.

All these AT commands entered and response from Sim900 module is shown in the picture below.

Send SMS using AT command

To send SMS using Sim900 GSM module using AT command follow the steps below.

1. Set SMS mode 

Command: at+cmgf=1 (press enter)

Reply: OK

2. Enter the phone number to send SMS message

Command: at+cmgs="+XXXXXXXXXXXX"

Reply: >

3. Write message 

For Example: >ee-diary.blogspot.com

4. To send message and exit from SMS mode press Ctrl+Z on the keyboard. To escape from SMS mode pess Esc key on keyword 

Below picture shows how to send SMS message using Sim900 

Receive SMS using AT command

To receive SMS on Sim900 follow the following steps.

1. Set SMS mode 

Command: at+cmgf=1(Enter)

Reply: OK

2. Set SMS message reading mode to read newly arrived message

Command: at+cnmi=2,2,0,0 (press enter)

Reply:OK

3.If there is any new message it will displayed

For example, sms message "This is my sms msg" was sent from mobile phone to Sim900 and the following picture shows how to receive SMS message using Sim900 and the SMS message that was received.

AT command to start voice call

To call a number type the command atd+[YourNumber]; in the terminal, you will get OK as reply if there is a successful connection. 

command: atd+[YourNumber];
reply: OK

If the dialed user cut off the incoming call then busy will displayed:

reply: BUSY

See the picture below to make a call using Sim900 via tera term terminal.

AT command to receive voice call

 When you dial the sim900 number, you will see RING message in the terminal. To receive the voice call type ata and to hang up the call type ath. This is illustrated with tera term terminal below.

 
In Summary, we have shown here how to program Arduino to communicate to the Sim900 using terminal by sending AT commands. We have shown how to send AT command to get network and other setting from the Sim900 module. We have shown how to send and receive SMS using Sim900A module. We have also shown how to make phone call and how to receive phone call using Sim900 GSM shield. GSM module such as Sim900A, Sim900 can be used for application where voice or data communication over mobile network is required. For example, Sim900A can be used to create Internet of Things(IoT) application where sensors or actuators are controlled over the mobile network. Although such wireless solution can be achieved using ESP8266 WiFi module WiFi communication the advantage of using GSM based IoT over WiFi IoT is that GSM wireless coverage will be larger and there will be more bandwidth available to send/receive data and voice controlled application can be build easily.

See next the tutorial on how to Send and Receive SMS with Sim900 & Arduino.

Post a Comment

Previous Post Next Post