As I don't want to stack the shield over the mega 2560 board, I try to connect only the pins that used for GSM communication. Here are my connection:
Pin 3 on Mega <==> Pin GSM Rx on Shield
Pin 10 on Mega <==> Pin GSM Tx on Shield
Pin 4 on Mega <==> Pin 4 on Shield
Pin 5V on Mega <==> Pin Vin on Shield
Pin GRD on Mega <==> Pin GRD on Shield
Code I used is from the Examples library, GsmScanNetworks:
#include <GSM.h>
// PIN Number
#define PINNUMBER "8888"
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter to enable debugging
GSMScanner scannerNetworks;
GSMModem modemTest;
// Save data variables
String IMEI = "";
// serial monitor result messages
String errortext = "ERROR";
void setup()
{
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("GSM networks scanner");
scannerNetworks.begin();
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
// get modem parameters
// IMEI, modem unique identifier
Serial.print("Modem IMEI: ");
IMEI = modemTest.getIMEI();
IMEI.replace("\n","");
if(IMEI != NULL)
Serial.println(IMEI);
}
void loop()
{
// scan for existing networks, displays a list of networks
Serial.println("Scanning available networks. May take some seconds.");
Serial.println(scannerNetworks.readNetworks());
// currently connected carrier
Serial.print("Current carrier: ");
Serial.println(scannerNetworks.getCurrentCarrier());
// returns strength and ber
// signal strength in 0-31 scale. 31 means power > 51dBm
// BER is the Bit Error Rate. 0-7 scale. 99=not detectable
Serial.print("Signal Strength: ");
Serial.print(scannerNetworks.getSignalStrength());
Serial.println(" [0-31]");
}
Questions:
- After opening the serial port, only a line "GSM network scanner" is read. Seems that the program is stuck on
gsmAccess.begin(PINNUMBER)
, how shall I fix that? - Is it a must that I shall supply 5V 2A power to the shield seperately in order for the shield to work? (with connection mentioned above, the ON led light on the shield does turns on with an orange light)
- For the PINNUMBER defined in the program, my SIM has default PIN 8888. I checked with a mobile phone that the SIM card does work. But my phone shows that the SIM card is not locked with PIN. So shall I define the PIN as 8888 for ''?
EDIT:
Note for using GSM shield with Mega
* And yes! The shield did work when stacked! (Orginally I don't want to bend pin 2...but...unnh...stacking and bending out pin 2 did work)
* Tried the examples "GSMScanNetwork" and "SendSMS", works fine. But for "GsmWebServer", an IP address is shown, but when I enter the IP address on my browser, chrome/ie says they cannot find the IP address.....Any clues?
* And does the status LED on the GSM board have anything to do with power? It goes on and off and on and off.....
* For question 1 & 3, PINNUMBER is set to ''. Worked fine.