[Hilo] How to know SIM card is removed?

Answer: There are two ways to do that.
1/ SOFTWARE WAY

  • If your SIM card is removed when module is in idle or sleep mode, it’ll take about 2 minutes to get "+CREG: 0”.
  • If your SIM card is removed when module is ongoing a call (voice/data) call, it’ll take about 20-60 seconds to get “NO CARRIER” and “+CREG: 0” at the end.
  • If your SIM card is removed when module is ongoing a GPRS call, it’ll take about 40 seconds to get “NO CARRIER” and “+CREG: 0” at the end.
    -If your SIM card is removed when you input some AT command, for example <AT+CPIN?>, then you’ll get “+CME ERROR: 10” immediately, and then you’ll get <+CREG: 0> after about 15 seconds.

Note1: you need to set <AT+CREG=1> to enable URC of “+CREG:x”.
Note2: Please refer to AT document Chapter “18.5. Appendix 5“, it lists the AT Commands which cannot be supported without SIM card.

2/ HARDWARE WAY:

  • You can also use <AT+KSIMDET=1,x> make a hardware detection of the SIM card,
    It supposes that one of the GPIO is linked to the SIMCD of the SIM card. If the SIM card is removed, the HiLo will display URC of “+SIM:1” and then reboot automatically.

For example:
AT+KSIMDET=1,2—To enable SIM card detection (Configuration can be kept in non-volatile memory, you only input once)
OK
AT+KGPIOCFG?

+KGPIOCFG: 2,1,1 —The GPIO 2 is configured as input Pull UP automatically
OK

—Remove SIM card now
+SIM:1 —It indicate SIM card is removed immediately
—Module reset automatically in 2 seconds
+CREG: 2
+CREG: 0
+KSUP: 2 —It indicate SIM card is not present

—Insert SIM card
+SIM:0 —It indicates SIM card is inserted immediately
—Module reset automatically in 2 seconds
+KSUP: 0 —It indicate the module is ready to receive AT commands and no PIN needed
+CREG: 0
+CREG: 2
+CREG: 1

AT+KSIMDET=0,2 —Disable the SIM card detection
OK