Send And Receive SMS Using SIM900 GSM Module

Hey Geeks, welcome back to Techatronic. Are you looking for a GSM-based SMS and calls-making project, well if so then you are at the right destination. In this article, we are going to discuss how you can send and receive SMS using an Arduino with the help of a SIM900 GSM module. Also, check out more amazing projects on Arduino and read our Arduino E-book which contains 10+ projects with complete circuits and codes. We have to program the Arduino for making calls or sending, receiving SMS. In this project, we are sending and receiving SMS and make calls using a GSM module with an Arduino UNO microcontroller board. You can check the interfacing of a SIM900 GSM module with Arduino if you don’t know about it. Please complete the circuit and then upload the given code to the Arduino for performing the desired operation. You can also check to digitalize the GSM-based forest fire alert system made by us.

How Does it Work?

Connect a DC 12-volts 2 Amp power supply to the DC jack of the GSM sim-900 module. Insert a sim into the given slot in the GSM module. We are using AT commands in the code for performing various functions in which AT stands for attention. The AT+CMGF=1 is used to select the operating mode of the GSM module. The AT+CMGS is used to send the SMS message. AT+CNMI, this AT command is used to receive a live SMS. For performing different operations you have to specify the instruction in the serial monitor. To make a call type “C”, to receive an SMS type “R”, to send an SMS type “S” in the serial monitor. Use the image given below to locate the serial monitor. We attach some screenshots of the output on the serial monitor. Please write the contact number of the sim you are using in the code so that you can operate the GSM module.

sim900 gsm module

Components Required

  • Arduino UNO
  • GSM SIM 900 Module
  • USB cable for uploading the code
  • DC 12-volts 2 Amp Adapter
  • Jumper wires

sim900 gsm module

Circuit Diagram for the Project

sim900 gsm module

Make the connections according to the circuit diagram given above. Connect the GND pin of the Arduino with the GND pin of the GSM module. Attach the digital-11 pin of the Arduino to the RX pin of the GSM module. Join the digital-10 pin of the Arduino with the TX pin of the GSM module.

Code for the Project

NOTE: Please upload the codes given below one by one to the Arduino for performing different functions. You need to install <SoftwareSerial.h> library before uploading the code. Please check how to install zip libraries to the Arduino if you don’t know.

  • Code for sending SMS
 // Techatronic.com   
  // Download Library of SoftwareSerial link given   
  // https://github.com/PaulStoffregen/SoftwareSerial  
  #include <SoftwareSerial.h>   
  SoftwareSerial SIM900A(10,11); // SoftSerial( RX , TX );   
  // 10 pin connect to TX of GSM SIM 900 Module   
  // 11 pin connect to RX of GSM SIM 900 Module   
  void setup()   
  {   
  SIM900A.begin(9600); // Setting the baud rate of GSM Module    
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)   
  Serial.println ("SIM900A Ready");   
  delay(100);   
  Serial.println ("Type s to send message ");   
  }   
  void loop()   
  {   
  if (Serial.available()>0)   
   switch(Serial.read())   
  {   
   case 's':   
   SendMessage();   
   break;   
  }   
  if (SIM900A.available()>0)   
   Serial.write(SIM900A.read());   
  }   
  void SendMessage()   
  {   
  Serial.println ("Sending Message");   
  SIM900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode   
  delay(1000);   
  Serial.println ("Set SMS Number");   
  SIM900A.println("AT+CMGS=\"xxxxxxxxxx\"\r"); //Write Mobile number to send message   
  delay(1000);   
  Serial.println ("Set SMS Content");   
  SIM900A.println("Helo, Techatronic.com");// Messsage content   
  delay(100);   
  Serial.println ("Finish");   
  SIM900A.println((char)26);// ASCII code of CTRL+Z   
  delay(1000);   
  Serial.println ("Message has been sent ->SMS Selesai dikirim");   
  }   
  • Code for receiving SMS
 // Techatronic.com   
  // Download Library of SoftwareSerial link given   
  // https://github.com/PaulStoffregen/SoftwareSerial   
  #include <SoftwareSerial.h>   
  SoftwareSerial SIM900A(10,11); // SoftSerial( RX , TX );   
  // 10 pin connect to TX of GSM SIM 900 Module   
  // 11 pin connect to RX of GSM SIM 900 Module   
  void setup()   
  {   
  SIM900A.begin(9600); // Setting the baud rate of GSM Module    
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)   
  Serial.println ("SIM900A Ready");   
  delay(100);   
  Serial.println ("Type r to receive message");   
  }   
  void loop()   
  {   
  if (Serial.available()>0)   
   switch(Serial.read())   
  {   
   case 'r':   
   RecieveMessage();   
   break;   
  }   
  if (SIM900A.available()>0)   
   Serial.write(SIM900A.read());   
  }   
  void RecieveMessage()   
  {   
  Serial.println ("SIM900A Membaca SMS");   
  delay (1000);   
  SIM900A.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS   
  delay(1000);   
  Serial.write ("Unread Message done");   
  }   
  • Code for calling and ringing
 // Techatronic.com   
  // Download Library of SoftwareSerial link given   
  // https://github.com/PaulStoffregen/SoftwareSerial   
  #include <SoftwareSerial.h>   
  SoftwareSerial SIM900A(10,11); // SoftSerial( RX , TX );   
  // 10 pin connect to TX of GSM SIM 900 Module   
  // 11 pin connect to RX of GSM SIM 900 Module   
  void setup()   
  {   
  SIM900A.begin(9600); // Setting the baud rate of GSM Module    
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)   
  Serial.println ("SIM900A Ready");   
  delay(100);   
  Serial.println (" Type c to Call ");   
  }   
  void loop()   
  {   
  if (Serial.available()>0)   
   switch(Serial.read())   
  {   
   case 'c':   
   RecieveMessage();   
   break;   
  }   
  if (SIM900A.available()>0)   
   Serial.write(SIM900A.read());   
  }   
  void RecieveMessage()   
  {   
  Serial.println ("SIM900A is Calling");   
  delay (1000);   
   SIM900A.println("ATDxxxxxxxxxx;"); //replace x by your number  
   delay(100);  
   SIM900A.println("ATH");   
  }   

We hope that you like this project and if so please try to make it on your own. Also, check out more tutorials on Arduino and Raspberry Pi made by us. If you are facing any problems let us know in the comments section below.

HAPPY LEARNING!