Tutorial.GSMToolsTestModem History

Hide minor edits - Show changes to markup

March 11, 2013, at 10:31 AM by Scott Fitzgerald -
Changed lines 185-188 from:
to:
February 04, 2013, at 08:22 AM by Scott Fitzgerald -
Changed lines 5-6 from:

This sketch gives you diagnostic information about the modem on the GSM shield.

to:

This sketch tests the modem on the GSM shield to see if it is working correctly. You do not need a SIM card for this example.

Deleted line 10:
  • SIM card with a data connection
Changed lines 26-31 from:

SIM cards may have a PIN number that enables their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank :

#define PINNUMBER ""

Define a number of constants that contain information about the GPRS network you're going to connect to. You'll need the Access Point Name (APN), login, and password. To obtain this information, contact your network provider for the most up to date information. This page has some information about various carrier settings, but it may not be current.

to:

Create an instance of the GSMModem class:

GSMModem modem;

Create a variable to hold the IMEI number of the modem

Changed lines 33-35 from:
  1. define GPRS_APN "GPRS_APN"
  2. define GPRS_LOGIN "login"
  3. define GPRS_PASSWORD "password"
to:

String IMEI = "";

Changed lines 36-37 from:

Initialize instances of the classes you're going to use. You're going to need the GSM, GPRS, GSMServer, and GSMClient classes. When you instantiate the GSMServer class, you'll need to tell it which port to listen for incoming connections. Port 80 is the default port for HTTP requests.

to:

In setup, open a serial connection to the computer. After opening the connection, send a message indicating the sketch has started.

Changed lines 39-42 from:

GSMClient client; GPRS gprs; GSM gsmAccess; GSMServer server(80);

to:

void setup(){

  Serial.begin(9600); 
  Serial.print("Starting modem test...");
Changed lines 44-45 from:

Create some variables to set a timeout period, flag incoming client messages, and a buffer to read incoming bytes. to hold the server, path, and port you wish to connect to.

to:

Call modem.begin() to start the modem. Send a status message depending on the outcome, and end setup().

Changed lines 47-49 from:

char server[] = "arduino.cc"; char path[] = "/"; int port = 80;

to:
  if(modem.begin()) 
    Serial.println("modem.begin() succeeded");
  else
    Serial.println("ERROR, no modem answer.");

}

Changed lines 54-55 from:

In setup, open a serial connection to the computer. After opening the connection, send a message indicating the sketch has started.

to:

Inside loop, use modem.getIMEI() to return the IMEI number of the modem. This number is unique to your GSM shield.

Changed lines 58-60 from:

void setup(){

  Serial.begin(9600); 
  Serial.println("Starting Arduino web client.");
to:

void loop() {

  // get modem IMEI
  Serial.print("Checking IMEI...");
  IMEI = modem.getIMEI();
Changed lines 65-66 from:

Create a local variable to track the connection status. You'll use this to keep the sketch from starting until the SIM is connected to the network :

to:

If there is a valid response from getIMEI(), print it to the serial monitor and reset the modem with modem.begin().

Changed lines 68-74 from:
  boolean notConnected = true;
to:
 if(IMEI != NULL)
  {
    // show IMEI in serial monitor
    Serial.println("Modem's IMEI: " + IMEI);
    // reset modem to check booting:
    Serial.print("Reseting modem...");
    modem.begin();
Changed lines 77-80 from:

Connect to the network by calling gsmAccess.begin(). It takes the SIM card's PIN as an argument. You'll also connect to the GPRS network using gprs.attachGPRS(). This requires the APN, login, and password you declared earlier. By placing this inside a while() loop, you can continually check the status of the connection and wait for them to both become true before proceeding.

When the modem does connect nd had attached itself to the GPRS network, gsmAccess() will return GSM_READY. Use this as a flag to set the notConnected variable to true or false. Once connected, the remainder of setup will run.

to:

Once reset, check the IMEI again. If it is a valid return again, the modem is functioning as expected.

Changed lines 80-85 from:
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
to:
   if(modem.getIMEI() != NULL)
Changed lines 82-83 from:
      Serial.println("Not connected");
      delay(1000);
to:
      Serial.println("Modem is functoning properly");
Deleted line 83:
  }
Changed lines 86-87 from:

Attempt to connect to the server using client.connect(). connect() requires two arguments, the server and port. Once connected to the server, make a HTTP request by calling client.print(). A typical web request looks like "GET pathname HTTP/1.0". print will send the message, just as a browser would.

to:

If, after resetting the modem, there is not a valid return from getIMEI(), report an error

Changed lines 89-99 from:
  if (client.connect(server, port))
to:
Changed lines 101-106 from:
    Serial.println("connected");
    client.print("GET ");
    client.print(path);
    client.println(" HTTP/1.0");
    client.println();
  } 
to:
    Serial.println("Error: Could not get IMEI");
  }
  // do nothing:
  while(true);

}

