2
votes

Objective: Submit AT Commands to the Quectel M95 (GSM2 Click http://www.mikroe.com/click/gsm2/) via SoftwareSerial/Arduino and parse responses; no Arduino GSM library.

Current condition: Able to fully communicate with the M95 via terminal at a variety of baud rates (9600 - 115200). AT Commands can be submitted and the desired result codes are present. I have tried with a different modem (DroneCell) with same results. All wiring has been checked 10 times and verified correct. If I submit AT commands via SoftwareSerial I know the modem is receiving the data as I can send an SMS, enact GPRS, etc; just can't get valid responses.

Issue: Arduino is unable to read GSM Module responses using the below code. Result is garbled text/chars - variable and unpredictable. The expected response when submitting AT Command "AT" is "OK."

Images:

Success via terminal:

enter image description here

Arduino response:

enter image description here

#include <SoftwareSerial.h>

#define rxPin 10
#define txPin 11

SoftwareSerial mySerial(rxPin,txPin); // RX, TX

void setup(){

  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);

  Serial.begin(9600);
  Serial.println("Arduino serial initialized!");
  delay(10);

  mySerial.begin(9600);
  Serial.println("Software serial initialized!");
  delay(10);
}

void loop(){
  issueCommand("AT");
  readSerial();
  delay(500);


  while(true){
    readSerial();
  }
}

void issueCommand(char* msg){
  mySerial.println(msg);
  Serial.print(msg);
  delay(10);
}

void readSerial(){
  while (mySerial.available()){
    Serial.write(mySerial.read());
    delay(10);
  }
}
2
I think you should wait (loop) until the response to your "AT" is received and only after that continue to send more commands.JimmyB
Which arduino are you using?Josh
I am using the latest version of Arduinoi: UNO.David J Barnes

2 Answers

1
votes

Solution: auto baud rate was in fact not enabled; I had my internal M95 baud rate set to 115200, my Arduino solution was also set to 115200 baud. However, SoftwareSerial seems to fail for rates over 9600-ish. Once I reset M95 internal rate to auto baud and changed my Arduino code to 9600 characters came through as expected.

Thanks for the feedback it drove me to find the solution myself.

Thanks!

0
votes

Change write to print:

   void readSerial(){
     while (mySerial.available() > 0){
        Serial.print(mySerial.read()); // or println
     delay(10);
   }