Saturday, January 17, 2015

Arduino Code for GSM Module basic program to find the network information

GSM Basic code to find the firmwire version, Network list, Network information, and baud rate. This uses the AT commands with the arduino command to communicate with the GSM module. I test these code with sim900a gsm module.

___________________________________________________________________________________

/*
Press--> a: AT Command.
f: To get Firmware Version.
l: To get List of Network.
i: To get Network Info.
v: To get VBAT voltage .
b: To get Baud rate Info.
*/

#include <SoftwareSerial.h>

SoftwareSerial mySerial(7, 8);

void setup()
{
  mySerial.begin(9600);               // the GPRS baud rate
  Serial.begin(9600);    // the GPRS baud rate
  delay(500);
}


void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 'a':
      AT();
      break;
    case 'i':
      Network();
      break;
    case 'f':
      FirmVersion();
      break;
    case 'l':
      NetworkList();
      break;
    case 'v':
      Battery();
      break;
    case 'b':
      Baud();
      break;
  }

 if (mySerial.available()>0)
   Serial.write(mySerial.read());
}

void AT()
{
  mySerial.println("AT");
  delay(100);
}

void Network()
{
  mySerial.println("AT+CSQ");
  delay(1000);

  mySerial.println("AT+COPS?");
  delay(1000);
}

void FirmVersion()
{
  mySerial.println("ATI");
  delay(100);
}

void NetworkList()
{
  mySerial.println("AT+COPS=?");
  delay(100);
}

void Battery()
{
  mySerial.println("AT+CBC");
  delay(100);
}

void Baud()
{
  mySerial.println("AT+IPR=0");
  delay(1000);
  mySerial.println("AT+IPR?");
  delay(100);
}

____________________________________________________________________________________



2 comments :

Post a Comment