Pages: [1]   Go Down
Author Topic: Cannot receive SMS on GSM Shield  (Read 4458 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,

I have the following hardware context:

Arduino Mega 2560
GSM Shield (pin 2 -GSM TX- wired to pin 10)

So far I have been able to send SMS and to receive calls on the Arduino GSM Shield. Unfortunately, I am not receiving any SMS on the shield. I tried to send SMS from another SIM (mobile phone) on the same network and the SMS does not get there. I even sent a SMS through SKYPE but no success at all. The SMS simply does not get there.

Has anyone experienced this problem? What kind of test should I run in order to figure out the root of the problem?

The code I am using is the one provided on the Arduino's examples:

Code:
/*
 SMS receiver
 
 This sketch, for the Arduino GSM shield, waits for a SMS message
 and displays it through the Serial port.
 
 Circuit:
 * GSM shield attached to and Arduino
 * SIM card that can receive SMS messages
 
 created 25 Feb 2012
 by Javier Zorzano / TD
 
 This example is in the public domain.
 
 http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS
 
*/

// include the GSM library
#include <GSM.h>

// PIN Number for the SIM
#define PINNUMBER ""

// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

// Array to hold the number a SMS is retreived from
char senderNumber[20];  

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("SMS Messages Receiver");
  Serial.println("Initializing SIM Card");
    
  // connection state
  boolean notConnected = true;
  
  // Start GSM connection
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
  
  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}

void loop()
{
  char c;
  
  // If there are any SMSs available()  
  if (sms.available())
  {
    Serial.println("Message received from:");
    
    // Get remote number
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);

    // An example of message disposal    
    // Any messages starting with # should be discarded
    if(sms.peek()=='#')
    {
      Serial.println("Discarded SMS");
      sms.flush();
    }
    
    // Read message bytes and print them
    while(c=sms.read())
      Serial.print(c);
      
    Serial.println("\nEND OF MESSAGE");
    
    // Delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }
  else
    {
      Serial.println("No SMS available");
    }

  delay(1000);

}

Basically, the output is always the same: "No SMS available" :-(


Thanks in advance


« Last Edit: July 16, 2013, 07:13:28 am by Porkin » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 110
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone experienced this problem? What kind of test should I run in order to figure out the root of the problem?

Hey,

I have not had that issue when I used the example script above so I presume there is problem with the SIM or with the compatibility between SIM and GSM shield. You are using the GSM shield of arduino right?

Can you receive sms when that SIM is in a normal cell phone?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using the Arduino GSM Shield to avoid any compatibility issues.

When I connect the Sim Card to a mobile phone, the SMS messages are received immediately.

I am also able to make phone calls and receive phone calls on the Arduino GSM Shield.

The problem is to receive SMS :-(

Any clue?
« Last Edit: July 16, 2013, 11:10:38 am by Porkin » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 110
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you show the debug feedback?

Code:
GSM gsmAccess(true);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Mathias,

first of all, thanks for your interest and support. As far your request is concerned, I am getting the following answer on the Serial Monitor:

AT+CMGL="REC UNREAD",1%13%
125 3>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
3 9>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
9 15>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
15 21>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
21 27>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
27 33>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
33 39>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
39 45>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
45 51>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
51 57>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
57 63>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
63 69>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
69 75>%13%%10%OK%13%%10%

................................................

Please see what you can do with this message.

Thanks in advance
Alexandre
« Last Edit: July 16, 2013, 06:57:20 pm by Porkin » Logged

Madrid (Spain)
Offline Offline
Full Member
***
Karma: 0
Posts: 137
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using a BlueVia SIM card (included with official GSM shield), you will be able to receive SMS only from another BlueVia SIM card.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there,

I am not using the original Sim Card that comes with the GSM Shield. I purchased a sim card from a Portuguese operator. In this specific case, it is Optimus (www.optimus.pt).
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 110
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is what I get with the code in the first post and the debugger on (including 1 sms I've sent):

AT+CMGL="REC UNREAD",1%13%
70 76>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
76 82>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
82 88>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
88 94>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
94 100>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
100 106>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
106 1>%13%%10%OK%13%%10%%13%%10%+CMTI: "SM",1%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
1 82>%13%%10%+CMGL: 1,"REC UNREAD","+phone number here","","2013/07/17 16:07:33+08"%13%%10%Test2%13%%10%%13%%10%OK%13%%10%
Message received from:
+phone number here
Test2
END OF MESSAGE
AT+CMGD=1%13%
82 88>%13%%10%OK%13%%10%
MESSAGE DELETED
AT+CMGL="REC UNREAD",1%13%
88 94>%13%%10%OK%13%%10%
No SMS available

So that's basically the same as with you. Sorry I'm afread I cannot help you. Maybe contact your supplier?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is what I get with the code in the first post and the debugger on (including 1 sms I've sent):

AT+CMGL="REC UNREAD",1%13%
70 76>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
76 82>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
82 88>%13%%10%OK%13%%10%
No SMS available
AT+CMGL="REC UNREAD",1%13%
88 94>%13%%10%OK%13%%10%
No SMS available

.................

So that's basically the same as with you. Sorry I'm afread I cannot help you. Maybe contact your supplier?

When you talk about the supplier, are you referring to the mobile network operator?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,

I have finally figured out the root of the problem. Basically, there is some sort of problem with the Sim card I purchased only to be used with the Arduino. A few minutes ago I inserted my old sim on the GSM Shield and I have sent a few SMS's to it. The GSM Shield received each SMS with no problem at all.

Thanks everyone for the support on this issue.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey I am a beginner user to the GSM shield. I have spent probably 40 hours going from store to store trying different phones to unlock the SIM card and try different sim cards and literally only one provider allowed for proper connectivity. I live in Ontario, Canada and the network may be slightly different than the GSM shield may have been designed for - But from what I've learned was that the GSM shield seemed to work for me RX and TX SMS when there actually was a pin number associated with the SIM card and the codes in the void set up addressed it. Just a tip to try out.

Akash
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I posted this in a different thread, I hope that isn't against forum rules... I will delete the post if it is.

 I can use the following code to receive SMS messages, and then use the body of the SMS message to do some conditional programming.  The only problem is that I can only do it by typing my AT commands into the serial monitor. When I try to put the receive SMS command (AT+CMGR=1,0) in my loop, it doesn't work.  Ideally I would be able to check for a new SMS every 30 seconds.  This is the working code:
Code:
#include <SoftwareSerial.h>
#include <string.h>
char command = 0; //Conditional Programming Variable changes with SMS content.
char incoming_char = 0;
SoftwareSerial cell(7, 8); //my shield uses these pins for software serial.

void setup()
{
  Serial.begin(19200);
  cell.begin(19200);
  delay(2000);
  Serial.print("Starting modem communication...");
  delay(12000);
  Serial.print("OK\nIntroduce your AT commands:\n");
}

void loop()

{
  if(cell.available() > 0)
  {
    incoming_char=cell.read();
    if((incoming_char >= ' ') && (incoming_char <= 'z'))
      Serial.print(incoming_char);
    if(incoming_char=='#'){
      Serial.println("SMS command mode:"); //If the SMS contains "#" the arduino looks for commands that follow.
      command=cell.read();
    }
    if (command == 'a'){  //If the next character in the SMS is "a", then do the following
      Serial.println("Commands would execute here and now.");
      command = 0;
    }

    else
    {
      Serial.print("%");
      Serial.print((int)incoming_char);
      Serial.print("%");
      if(incoming_char==10)
        Serial.println();

      //Serial.println(incoming_char);



    }
  }

  if(Serial.available() > 0)
  {
    incoming_char = Serial.read();
    cell.print(incoming_char);
  }
}




When I send a SMS to my cell shield that contains "#a" in the body of the message and enter the "AT+CMGR=1,0" into the serial monitor the program reads the SMS and then does whatever I tell it to do.  Right now it just executes a serial print that says "Commands would execute here and now".

After I run this I'd also like to delete the SMS with the "AT+CMGD=1" command.

Here is my code with the timed SMS check... It runs the "AT+CMGR=1,0" command every 30 seconds, but doesn't work.

Code:
#include <SoftwareSerial.h>
#include <string.h>
char command = 0; //Conditional Programming Variable changes with SMS content.
char incoming_char = 0;
SoftwareSerial cell(7, 8); //my shield uses these pins for software serial.

//These variables are for timing the Receive SMS command.
long previousMillis = 0; //Equals current millis every time interval is met.
long interval = 30000; //Amount of time to wait between Receive SMS commands

void setup()
{
  Serial.begin(19200);
  cell.begin(19200);
  delay(2000);
  Serial.print("Starting modem communication...");
  delay(12000);
  Serial.print("OK\nIntroduce your AT commands:\n");
}

void loop()

{
//--------Timed SMS Receive command code ---------
  if (currentMillis - previousMillis > interval) {

    cell.print('AT+CMGR=1,0');

    previousMillis = currentMillis;
  }
//------------------------------------------------


  if(cell.available() > 0)
  {
    incoming_char=cell.read();
    if((incoming_char >= ' ') && (incoming_char <= 'z'))
      Serial.print(incoming_char);
    if(incoming_char=='#'){
      Serial.println("SMS command mode:"); //If the SMS contains "#" the arduino looks for commands that follow.
      command=cell.read();
    }
    if (command == 'a'){  //If the next character in the SMS is "a", then do the following
      Serial.println("Commands would execute here and now.");
      command = 0;
    }

    else
    {
      Serial.print("%");
      Serial.print((int)incoming_char);
      Serial.print("%");
      if(incoming_char==10)
        Serial.println();

      //Serial.println(incoming_char);



    }
  }

  if(Serial.available() > 0)
  {
    incoming_char = Serial.read();
    cell.print(incoming_char);
  }
}





The result is this:
"1%49%1%49%3%51%1%49%2%50%"

Which makes no sense to me... I realize I haven't included the auto delete code in either example, that's because I haven't even gotten to that point yet.  Could you please point out what I am doing wrong? I spent all day trying to figure it out. Thanks in advance.
« Last Edit: July 22, 2013, 06:57:24 pm by captainhooyah » Logged

Pages: [1]   Go Up
Jump to: