SIM800 & SIM900 SIM card PIN unlock

As this is a new hardware supported by Blynk, I decided to start a new topic, and ask first question here:
What I see, there seems to be support in TinyGSM lib for sim card PIN handling, but being impatient, I did not dug into the library code to find out, how to handle it while initializing Blynk connection. As I do have one SIM card where PIN CANNOT be disabled (a crappy operator - Orange PL) , I wish I can pass pin code to th hardware. Now the question is HOW?
By the way: A GREAT THANK YOU for introducing GSM support!!

Just call simUnlock after modem restart, like this:

  modem.restart();

  modem.simUnlock("1234");

Please note that we’re not responsible it this somehow locks/bricks your card forever :slight_smile:

1 Like

Also, I edited the topic - it was too generic. it’s better for us to have different topics for different problems.
Did my hint help in your case?

Thank You! Will check that later, but I take Your word for it… So I guess it is SOLVED.

There is always PUK, which entered incorrectly (if I remember) 10 times locks then SIM permanently. Also even IF s*** happens, they WILL change the SIM (sometimes free of charge - if You are able to justify it well enough)

Sure, OK for me!

1 Like

I’m excited too, I’m using cheap sim800l.

I’m Indonesian, few seconds ago I tried to test Arduino Uno with sim800l module just lyk aliexpress’s (red color), Serial monitor succeed connect to network, but while connecting to gprs it didn’t. I tried with 2 type APN config of my operator (Three). Honestly I want make that thing connect via cheap gsm module. But it is not easy lyk via Ethernet or ESP8266 Module

I will be able to check it today (it’s 9:30 in the morning), but in the meantime I suggest you try to open serial monitor (or other terminal) and try with regular at+ to do something requiring Internet conn. I have one example to send an email, can post it here or elsewhere. Examples are also in AT command reference manual.

@vshymanskyy
Uh, there is some error! Or something is screwed with my setup? The previous setup, with “prerelease” version compiled without error, so? What am I missing?

EDIT: And the error is gone, when I replace “new” TinyGsm library (from package 0.4.1) with the “older” one (received from You). But than again: OLDER does not supports PIN handling

LOG says:
no matching function for call to 'BlynkSIM::begin(char [33], TinyGsm&, char [9], char [1], char [1])'

Sketch: Almost default BlynkClient,

#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include <SimpleTimer.h>

char auth[] = "##copied#and#pasted";
char apn[]  = "internet";
char user[] = "";
char pass[] = "";

#define SerialAT Serial

TinyGsm modem(SerialAT);
TinyGsmClient client(modem);
SimpleTimer timer1;

void readADC() {
  int ADC0 = analogRead(A0);
  Blynk.virtualWrite(V1, ADC0);
}

void setup()
{
  // Set GSM module baud rate
  SerialAT.begin(115200);
  delay(3000);
  modem.restart();
  modem.simUnlock("1111");
  delay(2000);

  Blynk.begin(auth, modem, apn, user, pass);
  timer1.setInterval(1000L, readADC);
}

void loop()
{
  Blynk.run();
  timer1.run();
}

just get latest release zip from github, the one that includes 6 libraries.

1 Like

Strange (?) after upgrading Blynk lib from within Arduino (Library rep) my “project” (a test one, but what? Isn’t it?) compiled without errors. Will let you know whether it works… and how

First shot:no joy… at least the card seems to unlock correctly - good. But no conn with network, if I understand logged traffic:

AT+CFUN=0
AT+CFUN=1,1
AT
AT&FZE0
AT+CPIN?
AT+CPIN=1111
AT
AT&FZE0
AT+CPIN?
AT+CPIN?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+COPS?
AT+CIPSHUT
AT+CIPMUX=1
AT+CIPQSEND=1
AT+CIPRXGET=1
AT+CSTT="internet","",""
AT
AT+CFUN=0
AT+CFUN=1,1
AT
AT&FZE0
AT+CPIN?
AT+CPIN=1111
AT
AT&FZE0
AT+CPIN?
AT+CPIN?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+COPS?
AT+CIPSHUT
AT+CIPMUX=1
AT+CIPQSEND=1
AT+CIPRXGET=1
AT+CSTT="internet","",""
AT
AT+CFUN=0
AT+CFUN=1,1
AT
AT&FZE0
AT+CPIN?
AT+CPIN=1111
AT
AT&FZE0
AT+CPIN?
AT+CPIN?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+COPS?
AT+CIPSHUT
AT+CIPMUX=1
AT+CIPQSEND=1
AT+CIPRXGET=1
AT+CSTT="internet","",""

Another SIM (no PIN Lock):

AT
AT+CFUN=0
AT+CFUN=1,1
AT
AT&FZE0
AT+CPIN?
AT
AT&FZE0
AT+CPIN?
AT+CPIN?
AT+CREG?
AT+COPS?
AT+CIPSHUT
AT+CIPMUX=1
AT+CIPQSEND=1
AT+CIPRXGET=1
AT+CSTT="internet","",""
AT
AT+CFUN=0
AT+CFUN=1,1
AT
AT&FZE0
AT+CPIN?
AT
AT&FZE0
AT+CPIN?
AT+CPIN?
AT+CREG?
AT+COPS?
AT+CIPSHUT
AT+CIPMUX=1
AT+CIPQSEND=1
AT+CIPRXGET=1
AT+CSTT="internet","",""

After the last line it hangs/waits for something… Don’t know it yet… Will check later, if I’m able to run my “default” manual example again (made more than a year ago with “pure” AT code for sending an email…)

@vshymanskyy: Well, after some investigation, I’ve found, that your lib tries to establish Internet connection with APN (the AT+CSTT=...) before my modem is attached to GPRS (AT+CGATT? returns 0 - this one I was able to put into your lib just to check what is going on). Because Lib doesn’t checks this one (and accordingly misses to set CGATT to 1), it ALMOST always ends with error after AT+CSTT=. I’ve found your note in GprsConnect() regarding CGATT, but level of coding in Lib is a bit out of my skills (at least without investing many hours in it) . When are you planning to implement AT+CGATT? and AT+CGATT=1 ?

One more thing: I had to declare apn, user, pass as const char, otherwise strings are getting corrupted (usually first 2 chars were cut)

Thanks for your comments, I will check that and get back to you soon.

1 Like

Then I’m looking forward… Thanks

@marvin7, i sent you a private message, please check it out.