0

I am trying to hook up to an A9G Pudding GSM board via an Arduino. I intend to use the onboard UART chip to facilitate TTL-UART conversion between PC and A9G.

I have initiated a software serial instance and using this to pass communication to/from the A9G and the Arduino.

Here's my code. However, all I'm getting is gibberish stuff. I've checked my connections, the link seems to exist but the encoding is mismatched. I'm communicating with the A9G at 115200 and my emulated serial is at 9600.

Could this be an issue?

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(9600); // Monitor baud rate
  mySerial.begin(57600); // Set to detected baud rate

  Serial.println("A9G Module Communication Test");
  
  // Send AT command with carriage return and line feed
  mySerial.print("AT\r\n");
  delay(1000); // Wait for response
}
void loop() {
  // Check if data is available from the A9G module
  if (mySerial.available()) {
    // Read the data from the A9G module
    while (mySerial.available()) {
      char c = mySerial.read();
      Serial.write(c); // Send it to the Serial Monitor
    }
  }

  // Check if data is available from the Serial Monitor
  if (Serial.available()) {
    // Read the data from the Serial Monitor
    while (Serial.available()) {
      char c = Serial.read();
      mySerial.write(c); // Send it to the A9G module
    }
  }
}

Here's the output on the serial monitor.

Serial console output

4
  • Type "AT" and press "Send" from your Serial Monitor, what do you get?
    – hcheung
    Commented May 28 at 13:32
  • Try it with mySerial.begin(115200); since that is the default baud rtate of the A9G.
    – Lee-xp
    Commented May 28 at 15:07
  • please do not write in all capitals ... it indicates SHOUTING which is considered impolite ... use the edit button to correct the title
    – jsotola
    Commented May 28 at 16:56
  • 1
    please do not post pictures of text ... post the text instead... format as code for readability
    – jsotola
    Commented May 28 at 16:58

1 Answer 1

-1

You can edit your code like this.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(9600); // Monitor baud rate to match A9G
  mySerial.begin(115200); // Set to A9G baud rate

  Serial.println("A9G Module Communication Test");
  
  // Send AT command with carriage return and line feed
  mySerial.print("AT\r\n");
  delay(1000); // Wait for response
}

void loop() {
  // Check if data is available from the A9G module
  if (mySerial.available()) {
    // Read the data from the A9G module
    while (mySerial.available()) {
      char c = mySerial.read();
      Serial.write(c); // Send it to the Serial Monitor
    }
  }

  // Check if data is available from the Serial Monitor
  if (Serial.available()) {
    // Read the data from the Serial Monitor
    while (Serial.available()) {
      char c = Serial.read();
      mySerial.write(c); // Send it to the A9G module
    }
  }
}
5
  • why? what is changed?
    – Juraj
    Commented Jun 6 at 16:07
  • My serial baud rate has been changed from 57600 to 115200.
    – tepalia
    Commented Jun 7 at 14:21
  • and why is that the right value. please write an answer without the sketch if only the baud rate is changed.
    – Juraj
    Commented Jun 7 at 16:31
  • The serial monitor is showing garbage value. That's why I thought, the defined baud rate for A9G might not be correct.
    – tepalia
    Commented Jun 8 at 15:55
  • but that should be in your answer. not a copy of the sketch. arduino.stackexchange.com/help/how-to-answer
    – Juraj
    Commented Jun 8 at 17:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.