簡體   English   中英

SIM7600CE - 如何通過軟件知道SIM卡何時注冊到網絡

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

我正在嘗試設置 SIM7600CE,使其在我使用 Arduino Mega 打開時連接到互聯網。 我知道如何通過將引腳 D12 設置為高電平來使用軟件打開它,但我不知道如何讀取 NETLIGHT 引腳的信號以了解 NETLIGHT 何時開始閃爍,這意味着 SIM 卡已注冊到網絡成功。 有什么辦法可以讀取那個信號嗎? 或者有什么其他方式可以確認SIM卡通過軟件成功注冊入網?

編輯:我試圖通過使用 AT 命令獲取我的 SIM7600 連接的信息。 即使我可以發送 AT 命令,我也無法解析響應。 下面代碼的結果是串行不斷打印字符串“at+csq”。 有人可以幫忙嗎?

#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; 
      }
    }
  }

查看調制解調器的 AT 手冊。 啟用所有與網絡注冊相關的 URC,一旦在網絡上注冊 - 您將收到一個 URC,其中包含您的 SIM 是否能夠在網絡上注冊的信息。

我已經用相同的邏輯解決了這個問題。 但是,我嘗試只在 SIM7600 串行中寫入和讀取,並在顯示器上打印一些以指導/調試。 另外,我使用連接標志作為條件來在 MODEM 連接時中斷 while 循環。

#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());
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM