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:
#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:
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:
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