I'm working with a GPRS module (the same as in the Arduino GSMShield). In some cases the PUK code is requested, and the PIN is thus locked. For this I wrote some code (which can be seen under "Software"). This code is based on the documentation of "GSM PIN Management". The only problem is that the module is telling us that both the PIN & PUK code is locked. The tutorials, however, does not provide an example how we should resolve this issue from the Arduino itself.

EDIT: When the SIM card is inserted in a smartphone. The PUK code is requested. When the PUK code is provided (and a new PIN) the SIM card is back to normal. But adding the PUK code via the GSM lib. doesn't really work, in contrast to using a smartphone to unlock the PIN code.


  • Does anybody have an idea how to resolve this issue? And if it can be done?


  • Atmega328p
  • Quectel M95 (as GPRS module)


int pin_query = PINManager.isPIN();
Serial.print(F("Pin Query is: ")); //output: -2
if(pin_query == -1)
  #ifdef DEBUG
    Serial.println(F("PUK is requested"));

    PINManager.setPINUsed(true); // I also think this must by "false". Both things were tested, none of them worked.

  • If you enter the wrong PUK code 10 times or more, then you will need a new SIM card.
    – Gerben
    Oct 28, 2016 at 13:28
  • That's not the case. Because when the SIM is inserted in a smartphone/gsm, the PUK is requested. When adding the PUK code and a new PIN code, the SIM works fine. See the EDIT in the post.
    – gillesC
    Oct 28, 2016 at 14:22

1 Answer 1


I've resolved the issue by using AT commands instead of the GSM library provided through Arduino.

    Serial.println(F("PUK is requested, entering it now"));
    String cmd = "AT+CPIN=\"";

This code checks if the PUK code is requested, this is the case when the pin_query is -1 or -2 (see question). When the PUK code is requested the new PIN (which is still the same pin as the old one) is given in combination with the PUK code. The AT commands were found in this manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.