carrascoacd / ArduinoSIM800L

Arduino HTTP & FTP client for SIM800L/SIM800 boards to perform GET and POST requests to a JSON API as well as FTP uploads.
159 stars 58 forks source link

Get IMEI of my module #34

Closed maxkraft7 closed 4 years ago

maxkraft7 commented 4 years ago

Is there any quick way on how I can retrieve my IMEI in this library?

carrascoacd commented 4 years ago

According to the doc you can use AT+GSN.

The library does not implement such feature but you can do something like this:

#include <Sim800.h>

#define READ_IMEI "AT+GSN\r\n"

#define RST_PIN 8
#define RX_PIN 10
#define TX_PIN 9

...

SIM800 sim800(9600, RX_PIN, TX_PIN, RST_PIN);
sim800.sendCmd(READ_IMEI);

char buffer[32];
if (sim800.readBuffer(buffer, sizeof(buffer)) == TRUE)
{
  // Do something with buffer
}