Hello,
Is there a way to identify the phone number associated with a SIM so it can be printed to the serial monitor? I have found references to identify GSM Modem's IMEI but not the phone number of SIM. Thanks in advance for any assistance
Hello,
Is there a way to identify the phone number associated with a SIM so it can be printed to the serial monitor? I have found references to identify GSM Modem's IMEI but not the phone number of SIM. Thanks in advance for any assistance
Look up the +CNUM command:
AT+CNUM?read subscriber MSISDN
Thanks gardner! I searched the suggested command on this forum and found a helpful sketch posted by butyouyes
in response to a post Re: Direct AT Commands to shield (for getting time) Here is the sketch. Appreciate the help!
/* This Sketch is to retrieve the MSISDN of the SIM using AT commands */
#include <GSM.h>
GSM gsmAccess(false);
char myNumber[20];
int timeout = 5000; // 5 seconds
void setup()
{
Serial.begin(9600);
boolean notConnected = true;
Serial.println("Connecting to the GSM network");
while(notConnected){
if(gsmAccess.begin() == GSM_READY) // Note: I do not require PIN #
notConnected = false;
else {
Serial.println("Not connected, trying again");
delay(1000);
}
}
Serial.println("Connected");
theGSM3ShieldV1ModemCore.println("AT+CNUM"); // AT Command to retrieve a MSISDN
int start = millis();
while((millis() - start) < timeout && !theGSM3ShieldV1ModemCore.theBuffer().extractSubstring("+CNUM: \"\",\"", "\"", myNumber, 20)){
}
Serial.print("My Telephone number: ");
Serial.println(myNumber);
}
void loop()
{
}