AT commands response error in serial monitor from ESP32 to GSM via UART,

Hi to the previous post which i have raised in forum, i have some error,

i am trying to interface a gsm module to ESp32, while trying to send the AT commands, and read the response in serial monitor, i get random error in serial monitor like this


even i changed to lower baud rate still i have no response, I am using software serial for esp32,

My code is follows

#include <SoftwareSerial.h>

//static const int RXPin = 16, TXPin = 17; // UART pinout

SoftwareSerial myserial(16, 17); // The MODial connection to the GPS device

void setup()
{
  myserial.begin(115200); //Initialize virtual serial port
  delay(5000);
  Serial.begin(115200); //Initialize Arduino default serial port
  delay(1000);
  Serial.print("ready_hi");
}

void loop()
{
  //Serial.println("ready");
  if (myserial.available())
    Serial.write(myserial.read());
  if (Serial.available())
    myserial.write(Serial.read());
}

if i have missed any parts, give your valuable thoughts, thanks and regards.

The ESP32 has a hardware serial interface (Serial2) on exactly the pins 16 and 17. Why do you emulate one in software? Don't expect that emulation to run at 115200 baud reliably.

Given the random characters you get (that's not an error message!) I guess you use the wrong baud rate but that's up to you to check.

yes, i have tried with hardware serial also, and even cross verified the baud rates, but seems to be no luck. Also when i try to check the response of the module via USB to TTL, in serial monitor in the same baudrate, i get a proper output. This is not happening when i send via ESP32

As stated by @pylon hardware serial is way more reliable... I doubt you will get high speeds (115200) using Software Serial.

Looks like a mismatch baud rate with the modem... do you know the default for the modem you are using? You could try sending an AT command to change the default.

yes, actually it supports different baud rates, we can select in which we need to operate, i will check once again, with hardware serial.

Thanks guys @pylon @red_car , hardware serial helped me, in the same baud rate with bit increase in a delay. Now i am getting reasonable response which i expected.

1 Like

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