0

I'm trying to use an Arduino Nano to communicate with a Quectel EC25 module from this Raspberry Pi 4G HAT. I'm using Arduino's pins 8 and 7 to communicate with RX and TX from the Quectel module. I'm able to establish communication and send AT commands.

The problem is that when I start to listen for incoming SMS, the available method does not change status, even if an SMS is received. There is the code I using:

#include <SoftwareSerial.h>

#define DEBUG Serial
SoftwareSerial EC25(8,7); // RX, TX - 9600 baud rate

#define AT_RESPONSE_LEN 100
#define TIMEOUT 1000

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

  sendATComm("ATE1","OK\r\n");
  sendATComm("AT","OK\r\n");
  sendATComm("AT+IPR?","OK\r\n");
  sendATComm("AT+CGSN","OK\r\n");

  sendATComm("AT+CNMI=2,1","OK\r\n");
  DEBUG.println("listennig");

}

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


  if (EC25.available()){
    DEBUG.println("Available");
  }



}

// 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");
}

That gives the following output:

ATE1

OK
AT

OK
AT+IPR?

+IPR: 9600

OK
AT+CGSN

860548040717545

OK
AT+CNMI=2,1

OK
listennig

I also tried this example by changing the default RX and TX pins but does not work at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.