How to use the GSM shield with Arduino Leonardo and Arduino Mega

How to use the GSM shield with Arduino Leonardo and Arduino Mega

The GSM shield communicates with an attached Arduino through the Software Serial library. By default, communication between the modem and Arduino happens on digital pins 2 and 3. On the Uno this works without modification, but to use the Leonardo or Mega boards, some slight changes are required.
The GSM_TX pin, pin 2 on the shield, sends information to the Arduino. The Arduino relies on an interrupt to know when to read the information on this pin. The Leonardo and Mega do not have interrupt capabilities on pin 2.
You do not need to change any code to program the shield for use with the Mega or Leonardo, the library will change the Arduino's RX pin automatically depending on the board selected in the "Tools" menu of the IDE.

Arduino Leonardo

The GSM library uses digital pin 8 to communicate with the Leonardo. On the GSM shield, connect a jumper wire between digital pins 2 and 8.
Bend the male header attached to pin 2 on the GSM shield to the side so it does not connect with the Leonardo.

 

Arduino Mega

The GSM library uses digital pin 10 to communicate with the Leonardo. On the GSM shield, connect a jumper wire between digital pins 2 and 10.
Bend the male header attached to pin 2 on the GSM shield to the side so it does not connect with the Mega.

 

Using alternate pins with the library

If you prefer to use a different interrupt pin for communication, refer to the Software Serial library reference page to see valid pin choices. You will need to change the __RXPIN__ definition in the GSM3SoftwareSerial.cpp file, located in the GSM library folder.