I recently bought a GPRS shield from Seeed Studio but was having issues running the programs described in their documentation. Here is everything you need to know about my shield:
Documentation for GPRS Shield V2.0
Website to purchase GPRS Shield V2.0
I assumed that there was a connection problem. I used the following code to try to debug my SIM900 and its connections to the sim card and the cellular network:
#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(7,8);
void setup(){
gprsSerial.begin(19200); // GPRS shield baud rate
Serial.begin(19200);
delay(500);
}
void loop(){
if(Serial.available()) {
switch(Serial.read()) {
case '0': testSIM900(); break;
// AT OK
case '1': testSIMCARD(); break;
// +CPIN: READY
// +CREG: 0,1
case '2': testNETWORK(); break;
// +CGATT: 1
}
}
if(gprsSerial.available()) Serial.write(gprsSerial.read());
}
void testSIM900() {
gprsSerial.println("AT");
// AT OK
delay(100);
}
void testSIMCARD() {
gprsSerial.println("AT+CPIN?");
// +CPIN: READY
delay(100);
gprsSerial.println("AT+CREG?");
// +CREG: 0,1
delay(100);
}
void testNETWORK() {
gprsSerial.println("AT+CGATT?");
// +CGATT: 1
delay(100);
}
When I entered 0, 1, and 2 into the serial monitor, I got the following response:
AT
OK
AT+CPIN?
+CPIN: READY
OK
AT+CREG?
+CREG: 1,2
OK
+CREG: 0
+CGREG: 0
AT+CGATT?
+CGATT: 0
OK
What does this tell me about the current state of my shield, sim card, and network connection? Is there anything else I can do to isolate issues?