Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM not present or wrong PIN routine stuck #9

Closed
salvq opened this issue Nov 22, 2019 · 8 comments
Closed

SIM not present or wrong PIN routine stuck #9

salvq opened this issue Nov 22, 2019 · 8 comments
Assignees
Labels
type: imperfection Perceived defect in any part of project

Comments

@salvq
Copy link

salvq commented Nov 22, 2019

I am using Connection Handler to get connected to GSM network via MKR GSM 1400. From time to time when I restart or reupload the sketch and I am getting error "SIM not present or wrong PIN" attaching screenshot.

When I restart the unit (reset button) or re-upload the sketch connection is successful. Looks to me that function just finish and never continue "void GSMConnectionHandler::init()" Arduino_GSMConnectionHandler.cpp

  1. Does this means in default settings there is no 2nd, 3rd etc. retry ?
  2. If so, is there any settings to set it up the way to retry again before fail or reset modem etc.?

Thanks a lot
Clipboard01

@salvq
Copy link
Author

salvq commented Nov 27, 2019

Hello, similar situation right after transmission SIM card is not present. After board reset communication continues...is it this infinity loop correct way to handle the situation ?

void onNetworkDisconnect(void *_arg) {
  Serial.println(">>>> DISCONNECTED from network");
}
08:19:15.795 -> Publishing message, timestamp: 08:19:15,CET
08:19:24.364 -> >>>> DISCONNECTED from network
08:19:25.049 -> Disconnected from Cellular Network
08:19:25.049 -> Attempting reconnection
08:19:25.049 -> Attempting reconnection
08:19:40.696 -> SIM not present or wrong PIN

@salvq
Copy link
Author

salvq commented Nov 27, 2019

I took out the PIN to eliminate other possibility but same behavior, time to time I am getting SIM not present or wrong PIN

The workaround I have implemented is watchdog so everytime processor is stuck in the routine Arduino gets restarted which usually helps after 1st or 2nd restart...

Any comment on that, does anybody have same issue ?

@salvq
Copy link
Author

salvq commented Nov 30, 2019

Adding more data on AT command level, anybody knows why there is time to time SIM not present ?

AT Command level on error

20:15:40.940 -> keep alive > INIT
20:15:44.950 -> ⸮AT
20:15:45.154 -> OK
20:15:45.187 -> AT+IPR=921600
20:15:45.187 -> OK
20:15:55.392 -> SIM not present or wrong PIN

After restart and connected OK

20:17:41.930 -> keep alive > INIT
20:17:45.954 -> ⸮AT
20:17:46.159 -> OK
20:17:46.193 -> AT+IPR=921600
20:17:46.193 -> OK
20:17:46.294 -> AT
20:17:46.294 -> OK
20:17:46.328 -> AT+UPSV=3
20:17:46.328 -> OK
20:17:46.431 -> AT+CPIN?
20:17:46.431 -> ERROR
20:17:46.637 -> AT+CPIN?
20:17:46.637 -> ERROR
20:17:46.840 -> AT+CPIN?
20:17:46.840 -> ERROR
20:17:47.045 -> AT+CPIN?
20:17:47.045 -> ERROR
20:17:47.251 -> AT+CPIN?
20:17:47.251 -> +CPIN: READY
20:17:47.251 -> 
20:17:47.251 -> OK
20:17:47.456 -> AT+CMGF=1

@salvq
Copy link
Author

salvq commented Dec 1, 2019

After several tests I am assuming there is a potential issue when changing baud rate...

There are 2 fixes:

  1. Change baud rate in Modem.cpp in MKRGSM library to 115200 (after changed to 115200 from default 921600 never got any problem with SIM not present as AT+IPR command i.e. changing baud rate is never executed), changing baudrate will have an impact to connection speed but not tested if so and how much
void ModemClass::setBaudRate(unsigned long baud)
{
  _baud = baud;
}

ModemClass MODEM(SerialGSM, 115200, GSM_RESETN, GSM_DTR); 
  1. Adjust delay after AT+IPR command from 100ms (it is minimal delay mention by u-blox for Sara U201 data sheet) to 200ms which seems to be more safe (not tested)
int ModemClass::begin(bool restart)
{
  _uart->begin(_baud > 115200 ? 115200 : _baud);

  if (_resetPin > -1 && restart) {
    pinMode(_resetPin, OUTPUT);
    digitalWrite(_resetPin, HIGH);
    delay(100);
    digitalWrite(_resetPin, LOW);
  } else {
    if (!autosense()) {
      return 0;
    }

    if (!reset()) {
      return 0;
    }
  }

  if (!autosense()) {
    return 0;
  }

  if (_baud > 115200) {
    sendf("AT+IPR=%ld", _baud);
    if (waitForResponse() != 1) {
      return 0;
    }

    _uart->end();
    delay(100);
    _uart->begin(_baud);

    if (!autosense()) {
      return 0;
    }
  }

  if (_dtrPin > -1) {
    pinMode(_dtrPin, OUTPUT);
    noLowPowerMode();

    send("AT+UPSV=3");
    if (waitForResponse() != 1) {
      return 0;
    }
  }

  return 1;
} 

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Dec 7, 2019
@salvq
Copy link
Author

salvq commented Dec 19, 2019

Just to update, I am running on baud rate 921600 (original one) and 200ms as mentioned on point 2 and no issue for several days...

@gvarisco
Copy link
Contributor

Got the same error on a different test performed, but I believe I end up in the same routine as @salvq (https://github.com/arduino-libraries/Arduino_ConnectionHandler/blob/master/src/Arduino_GSMConnectionHandler.cpp#L66-L67). My test consists in 'removing' the external antenna, having the board disconnecting from the network, then re-attaching it again and see if it reconnects. It doesn't exit from that status until a reset.

@gvarisco
Copy link
Contributor

gvarisco commented Feb 3, 2020

release 0.4.4 solves it for me. Commit: 10f0637

@salvq could you please give it a try?

@salvq
Copy link
Author

salvq commented Feb 17, 2020

I tried and working just fine, no more stuck in SIM not present or wrong PIN routine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants