Arduino

Reference Language | Libraries | Comparison | Changes

GSM : GSMModem class

## getIMEI()

#### Description

Retrieves the modem's IMEI number. Call this after GSMModem.begin().

#### Syntax

modem.getIMEI()

#### Parameters

none

#### Returns

String : the modem's IMEI number

#### Example

// libraries
#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");
else
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("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()");
}
}
else
{
Serial.println("Error: Could not get IMEI");
}
// do nothing:
while(true);
}
[Get Code]

#### See Also

begin()
Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- About us
- Careers