GPRS connection problem

Hello all,

I'm trying out my new GSM shield module and have succesfully gone trough the first 2 sketches from:

  • Testing the modem and network connection
  • Sending a SMS message

However, I'm stuck with the third sketch "Connecting to the internet". I've modified it a bit to better look at the problem (I'm returning a check if the PIN succeeds and when the GPRS connection works:

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

// PIN number if necessary
#define PINNUMBER ""

// APN information obrained from your network provider
#define GPRS_APN       "web.pro.be" // replace with your GPRS APN
#define GPRS_LOGIN     ""    // replace with your GPRS login
#define GPRS_PASSWORD  "" // replace with your GPRS password

// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;

// This example downloads the URL "http://arduino.cc/latest.txt"

char server[] = "arduino.cc"; // the base URL
char path[] = "http://arduino.cc/latest.txt"; // the path
int port = 80; // the port, 80 for HTTP
int PIN_OK = 0;

void setup()
{
  // initialize serial communications
  Serial.begin(9600);
  Serial.println("Starting Arduino web client.");
  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // pass the PIN of your SIM as a parameter of gsmAccess.begin()
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY && !PIN_OK){
       Serial.println("PIN OK");
       PIN_OK = 1;
       digitalWrite(4,HIGH);
    }
    else if (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY){
      Serial.println("GPRS OK");
      notConnected = false;
      digitalWrite(5,HIGH);
    }
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, port))
  {
    Serial.println("connected");
    // Make a HTTP request:
    client.print("GET ");
    client.print(path);
    client.println(" HTTP/1.0");
    client.println();
  }
  else
  {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available())
  {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.available() && !client.connected())
  {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for(;;)
      ;
  }
}

The result is this:

Starting Arduino web client.
PIN OK

And it stays that way... I do not get an error, I do not get a "'succesfull" message. Just this.

However, when I go to debug mode gsmAccess(true) then I get this:

Starting Arduino web client.
AT%13%
0 9>AT%13%%13%%10%OK%13%%10%
AT+CPIN=....%13%
9 44>AT+CPIN=....%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 120>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%%13%%10%Call Ready%13%%10%
AT+CGREG?%13%
120 23>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
23 54>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
54 85>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
85 102>AT+IFC=1,1%13%%13%%10%OK%13%%10%
AT+CMGF=1%13%
102 118>AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
118 6>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
6 17>ATE0%13%%13%%10%OK%13%%10%
AT+COLP=1%13%
17 23>%13%%10%OK%13%%10%
PIN OK
AT%13%
48 57>AT%13%%13%%10%OK%13%%10%
AT+CPIN=....%13%
57 92>AT+CPIN=....%13%%13%%10%+CPIN: READY%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
92 123>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
123 40>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%%13%%10%Call Ready%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,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
102 5>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
5 22>AT+IFC=1,1%13%%13%%10%OK%13%%10%
AT+CMGF=1%13%
22 38>AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
38 54>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
54 65>ATE0%13%%13%%10%OK%13%%10%
AT+COLP=1%13%
65 71>%13%%10%OK%13%%10%
AT+CGATT=1%13%
71 77>%13%%10%OK%13%%10%
AT+QIFGCNT=0%13%
77 83>%13%%10%OK%13%%10%
AT+QICSGP=1,"web.pro.be","",""%13%
83 89>%13%%10%OK%13%%10%
AT+QIMUX=0%13%
89 95>%13%%10%OK%13%%10%
AT+QIMODE=1%13%
95 101>%13%%10%OK%13%%10%
AT+QINDI=1%13%
101 107>%13%%10%OK%13%%10%
AT+QIREGAPP%13%
107 113>%13%%10%OK%13%%10%
AT+QIACT%13%
113 119>%13%%10%OK%13%%10%
GPRS OK
connecting...
AT+QIDNSIP=1%13%
119 125>%13%%10%OK%13%%10%
AT+QIOPEN="TCP","arduino.cc",80%13%
125 3>%13%%10%OK%13%%10%

125 14>%13%%10%OK%13%%10%%13%%10%CONNECT%13%%10%
connected
GET http://arduino.cc/latest.txt HTTP/1.0%13%%10%%13%%10%
14 10>HTTP/1.1 200 OK%13%%10%Server: Apache%13%%10%Last-Modified: Wed, 05 Jun 2013 10:14:56 GMT%13%%10%Content-Type: text/plain%13%%10%Content-Length: 5%13%%10%
HTTP/1.1 200 OK
Server: Apache
Last-Modified: Wed, 05 Jun 2013 10:14:56 GMT
Content-Type: text
111 107>/plain%13%%10%Content-Length: 5%13%%10%Accept-Ranges: bytes%13%%10%Date: Mon, 24 Jun 2013 20:33:11 GMT%13%%10%X-Varnish: 982801640%13%%10%Age: 0%13%%10%Via: 1.1
/plain
Content-Length: 5
Accept-Ranges: bytes
Date: Mon, 24 Jun 2013 20:33:11 GMT
X-Varnish: 
80 40>982801640%13%%10%Age: 0%13%%10%Via: 1.1 varnish%13%%10%Connection: close%13%%10%X-Cache: MISS%13%%10%%13%%10%0105%10%%13%%10%CLOSED%13%%10%
982801640
Age: 0
Via: 1.1 varnish
Connection: close
X-Cache: MISS

0105


disconnecting.
+++AT+QICLOSE%13%
41 41>

And everything looks to be working fine...

I'm powering the arduino by USB and 12V external power source (lightgrid). Can somebody help me please? I'm out of ideas...

I have tried another SIM card from a different operator but still the same result. Could it be that there is something wrong with the GSM module?

OK I have no idea why the code above won't work while it seems to work with everybody else. But the GPRS tool test code works:

I'm going to use that one as a basis for my project.

Your sketch works fine in my shield. Your problem may be caused by the condition that you introduced in gsmAccess.begin.

Change your gsmAccess.begin line to the following:

if((!PIN_OK) && gsmAccess.begin(PINNUMBER)==GSM_READY){

Thank you David for your reply. Even the original test scrip doesn't work for me so I don't think it has something to do with the modification I made. I clearly works in debug mode (true) and not in normal mode.

Ok people, I think I finally figured out the cause of my problem here. Ok maybe not the cause, but at least the solution...

I believe that the issue is caused by doing to much at the same time. Ok ok I'm just a beginner here but I've noticed that when I introduce a delay between
gsmAccess.begin(PINNUMBER)
and
gprsAccess.attachGPRS(apn, login, password)

it actually give me no problem. I use a delay of 1000ms but I suppose it can be less. The testGPRS script for examples works like a charm when I have to insert the apn, login and password by serial but when I hard code them in the script, then the arduino will fail to connect to the grid. I have no idea what the problem is here but I suggest you take a look at it. Tomorrow my arduino mega board will arrive. I'll test the gps shield on that without the delay and keep you informed.

For your information. I reported that several people have experienced the same problem and implemented the same solution to the arduino support. I've got this reply from them:

Federico_Vanzati, Jul 23 12:43 (CEST):
Thank you for reporting that.
We will do further test on this problem.
Kind,
Federico

This is quite true for most GSM module.
Once registered to the network, you definitely need to give the module a breather before trying to hook o the GPRS.

try for
char server[]=arduino.cc
char path[]= /asciilogo. txt

or

char server[]=arduino.cc
char path[]= /latest.txt

and not char path[]=/arduino.cc/latest.txt