Pages: [1]   Go Down
Author Topic: GSM Shield problem - reset during registration  (Read 5334 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear community members,

I am working on a project that uses an Arduino Ethernet R3 combined with a Telefonica GPS/GPRS shield. The board is connected to a Linux laptop using a  PL2303 based board (serial to USB). The arduino is powered with an external adapter delivering 7.5V at 1A.

I am struggling to get the SendSMS example working. I filled in the PIN and activated debugging of the GSM class. This gives me the following output:

Code:
SMS Messages Sender
AT%13%
0 9>AT%13%%13%%10%OK%13%%10%
AT+CPIN=3511%13%
9 44>AT+CPIN=3511%13%%13%%10%+CPIN: READY%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
44 75>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%SMS Messages Sender
SMS Messages Sender
SMS Messages Sender
AT%13%
0 9>AT%13%%13%%10%OK%13%%10%
AT+CPIN=3511%13%
9 44>AT+CPIN=3511%13%%13%%10%+CPIN: READY%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
44 75>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
SMS Messages Sender
SMS Messages Sender

The script appears to crash on the GSM.begin() function, while connecting to the network. It then resets and tries again.

I also tested the Telefonica shield on an Arduino UNO R2 and used the exact same code as with the Ethernet. This works perfectly and gives the following output:

Code:
SMS Messages Sender
AT%13%
0 9>AT%13%%13%%10%OK%13%%10%
AT+CPIN=3511%13%
9 44>AT+CPIN=3511%13%%13%%10%+CPIN: READY%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
44 75>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
75 106>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
106 9>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
9 40>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
40 71>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
71 102>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
102 5>AT+IFC=1,1%13%%13%%10%OK%13%%10%%13%%10%Call Ready%13%%10%
AT+CMGF=1%13%
5 21>AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
21 37>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
37 48>ATE0%13%%13%%10%OK%13%%10%
AT+COLP=1%13%
48 54>%13%%10%OK%13%%10%
GSM initialized
Enter a mobile number: 0464000000
Now, enter SMS content: SENDING

Message:
Hello word!
AT+CMGS="0464000000"%13%
54 58>%13%%10%>
Hello word!%26%%13%
54 76>%13%%10%> %13%%10%+CMGS: 5%13%%10%%13%%10%OK%13%%10%

COMPLETE!

Enter a mobile number:

And this is the code used on both boards:
Code:
#include <GSM.h>

#define PINNUMBER "3511"

// initialize the library instance
GSM gsmAccess(true); // include a 'true' parameter for debug enabled
GSM_SMS sms;

void setup()
{
  // initialize serial communications
  Serial.begin(9600);
 
  Serial.println("SMS Messages Sender");

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    delay(1000);
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
 
  Serial.println("GSM initialized");
}

void loop()
{

  Serial.print("Enter a mobile number: ");
  char remoteNumber[20];  // telephone number to send sms
  readSerial(remoteNumber);
  Serial.println(remoteNumber);
   
  // sms text
  Serial.print("Now, enter SMS content: ");
  char txtMsg[200];
  readSerial(txtMsg);
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);
 
  // send the message
  sms.beginSMS(remoteNumber);
  sms.print(txtMsg);
  sms.endSMS();
  Serial.println("\nCOMPLETE!\n");
}

int readSerial(char result[])
{
  int i = 0;
  while(1)
  {
    while (Serial.available() > 0)
    {
      char inChar = Serial.read();
      if (inChar == '\n')
      {
        result[i] = '\0';
        Serial.flush();
        return 0;
      }
      if(inChar!='\r')
      {
        result[i] = inChar;
        i++;
      }
    }
  }
}

Can anyone explain this behavior? Why does is work on the regular Arduino UNO, but not on the Ethernet?
Logged

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

The ethernet stack and the gprs shield both consumes RAM memory which is very limited. Once there is no memory left, random issues occur often followed by a crash and reset. This would be my first bet in this case.

Google and check for code that tests for low RAM memory as memory problems are rather hard to find out on the Arduino.

We had to move a gprs application to the ATMega 1284 to be able to use some extra libraries for i2c and one-wire sensors.
Logged

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

I agree......

The Mega do´s have what i takes to bring some sketches to the next level.

There is another way though,

http://forum.arduino.cc/index.php?PHPSESSID=lq5274qjlrv8534btbvfpmqlv2&topic=176235.0

Quote
    if((gsmAccess.begin(PINNUMBER, false)==GSM_READY) &

try it out, and report back if it still hangs in the restart funk.  smiley-kitty

Logged

Pages: [1]   Go Up
Jump to: