Recently I battled to get the Seeed Studio GPRS Shield 1.4 and Arduino Mega 2560 to talk to each other. I eventually discovered that they are not actually compatible when stacked (without some ugly pin jumping, and even then, not really compatible because the Software Serial can’t seem to really handle 19200 baud rates).
So here’s how to treat it as a breakout board. (my notes in blue):
This only requires 5 connections. The blue labels represent the Arduino pins to connect to.
- 5v and GND – These should be pretty obvious.
- Pin 9 – This pin is used to turn the SIM900 on and off.
- Pin 18 and 19 – These are the HW serial pins
Finally note the position of the jumpers (HW Serial) and the position of the Power Switch (Internal).
Which, when connected up should look something like this:
Then finally you can load up the following sketch to get serial access to the GPRS modem via the Arduino’s serial monitor.
#include <SoftwareSerial.h> #define terminator 10 // DEC value for a LF(line feed) to skip while loop /* SETUP See https://arbitraryuser.com/2013/04/07/seeed-studio-gprs-shield-and-arduino-mega-2560/ This code is partially "borrowed" from idS2001 at http://www.seeedstudio.com/forum/viewtopic.php?p=12939#p12939 */ String IncDataSerial = ""; void setup() { delay(1000); Serial.begin(19200); Serial1.begin(19200); // Automatically power up the SIM900. pinMode(9, OUTPUT); digitalWrite(9,LOW); delay(1000); digitalWrite(9,HIGH); delay(2500); digitalWrite(9,LOW); delay(3500); // End of SIM900 power up. } void loop() { if (Serial1.available()>0) // if date is comming from softwareserial port ==> data is comming from gprs shield { boolean getLF = false; while(Serial1.available()>0 && !getLF) // reading data into string if activity is on port and getLF is false ==> no LF have been send { char buffer=Serial1.read(); // writing data into char IncDataSerial += buffer; if (buffer == terminator) { getLF = true; } } Serial.print(IncDataSerial); // send string ( char array ) to hardware serial Serial.print("\r"); // send a CR because it is missing IncDataSerial = ""; } if (Serial.available()>0) // if data is available on hardwareserial port ==> data is comming from PC or notebook Serial1.write(Serial.read()); // write it to the GPRS shield }
In Serial Monitor (or similar app) you will then see it start to talk to you after the initial ~5 second startup delay.
RDY +CFUN: 1 +CPIN: READY Call Ready AT OK AT+CSQ +CSQ:18,0 OK