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

dda
1,5951 gold badge12 silver badges17 bronze badges
asked May 28, 2024 at 13:02
4
  • Type "AT" and press "Send" from your Serial Monitor, what do you get? Commented May 28, 2024 at 13:32
  • Try it with mySerial.begin(115200); since that is the default baud rtate of the A9G. Commented May 28, 2024 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 Commented May 28, 2024 at 16:56
  • 1
    please do not post pictures of text ... post the text instead... format as code for readability Commented May 28, 2024 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
 }
 }
}
answered Jun 6, 2024 at 14:58
5
  • why? what is changed? Commented Jun 6, 2024 at 16:07
  • My serial baud rate has been changed from 57600 to 115200. Commented Jun 7, 2024 at 14:21
  • and why is that the right value. please write an answer without the sketch if only the baud rate is changed. Commented Jun 7, 2024 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. Commented Jun 8, 2024 at 15:55
  • but that should be in your answer. not a copy of the sketch. arduino.stackexchange.com/help/how-to-answer Commented Jun 8, 2024 at 17:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.