SMS通知不适用于带有GSM模块的Arduino Nano

问题描述 投票:0回答:1

我想使用Arduino Nano监视GSM模块的SMS流量。我能够读取和发送SMS,但是通知系统无法正常工作:当我发送SMS(到GSM模块中的SIM卡)时,串行端口中没有可用的新数据。知道为什么或如何调试才能发现问题吗?

通信通过Arduino模块的Arduino的9和10针以及GSM模块的Quectel EC25的RX和TX完成。我正在使用的代码:

#include <SoftwareSerial.h>

#define DEBUG Serial
SoftwareSerial EC25(10,9); // RX, TX - 9600 baud rate
// pin 8 of raspi -> pin 9 of arduino nano 
// pin 10 of raspi -> pin 10 of arduino nano

#define AT_RESPONSE_LEN 100
#define TIMEOUT 1000

void setup() {
  // put your setup code here, to run once:
  EC25.begin(9600);
  DEBUG.begin(9600);

  // some AT commands just to see if the coms are ok
  sendATComm("AT","OK\r\n");
  sendATComm("AT+IPR?","OK\r\n");
  sendATComm("AT+CGSN","OK\r\n");

  sendATComm("AT+CNMI=2,1,0,0,0","OK\r\n");

  DEBUG.println("listennig");
}

void loop() {
  // put your main code here, to run repeatedly:

  if (EC25.available()){
    DEBUG.println("Notification received!");
  }

}



// function for sending at command.
const char* sendATComm(const char *command, const char *desired_reponse)
{
  uint32_t timer;
  char response[AT_RESPONSE_LEN]; // module response for AT commands.

  memset(response, 0 , AT_RESPONSE_LEN);
  EC25.flush();

  sendATCommOnce(command);

  timer = millis();
   while(true){
    if(millis()-timer > TIMEOUT){
      sendATCommOnce(command);
      timer = millis();
    }
    char c;
    int i = 0;

    while(EC25.available()){
      c = EC25.read();
      DEBUG.write(c);
      response[i++]=c;
      delay(2);
      }
      if(strstr(response, desired_reponse)){
        return response;
        memset(response, 0 , strlen(response));
        break;
      }
  }
}

// send at comamand to module
void sendATCommOnce(const char *comm)
{
  EC25.print(comm);
  EC25.print("\r");
  delay(100);
}
arduino sms gsm at-command
1个回答
0
投票
AT+QURCCFG="urcport","uart1"
© www.soinside.com 2019 - 2024. All rights reserved.