GSM Modem Interfacing With Arduino

In this tutorial we will learn how to interface GSM Modem and send SMS. GSM Modems are easy long range interface where we need to read sensor data or control electrical equipment. We will start with selection of GSM modem, AT commands and connection of GSM Module with Arduino. A GSM modem is a specialized type of modem or phone hardware on small PCB which accepts a SIM card, and operates over a subscription to a mobile operator, just like a mobile phone.

What you will learn?

  1. Which GSM Modem should I use?
  2. How to connect GSM Modem with Arduino?
  3. How to send SMS using GSM module using Arduino?

Selection of GSM Modem

GSM modem are selected based on price, interface required and size. You can find detailed explanation here. We will not go deep into selection process. We are using SIM900A GSM Modem for this tutorial.

Connection of GSM Modem with Arduino Uno

 

GSM Modem interfacing with arduino
GSM Modem interfacing with arduino

Connecting GSM modem with arduino is very simple just connect RX Line of Arduino to TX Line of GSM Modem and vice versa TX of arduino to Rx of GSM modem. Make sure use TTL RX, TX lines of GSM modem.

Give 12V 2Amp power supply to GSM modem, Use of less current power supply can cause reset problem in GSM modem, give sufficient current to GSM modem.

Arduino Code for Sending SMS using GSM Modem

// GSM Modem SMS Sending Tutorial
// circuits4you.com

void setup()
{
    Serial.begin(9600);   //Initialise serial to communicate with GSM Modem
}

void loop()
{
     delay(10000); //Give enough time for GSM to register on Network
     SendSMS();    //Send one SMS
     while(1);     //Wait forever
}

void SendSMS()
{
  Serial.println("AT+CMGF=1");    //To send SMS in Text Mode
  delay(1000);
  Serial.println("AT+CMGS=\"+9198xxxxxxxx\"\r"); //Change to destination phone number 
  delay(1000);
  Serial.println("Hello from GSM Modem!");//the content of the message
  delay(200);
  Serial.println((char)26); //the stopping character Ctrl+Z
  delay(1000);  
}

Code is kept very simple we are using we are using few AT commands to send the SMS. every AT command ends with Carrige return. Always use Serial.println. 

  1.  AT+CMGF=1 set the GSM modem in text mode.
  2. AT+CMGS=”+9198xxxxxxxx” Send SMS to this number
  3. Message text
  4. Message closing character Control+Z. (char(26))

Note: While Programming Remove GSM Modem serial lines. You can use software serial also.

Testing of Code

  1. Insert the sim card.
  2. Upload Code with removed RX,TX lines.
  3. After uploading power off and connect RX,TX Lines.
  4. Turn on Both Arduino and GSM Modem.
  5. Wait for few seconds and see the blinking of network LED slows down. It means it is registered on network.
  6. You will receive SMS after 15 Seconds. If it takes too long to register on network in crease the 10 Second delay to larger value.
  7. For queries comment below.
  8. To use GSM Modem with Other microcontroller use this tutorial this.

 

In this tutorial you learned how to interface GSM Modem and send SMS. Its very simple but need to take care of Power supply current requirements, and Serial interface voltage levels USART(TTL) or RS232.

2 thoughts on “GSM Modem Interfacing With Arduino

Leave a Reply