Weird characters after AT command is sent

Hello guys!
Wanted to ask you why are some random characters printed out when I send AT command via serial using this code.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8,9); // RX, TX

void setup()  
{
  Serial.begin(9600);
  mySerial.begin(9600); 
}

void loop()
{
  if (mySerial.available())
    Serial.write(mySerial.read());
    
  if (Serial.available())
  { 
    while(Serial.available())
    {
      mySerial.write(Serial.read());
    }
    mySerial.println();
  }
}

and this is the response after the module is up and running and I write simply AT to the monitor


What could be the issue? I got similar problems on my other project when I was sending AT commands through code.

To what device are you sending AT commands?
Is 9600 the correct baud rate?

It is BC68 TE-B from Quectel and I think it was written in the documentation that the basic baud rate is 9600.
image

You are only reading one character in per loop. Try...

void loop()
{
  while (mySerial.available())
    Serial.write(mySerial.read());

  while(Serial.available())
     mySerial.write(Serial.read());
}
1 Like

Oh this works. I am such a dumbass. Thank you for your help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.