How to change/create SIM PIN using AT commands when the SIM card has no PIN?

7.2k Views Asked by At

I'm using a SIM868 module and I was using my usual SIM card with no problem, but now I have bought a new SIM card and has no pin. I need to add a PIN code in order to have more security.

I have checked that it has no PIN enabled using this command: AT+CPIN?.

and the answer was: +CPIN: READY.

I have searched how to change it in the SIMCOM's AT commands manual and I have found 2 options:

  1. AT+CPIN=<pin>[,<new pin>]
  2. AT+CPWD=<fac>,<oldpwd>,<newpwd>

I have tried both of them, but in the first one I can't insert the actual PIN, because there is no actual PIN. And in the second one I have tried different commands due, in the description of the AT command, sais "If an old password has not yet been set, oldpwd is not to enter". None of this ones has worked (guess that 1234 is the new PIN that I want to use)

1) AT+CLCK=“SC”,"1234"
2) AT+CLCK=“SC”,,"1234" 
3) AT+CLCK=“SC”,“”,"1234" 

The answer to that 3 cases was the same: ERROR.

(If someone is going to suggest that I can change or try the SIM card with a mobile phone I can't do it because this new SIM card is a miniSIM card and all my phones use nanoSIM or microSIM).

Any suggestions?

1

There are 1 best solutions below

1
On BEST ANSWER

TL;DR

In order to set the PIN code 1234 you need to provide the following command:

AT+CLCK="SC",1,"1234"

Explanation

As you correctly wrote, AT+CLCK is the correct command to enable/disable any module's facility, included "SIM PIN request". But your syntax is wrong.

According to ETSI specification, the correct syntax is

AT+CLCK=<fac>,<mode>[,<passwd>[,<class>]]

Where:

  • <fac> (string) is the facility to be locked/unlocked ("SC" in case of "SIM (PIN request)").
  • <mode> (integer) is the operation to be done on the facility. This parameter was missing in your attempts.
    • 0 to unlock
    • 1 to lock
    • 2 to query lock status
  • <passwd> is the password set with +CPWD (in your case it should be the PIN code but it is probably not required since it is not set).
  • <class> is a sum of integers each representing a class of information. You don't need it for your task.

Note: in development phase, when "playing" with AT commands, I suggest enabling verbose errors mode providing either AT+CMEE=1 or AT+CMEE=2 according to what your device do support (check it by providing test command AT+CMEE=?).