Hi,
I have a project with a goal to reliably upload data from multiple xbees to a server. For the last week I've run into issues with the GSM connection becoming unresponsive and the Arduino MEGA2560 hanging infinitely. During this time I have rewritten my method of connecting to the network multiple times. The most reliable way so far ran for 36 hours, uploading dummy data every 10 minutes. This was accomplished using this code (personal details have been omitted):
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// APN data
#define GPRS_APN "XXX" //GPRS APN
#define GPRS_LOGIN "XXX" //GPRS login
#define GPRS_PASSWORD "XXX" //GPRS password
// Initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess(true);
//Server details
char server[] = "XX.XXX.XXX.XXX";
int port = XXXX;
int trynr = 0;
int oknr = 0;
void setup(){
Serial.begin(9600); //Start serial connection
Serial.println("Starting up...");
}
void loop(){
trynr++;
Serial.println("Connecting to GSM network...");
if(gsmAccess.begin(PINNUMBER)==GSM_READY){
Serial.println("PIN OK");
delay(1000);
if(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY){
Serial.println("GPRS OK");
delay(1000);
if(client.connect(server, port)){
oknr++;
client.print("Test ");
client.print(oknr);
client.print("/");
client.print(trynr);
client.flush();
client.stop();
delay(60000);
}
}
}
}
I don't have the debug log on hand at the moment, but the script is running with Serial Monitor attached right now. I will add the failing debug log as soon as I get them.
First hitch:
Connecting to GSM network...
AT%13%
89 103>%13%%10%Call Ready%13%%10%
Connecting to GSM network...
AT%13%
And it just hangs on this.
Before this, I had a prototype that normally ran between 8-20 hours, with the occasional hangs much sooner. As this code is a lot more messy, I uploaded it to codepad: C code - 258 lines - codepad
When failing, I either get stuck on AT%13% and it never moves forward or I start getting a really long line of %240%-s. Sometimes I start connecting and as soon as it gets a connection with GPRS it starts connecting again. I don't have antennas on hand to post a full debug report for this one yet, but I can tomorrow.
I just ran a test with this code as well and I got stuck on this after one successful upload:
Connecting to GSM network...
GSM Access begin
AT%13%
The Arduino MEGA2560 and the Arduino GSM Shield have been running from a 2A power supply since day one.