More Than a Hobby..

Arduino SIM900 Modem Test


Port open

Starting modem test...modem.begin() succeeded

Checking IMEI...Modem's IMEI: 


Resetting modem...Modem is functoning properly




 This example tests to see if the modem of the

 GSM shield is working correctly. You do not need

 a SIM card for this example.



 * GSM shield attached


 Created 12 Jun 2012

 by David del Peral

 modified 21 Nov 2012

 by Tom Igoe




 This sample code is part of the public domain




// libraries

#include <GSM.h>


// modem verification object

GSMModem modem;


// IMEI variable

String IMEI = "";


void setup()


  // initialize serial communications and wait for port to open:


  while (!Serial) {

    ; // wait for serial port to connect. Needed for Leonardo only



  // start modem test (reset and check response)

  Serial.print("Starting modem test...");

  if (modem.begin())

    Serial.println("modem.begin() succeeded");


    Serial.println("ERROR, no modem answer.");



void loop()


  // get modem IMEI

  Serial.print("Checking IMEI...");

  IMEI = modem.getIMEI();


  // check IMEI response

  if (IMEI != NULL)


    // show IMEI in serial monitor

    Serial.println("Modem's IMEI: " + IMEI);

    // reset modem to check booting:

    Serial.print("Resetting modem...");


    // get and check IMEI one more time

    if (modem.getIMEI() != NULL)


      Serial.println("Modem is functoning properly");




      Serial.println("Error: getIMEI() failed after modem.begin()");





    Serial.println("Error: Could not get IMEI");


  // do nothing:

  while (true);