Changed lines 108-109 from:

If the connection to the server failed, make a note of it in the serial monitor, and close up setup.

to:
Added lines 112-142:

/*

 This example test if your modem is working correctly.

 Circuit:
 * GSM shield attached (using digital pins 2, 3, and 7)

 Created 12 Jun 2012
 by David del Peral
 modified 21 Nov 2012
 by Tom Igoe
 */

// libraries

  1. include <GSM.h>

// modem verification object GSMModem modem;

// IMEI variable String IMEI = "";

void setup() {

  // initialize serial communications
  Serial.begin(9600);

  // start modem test (reset and check response)
  Serial.print("Starting modem test...");
  if(modem.begin()) 
    Serial.println("modem.begin() succeeded");
Changed lines 144-146 from:
  {
    Serial.println("connection failed");
  }
to:
    Serial.println("ERROR, no modem answer.");
Changed lines 146-151 from:
to:

void loop() {

  // get modem IMEI
  Serial.print("Checking IMEI...");
  IMEI = modem.getIMEI();

  // check IMEI response
  if(IMEI != NULL)
Changed lines 156-157 from:
    char c = client.read();
    Serial.print(c);
to:
    // show IMEI in serial monitor
    Serial.println("Modem's IMEI: " + IMEI);
    // reset modem to check booting:
    Serial.print("Reseting modem...");
    modem.begin();
    // get and check IMEI one more time
    if(modem.getIMEI() != NULL)
    {
      Serial.println("Modem is functoning properly");
    }
    else
    {
      Serial.println("Error: getIMEI() failed after modem.begin()");
    }
Changed lines 171-176 from:
to:
  else
Changed lines 173-179 from:
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for(;;)
      ;
to:
    Serial.println("Error: Could not get IMEI");
Added lines 175-176:
  // do nothing:
  while(true);
Added line 178:
Deleted lines 179-365:
February 03, 2013, at 07:24 PM by Scott Fitzgerald -
Changed lines 1-6 from:

Examples > Make Voice Call

Using the GSM Shield to Make Calls

This example shows how to use the GSM Shield and Library to make voice calls. Please click here for more information on the GSM library.

to:

Examples > GSM library

GSM Test Modem

This sketch gives you diagnostic information about the modem on the GSM shield.

Changed line 11 from:
  • SIM card
to:
  • SIM card with a data connection
Changed lines 23-25 from:

The code below is configured for use with a GSM/GPRS shield. In the variable declaration area, you need to instantiate both the GSM and GSMVoiceCall classes. Inside setup(), call GSM.begin(), with the PINNUMBER of your SIM card as parameter. GSM.begin() will return whether the shield managed to connect to the GSM network or not.

In the loop(), the input from the Serial Monitor is used to tell the GSM Shield a phone number to call to. The code waits until the call is over before performing any other actions.

to:
Changed lines 141-322 from:
to:
Changed line 328 from:
to:
November 16, 2012, at 07:58 PM by Scott Fitzgerald -
Added lines 1-34:

Share