Go Down

Topic: Arduino GSM Shield + SIM Telefonica not working (Read 562 times) previous topic - next topic

qds3

Hi,
I have recently adquired a GSM SHIELD and plugged it into an Arduino UNO and I'm having some issues with the example sketches to make it work. When I run to following sketch:

Code: [Select]

#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
// With a Movilforum SIM:
// It can be "bluevia.movistar.es" or "sm2ms.movilforum.es"
#define GPRS_APN       "sm2ms.movilforum.es" // replace your GPRS APN
#define GPRS_LOGIN     ""    // replace with your GPRS login
#define GPRS_PASSWORD  "" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess(true);

// URL, path & port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/latest.txt";
int port = 80; // port 80 is the default for HTTP

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);

  Serial.println("Starting Arduino web client.");
  // connection state
  boolean notConnected = true;
 
  // After starting the modem with GSM.begin()
  // attach the shield to the GPRS network with the APN, login and password
  while(notConnected)
  {
    Serial.println("Dentro while");
    if((gsmAccess.begin(PINNUMBER,false)==GSM_READY))
    {
      Serial.println("PIN ok");
      if((gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      {
        Serial.println("GPRS ok");
        notConnected = false;
      }
      else
        Serial.println("GPRS mal");
    }
    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(;;)
      ;
  }
}


I can't make it connect with the URL and receive the data. In fact, sometimes the GSM Shield gets stuck in the following line:
Code: [Select]

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


How can I solve this issue? I try other sketches but it's always the same. The shield is not able to connect.

I attach the output from the debug mode for the sketch above:
Code: [Select]

Starting Arduino web client.
Dentro while
AT%13%
0 37>AT%13%%13%%10%OK%13%%10%%13%%10%+CFUN: 1%13%%10%%13%%10%+CPIN: READY%13%%10%
AT+CGREG?%13%
37 82>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%%13%%10%Call Ready%13%%10%
AT+CGREG?%13%
82 113>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
113 16>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
16 47>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
47 78>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
78 109>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
109 12>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
12 43>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
43 74>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%Not connected
Dentro while
AT%13%
84 7>AT%13%%13%%10%OK%13%%10%%13%%10%+CFUN: 1%13%%10%%13%%10%+CPIN: READY%13%%10%%13%%10%Call Ready%13%%10%
AT+CGREG?%13%
7 38>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
38 69>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
69 100>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
100 3>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
3 34>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
34 65>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
65 96>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
96 127>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
127 30>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
30 61>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
61 92>AT+CGREG?%13%%13%%10%+CGREG: 0,2%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 26>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
26 57>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
57 88>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
88 119>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
119 8>AT+IFC=1,1%13%%13%%10%OK%13%%10%
AT+CMGF=1%13%
8 26>%19%%17%AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
26 42>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
42 53>ATE0%13%%13%%10%OK%13%%10%
AT+COLP=1%13%
53 59>%13%%10%OK%13%%10%
PIN ok
AT+CGATT=1%13%
59 65>%13%%10%OK%13%%10%
AT+QIFGCNT=0%13%
65 71>%13%%10%OK%13%%10%
AT+QICSGP=1,"sm2ms.movilforum.es","",""%13%
71 77>%13%%10%OK%13%%10%
AT+QIMUX=0%13%
77 83>%13%%10%OK%13%%10%
AT+QIMODE=1%13%
83 89>%13%%10%OK%13%%10%
AT+QINDI=1%13%
89 95>%13%%10%OK%13%%10%
AT+QIREGAPP%13%
95 101>%13%%10%OK%13%%10%
AT+QIACT%13%
101 107>%13%%10%OK%13%%10%
GPRS ok
connecting...
AT+QIDNSIP=1%13%
107 113>%13%%10%OK%13%%10%
AT+QIOPEN="TCP","arduino.cc",80%13%
113 119>%13%%10%OK%13%%10%
connection failed

OK

disconnecting.
+++AT+QICLOSE%13%


Thank you and sorry for my bad english

Capt_Rhizz

1) Referrence to your error

Check this out. Not sure if your familiar with AT language, but it has to to with your access to the the GSM network. I think... MAybe someone could verify? :smiley-draw:

2) Check you have the right plan set up and make sure you have a compatible GSM sim card.

3) Another ideal said thing to have is a 5v external power supply. 200mA to 300mA.

4)
You can use AT commands directly by using this code or thread. You need the manual tho to follow along. ** double check you pin configuration from the GSM to the Arduino TX and RX ports. Also in the code**

 AT commands DIRECTLY CODE

5) PIN config referrence

Hope that helps! Keep checkin. It is always something simple.
Rhiz

qds3

Thanks for your help. Unfortunately I had already tried the things you comment with no result. I'll keep checking unless someone could find the answer before.

qds3

I solved it! Here is the new code that works for me:

Code: [Select]

/*
  Web client
 
 This sketch connects to a website through a GSM shield. Specifically,
 this example downloads the URL "http://arduino.cc/" and prints it
 to the Serial monitor.
 
 Circuit:
 * GSM shield attached to an Arduino
 * SIM card with a data plan
 
 created 8 Mar 2012
 by Tom Igoe
 
 http://arduino.cc/en/Tutorial/GSMExamplesWebClient
 
 */

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
// With a Movilforum SIM:
// It can be "bluevia.movistar.es" or "sm2ms.movilforum.es"
#define GPRS_APN       "sm2ms.movilforum.es" // replace your GPRS APN
#define GPRS_LOGIN     ""    // replace with your GPRS login
#define GPRS_PASSWORD  "" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess(true);

// URL, path & port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/";
int port = 80; // port 80 is the default for HTTP

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);

  Serial.println("Starting Arduino web client.");
  // connection state
 
 
  // After starting the modem with GSM.begin()
  // attach the shield to the GPRS network with the APN, login and password
  Serial.println(F("GSM start"));

  unsigned long myTimeout = 60000; // YOUR LIMIT IN MILLISECONDS

gsmAccess.begin(PINNUMBER,true,false); //Use async mode and requires that GSM debug mode has been set on GSM object creation
boolean notConnected = true;
unsigned long timeConnect = millis();
// connection state
while(notConnected && (millis()-timeConnect < myTimeout))
{
int ok = 0;
gsmAccess.ready(); //Call this if debugging is on. Otherwise we will never reach GSM_READY...?!?
delay(1000); //might not call ready too often.??? See GSM3ShieldV1AccessProvider.cpp, GSM3ShieldV1AccessProvider::begin
ok = gsmAccess.getStatus();
if (ok != GSM_READY && ok != GPRS_READY){
Serial.print(F("GSM status: "));
Serial.println(ok);
continue;
}
if(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY) {
notConnected = false;
}
}

  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(;;)
      ;
  }
}

Go Up