How to change/create SIM PIN using AT commands when the SIM card has no PIN?
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=?
).