SIM – AT commands for SIM presense and status

With Online AT Command Tester tool, you can get SIM status of the device.

SIM status and presense

First enable the extended error codes to get a verbose format,
AT+CMEE=2
OK

Now get the status of SIM presense,
AT+cpin?
+CME ERROR: SIM not inserted

Above AT command response indicates that SIM card is not present. Verify that SIM is inserted properly and check again,

AT+cpin?
+CPIN: READY
OK

When the SIM card is ready, above AT response will be received from the module.

Try this script included in AT Command Tester Tool.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Script- sim_lock.at

//Test SIM lock related AT commands with this script

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

//Get the status of SIM PIN

//Pin status can be,

//     READY -  This means  SIM PIN is already unlocked or lock has been disabled

//     SIM PIN – This means SIM PIN is locked and code is required

//     SIM PUK – Maximum number to retries to unlock has reached. PUK code is required from network provider to setup new PIN

//     These are other less common return values – PH_SIM PIN, PH_SM PUK, SIM PIN2, SIM PUK2

AT+CPIN?

 

//WAIT for 1 sec

WAIT=1

 

//First let us check if PIN lock feature is enabled using facility lock AT command

//”SC” is for SIM, 2 is query

AT+CLCK=”SC”,2

 

//WAIT for 2 sec

WAIT=2

 

//Set up the SIM PIN LOCK

// 1 is lock, “1234″ is the pin code

AT+CLCK=”SC”,1,”1234″

 

//WAIT for 2 sec

WAIT=2

 

//You need to reset the device for SIM PIN changes to take effect

AT+CFUN=1,1

 

//WAIT enough time for device to reset

WAIT=15

 

//Check SIM is ready

AT+CPIN?

 

//WAIT for 2 sec

WAIT=2

 

//Unlock SIM PIN

AT+CPIN=”1234″

 

//WAIT for 2 sec

WAIT=2

 

//You can confirm if PIN lock feature is enabled

AT+CLCK=”SC”,2

 

//Let us change the SIM PIN code

//1234 is current code, 4321 is new code

AT+CPWD=”SC”,”1234″,”4321″

 

//WAIT for 2 sec

WAIT=2

 

//You need to reset the device for SIM PIN changes to take effect

AT+CFUN=1,1

 

//WAIT enough time for device to reset

WAIT=15

 

//Check the CPIN status

AT+CPIN?

 

//WAIT for 2 sec

WAIT=2

 

//Unlock SIM PIN

AT+CPIN=”4321″

 

//WAIT for 2 sec

WAIT=2

 

//Confirm SIM is ready

AT+CPIN?

 

//Now let us clear SIM lock

//O is to unlock SIM

AT+CLCK=”SC”,0,”4321″,1

 

//You need to reset the device for SIM PIN changes to take effect

AT+CFUN=1,1

 

//WAIT enough time for device to reset

WAIT=15

 

//Check the CPIN status

AT+CPIN?

Response to above output script in AT Command Tester Tool.

AT+CPIN?

+CPIN: READY

 

OK

SIM is ready

 

AT+CLCK=”SC”,2

+CLCK: 0

 

OK

SIM Lock is not active

 

 

AT+CLCK=”SC”,1,”1234″

OK

 

AT+CFUN=1,1

OK

 

AT+CPIN?

+CPIN: SIM PIN

 

OK

SIM PIN is required

 

 

AT+CPIN=”1234″

OK

SIM PIN is successfully unlocked .

 

 

AT+CLCK=”SC”,2

+CLCK: 1

 

OK

SIM Lock is active

 

 

AT+CPWD=”SC”,”1234″,”4321″

OK

SIM PIN successfully changed

 

 

AT+CFUN=1,1

OK

 

AT+CPIN?

+CPIN: SIM PIN

 

OK

SIM PIN is required

 

AT+CPIN=”4321″

OK

SIM PIN is successfully unlocked .

 

 

AT+CPIN?

+CPIN: READY

 

OK

SIM is ready

 

AT+CLCK=”SC”,0,”4321″,1

OK

SIM lock is cleared

 

AT+CFUN=1,1

OK

 

AT+CPIN?

+CPIN: READY

 

OK

SIM is ready

Keywords: Module SIM, M2M SIM, GPRS SIM, 3G SIM, SIM through AT commands,