arduinoiotgsm

SIM7600CE - How to know when SIM card is registered into network by software


I am trying to set up the SIM7600CE to have it connect to the internet whenever I turn it on with Arduino Mega. I know how to turn it on with software by set the pin D12 to HIGH but I don't know how to read the signal of the NETLIGHT pin to get to know when the NETLIGHT starts to blink, which means the SIM card is registered into network successfully. Is there any way I can read that signal? Or is there any other way I can acknowledge when SIM card is registered into network successfully by software?

edit: I am trying to get the information that my SIM7600 is connected by using AT command. Even though I can send the AT command, I cannot parse the response. The result of the code below turns out that the Serial keeps printing the string "at+csq" constantly. Can anybody help?

#define mySerial Serial1
#define PWRKEY 12

void setup() 
{
  digitalWrite(PWRKEY, HIGH);     //Press the boot button
  Serial.begin(115200);
  delay(500);
  mySerial.begin(115200);
  delay(5000);

  while (1)
  {
    Serial.println("AT+CSQ");     //AT command for Signal quality test
    updateSerial();
    delay(1500);
  }
}

void loop() 
{
  updateSerial();
}

void updateSerial()
{
  delay(500);
   while (Serial.available())
  {
    mySerial.write(Serial.read());
  }
  while (mySerial.available())
   {
    Serial.write(mySerial.read());
     if (Serial.find("+CSQ: "))   //Find the AT+CSQ response
    {
      char c = mySerial.read();   
      if (c != '9')               //check the first digit after "+CSQ: ", +CSQ: 99,99 means not detectable, 
      {
        Serial.println("connected");
        break; 
      }
    }
  }

Solution

  • I have solved the problem with the same logic. However, I tried to just write and read in the SIM7600 serial, with some printing on the monitor to guide/debug. Plus, I used a connection flag as a condition to break the while loop when the MODEM is connected.

    #define mySerial Serial1
    #define PWRKEY 12
    
    bool connectionFlag = 0; //will be set when connected
    
    void setup() 
    {
      digitalWrite(PWRKEY, HIGH);     //Press the boot button
      Serial.begin(115200);
      delay(500);
      mySerial.begin(115200);
      delay(5000);                    //Give it a little time to initialize
    
      while (1)
      {
        mySerial.println("AT+CSQ");     //AT command for Signal quality test
        connectionCheck();
        if (connectionFlag ==1) break;
        delay(1500);    
      }
      Serial.println("done");
      mySerial.println("AT+CSQ");       //Get the CSQ response to confirm. 
      updateSerial();
    }
    
    void loop() 
    {
      updateSerial();
    }
    
    void connectionCheck()
    {
      delay(500);
      while (mySerial.available())
       {
    //    Serial.write(mySerial.read());
         if (mySerial.find("+CSQ: "))   //Find the AT+CSQ response
        {
          Serial.print("initializing\t");
          char c = mySerial.read();   
          if (c != '9')               //check the first digit after "+CSQ: ", +CSQ: 99,99 means not detectable, 
          {
            Serial.println("connected");
            connectionFlag = 1;
            break; 
          }
        }
       }
    }
    
    void updateSerial()
    {
      delay(500);
      if (mySerial.available())
      {
        Serial.write(mySerial.read());
      }
      if (Serial.available())
      {
        mySerial.write(Serial.read());
      }
    }