Go Down

Topic: GSM shield does not receive sms (Read 1 time) previous topic - next topic

aamir5253

Hi friends.......im using arduino mega and GSM shield from GEETECH. I have a problem that the commands AT+CMGL="ALL" doesnot work and also the command AT+CMGR=1,0 does not work i am unable to receive sms. THe command CMGR worked for some time but i was not getting the whole msg and was getting a part of it only. Im using hardware serial i suppose that the buffer of 64 bytes gets full so i cannot get full sms but im not sure about that.

Im attaching the code so please someone help me.

#include <String.h>

void setup()

{
  pinMode(13, OUTPUT);
  Serial.begin(9600); 
  delay(100);
  Serial.println("AT");    //Because we want to send the SMS in text mode
  delay(800); 
  Serial.println("ATE0");    //Because we want to send the SMS in text mode
  delay(300);
  Serial.println("AT+CMGF=1");    //Because we want to send the SMS in text mode
  delay(300);
  Serial.println("AT+CPMS=\"SM\"");      //Preferred SMS Message Storage
  delay(300); 
  Serial.println("AT+CNMI=1,2,0,0,0");      //Preferred SMS Message Storage
  delay(300);

while (Serial.available())
               Serial.write(Serial.read());     
}

void loop()
{   
 if (Serial.available())
     Serial.println("AT+CMGL=\"ALL\"");
     delay(1000);
     
       while (Serial.available())
                     Serial.write(Serial.read());           
 
      Serial.println("AT+CMGR=1,0");
      delay(1000);
           
      while (Serial.available())
                      Serial.write(Serial.read()); 
                 
            Serial.end();
            delay(50);
            Serial.begin(9600);
            delay(50);
}

dannable

Code: [Select]
delay(1000)

You might want to rethink this - send a command, then twiddle your thumbs for a whole second, then see what's going on?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

aamir5253

i also removed the delay but nothing happens what should i do then ?

dannable

Just deleting it isn't going to work either. Send a command to the device, then instantly see if it's replied before it has even had chance to execute your command? That's why I said you need to rethink it.

Perhaps what you want to do is wait until you start to get a response, then keep reading until there is no more to read? The only problem is that you won't get an 'end of record' marker so you'll need to read until there is no more, say more than 100 milliseconds after the last character has been read?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

aamir5253

I also tried that i changed the delay but still no sms is received nor the command AT+CMGL works.

Go Up