controlling multiple relays through sms

Hello,
I am newbie in Arduino. Currently i am working on project controlling multiple relays by sending SMS messages to GSM module.I designed a code and tried it on GSM module 900 it was working fine but when i tried to do same thing with GSM800 the module is not responding properly. Means module recieves SMS but unable to proceed same functions. help me and thanks in advance.
This is the code.

#include <SoftwareSerial.h>

//char inchar; //Will hold the incoming character from the Serial Port.
SoftwareSerial mySerial(4,5);

int a,b,batt,quality;
String str="";
int pin6= 6;
int pin7= 7;
char val;
int count, prev=0;

void sms()
{ digitalWrite(13,0);
  Serial.println(mySerial.read());
  mySerial.println("AT+CMGF=1");    //To send SMS in Text Mode
  delay(2000);
  mySerial.println("AT+CMGS=\"+919930275662\"\r"); // change to the phone number you using
  delay(2000);
  mySerial.println(str);
  if(val=='@'|| val=='!'){
  if(val=='@')
  {mySerial.println(batt);}
  else if(val='!')
  {mySerial.println(quality);}}
  else{mySerial.println(" ");}
  delay(2000);
  mySerial.println((char)26);//the stopping character
  delay(5000);

  mySerial.println("AT+CMGD=DEL ALL");
    
}

void setup()

{
  delay(5000);
  count=0;
  pinMode(13,OUTPUT);
  mySerial.begin(9600);
  delay(5000);
  Serial.begin(9600);
  delay(3000); // give time for GSM module to register on network etc.
  mySerial.println("AT+CMGF=1"); // set SMS mode to text
  delay(2000);
//  check();
  
}



/////////////////////////////main loop////////////////////////////////////////////////////////////////////////////
void loop()
{
  
  if (mySerial.available() > 0)
  { val=mySerial.read();
  Serial.println(val);
    switch (val)
    {
      case '@':
      batt=analogRead(A0);
      batt=map(batt,0,1023,0,100); 
      str="Battery power is good";
       sms();
        break;

      case '#':
      digitalWrite(pin6,1);     //Relay 1
      delay(3000);
      digitalWrite(pin6,0);
      str="Power now Reset";
        sms();
        break;

      case '%':
      digitalWrite(pin7,1);    //Relay 2
      delay(3000);
      digitalWrite(pin7,0);
      str="Internet now Reset";
      sms();
      break;

      case '&':
      a=digitalRead(8);        //AC Power check
      if(a==1)
      {str="AC Power Available";}
      else if(a==0)
      {str="AC Power Not Available";}
       sms();
       break;

      case '*':
      b=digitalRead(9);       //Internet  check
      if(b==1)
      {str="Internet Available";}
      else if(b==0)
      {str="Internet Not Available";}
        sms();
        break;

        
      case '!':
      quality=mySerial.println("AT+CSQ=?");
      delay(1000);
      {str="Signal Quality is";}
        sms();
        break;

      default:
      digitalWrite(13,1);
      a=0;b=0;val=0;

      
    }
  }
a=digitalRead(8);
power_check();
battery();
}

void power_check()
{
  if(a!=prev)
   {
     if(a==1)
     { str="Power is ON";}

    else if(a==0)
     {str="Power is OFF";}
    sms();
   }
prev=a;

}

void battery()
{ batt=analogRead(A0);
  batt=map(batt,0,1023,0,100);
  if (count==0)
  {
  if(batt<50)
  {str="BATTERY LOW";sms();count=1;}
  }
  else if (batt>=50)
  {
    count=0;
    }
  }

Hello,

did you change the setting in the SMS module to work on 800
and is your modem a quad band?

Samir Tafesh

Thank you Samir Tafesh sir for your suggestions.
My modem is quad band but still i have question means what setting should i change in GSM 800 module.I comapared GSM800 and GSM900 AT commands they are same for sending SMS. kindly tell me in deep please.

Dear Brother,
It depends on the model of the modem module,
if you can provide me with the model number i can help you.

Normally we should change the frequency of the modem depending on the network Band

using AT commands we can read the Bands available and change them
here is an example for AirCard Modem:

AT!band? - to query the current frequency band
AT!band=? - to query all available frequency bands
AT!band=00 - to change the frequency band to Automatic
AT!band=04 - to change the frequency band to 2G 850/1900

it might not be applicable on your modem, preferable to have your modem model number to help you

Regards
Samir Tafesh