Hi to everyone,
Sim800L is attached to ESP32, i'm running an On/Off, timed relay
I wish to know how to capture IMEI from SIM800L with AT+GSN command .
Response from command i wish to compare with a value from sketch.
Idea is : someone not to swap GSM modules between them, and sketch to work anymore.
I'm using Software Serial library.
Regards,
Rivelino
AT+CGSN queries the serial number, not the IMEI.
AT+CIMI us the command you’re looking for.
AT+CGSN - query serial number of International Mobile Equipment Identifier (Imei).
That i need.
To bound GSM module to the software.
Not to SIM card to the software . Can be any SIM card.
Go for it...
Sorry about that, Ive been playing with these for too long !
The command is straightforward...
Send AT+CGSN
- then receive the IMEI number, followed by OK
That’s it...
The command already know how to send it.
This is the solution:
Result :
Printez comanda imei :
imei_citit : AT+CGSN866782042363461OK
imei_citit2 : 866782042363461
void imei() {
Serial.println ("Printez comanda imei : "); //Printing some info
mySerial.println("AT+CGSN"); //Sending command
delay (200);
while (mySerial.available() > 0)
{
imei_citit += mySerial.readStringUntil('\r\n');
}
Serial.print ("imei_citit : ");
Serial.println (imei_citit); //Printing first raw reading
int x = imei_citit.indexOf(String("AT+CGSN"))+7 ;
int y = imei_citit.lastIndexOf(String("OK"));
Serial.print ("imei_citit2 : ");
Serial.println(imei_citit.substring(x, y)); //Printing only IMEI reading
imei_citit=""; //Reset imei storage
}