GSM SIM900A Arduino Tutorial (Easy 4 Step)

by AlphaPagon in Circuits > Arduino

24984 Views, 3 Favorites, 0 Comments

GSM SIM900A Arduino Tutorial (Easy 4 Step)

5583a740-15bf-4c9f-ae8d-65d1072f7468-600x600.jpg
SIM900A-block-e1508248047694.jpg

Introduction to SIM900A

SIM900A is a GSM module that function like phone. It can send a message, call a phone number and use GPRS to send data. Here’s the simple feature taken from it’s datasheet :

  • Quad-Band 850/ 900/ 1800/ 1900 MHz
  • Dual-Band 900/ 1900 MHz
  • GPRS multi-slot class 10/8GPRS mobile station class B
  • Compliant to GSM phase 2/2+Class 4 (2 W @850/ 900 MHz)
  • Control via AT commands (GSM 07.07 ,07.05 and SIMCOM enhanced AT Commands)
  • Low power consumption: 1.5mA(sleep mode)
  • Operation temperature: -40°C to +85 °C

Buy SIM900A: https://shopee.com.my/product/96013540/3745454063/

Material Preparation

SIM900A-with-arduino.jpg

  1. SIM900A (Buy now)
  2. Arduino UNO (Buy now)
  3. SIM Card
  4. 4 male to female jumper cable (Buy now)

Pin Connection

Pinout-smaller.jpg
wiring.png

We just need connect 4 wires to SIM900A module, that is power connection (VCC and GND). And Serial communication (RX-TX). Because we use arduino UNO which is use 5V operating voltage and has 5V logic level (TTL). So we need to connect arduino to 5RX and 5TX like in pinout picture below. Plug in sim card into sim card cartridge.

SIM900A and Arduino wiring connection
Wire SIM900A module to arduino UNO like this :

  • Arduino -> SIM900A
  • 5V -> VCC
  • GND -> GND
  • 10 -> TX
  • 11 -> RX

Communication Test

If you already connect the module with arduino like in picture above, then this is the time to test communication between module and arduino, to make sure that arduino can give command to SIM900A module. Don’t forget to double check the wiring connection.

In this test, we will use AT Command to communicate with SIM900A module. If we send command “AT” the module should reply “OK”. And if that happen, this means the connection is successful. To do this, we need an arduino sketch like below :

#include <SoftwareSerial.h>
SoftwareSerial SIM900A(10,11); // RX | TX
// Connect the SIM900A TX to Arduino pin 2 RX. 
// Connect the SIM900A RX to Arduino pin 3 TX. 
char c = ' ';
void setup() 
{
// start th serial communication with the host computer
Serial.begin(9600);
while(!Serial);
Serial.println("Arduino with SIM900A is ready");

// start communication with the SIM900A in 9600
SIM900A.begin(9600); 
Serial.println("SIM900A started at 9600");
delay(1000);
Serial.println("Setup Complete! SIM900A is Ready!");
}

void loop()
{

// Keep reading from SIM800 and send to Arduino Serial Monitor
if (SIM900A.available())
{ c = SIM900A.read();
Serial.write(c);}

// Keep reading from Arduino Serial Monitor and send to SIM900A
if (Serial.available())
{ c = Serial.read();
SIM900A.write(c); 
}

}

Upload the sketch above and open Serial Monitor. Don’t forget to use BOTH NL&CR in arduino Serial monitor option.

Test the connection by type “AT” and then enter. If the arduino reply “OK” means your connection is established and working. If still no answer from arduino then check your connection and wiring again.

Since we already success use an AT command to SIM900A module, now we can try another AT command. These are some basic AT command we can use :

Change mode to sms :
AT+CMGF=1

Read SMS in text mode :
AT+CNMI=2,2,0,0,0

Make a call :
ATD+1123456789; //replace with number and country code you like

Disconnect / hangup call :
ATH

Receive a phone call :
ATA

Complete Source Code

We will try an complete example how to send and receive message. Use the sketch below :

#include <SoftwareSerial.h>

SoftwareSerial SIM900A(10,11);

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 or r to receive message");
}


void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      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=\"+6281542787536\"\r"); //Mobile phone number to send message
  delay(1000);
  Serial.println ("Set SMS Content");
  SIM900A.println("Good morning, how are you doing?");// 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");
}


 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");
 }

Complete Video Tutorial Here

SIM900A with arduino tutorial. How to send and receive message