0

I want to lower my ESP's baud rate for SerialSoftware but I keep getting "ERROR" responses to commands below.

I'm using Arduino Mega and Arduino IDE's serial monitor for commands:

AT+CIOBAUD=9600
AT+UART_DEF=9600,8,1,0,3

I tried AT and couple other commands they seems to be working and returning OK.

I use the code below for sending commands:

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

void setup() {

    Serial.begin(9600);
    while (!Serial) {}

    Serial.println("Goodnight moon!");

    mySerial.begin(115200);
    mySerial.println("Hello, world?");
}

void loop() {

    if (mySerial.available()) {
        Serial.write(mySerial.read());
    }

    if (Serial.available()) {
        mySerial.write(Serial.read());
    }
}
gre_gor
  • 6,669
  • 9
  • 47
  • 52
Eic Dafusen
  • 11
  • 2
  • 6
  • I don't understand the question. Where in the code are you sending the AT commands?, also which device is running the code that you wrote? Is it an Arduino UNO, or the esp8266? – Nitro Jan 20 '19 at 04:37
  • sorry that i forgot about thoso. I'm using arduino mega and arduino IDE's Serial Monitor for commands – Eic Dafusen Jan 20 '19 at 09:50
  • Did you type in 'AT+CIOBAUD=9600, AT+UART_DEF=9600,8,1,0,3' into the serial monitor and press enter, or did you type out each command one at a time? – Nitro Jan 20 '19 at 11:12
  • i typed them one at a time – Eic Dafusen Jan 20 '19 at 11:21
  • Did you try using Serial1 available on Arduino mega instead of the software serial? – Nitro Jan 20 '19 at 11:22
  • Does the esp stop responding to all your commands after you send either of the buad commands? – Nitro Jan 20 '19 at 11:30
  • no i still get ok for AT command and i've never heared of serial1 and i'm loking into it now – Eic Dafusen Jan 20 '19 at 11:32
  • here you go https://www.arduino.cc/reference/en/language/functions/communication/serial/ – Nitro Jan 20 '19 at 11:35
  • Thank You !! . Now i can have a healty communication wtih my esp and dont need to lower esp's baud-rate – Eic Dafusen Jan 20 '19 at 11:55
  • Why are you using software serial if you have 3 other hardware serial interfaces available? – gre_gor Jan 21 '19 at 17:35

1 Answers1

0

Assumptions:

  1. You have your computer connected to the Arduino Mega
  2. You have the ESP8266 connected to the software serial pins.
  3. You are trying to send AT commands to the esp via the Arduino Mega.

If my assumptions are correct, then this is what is happening.

Initially, when you power up the system, the baud rate of the ESP8266 is set to 115200 as default.

When you use the command AT+CIOBAUD=9600 it gets temporarily set to 9600. But the problem here is that, the software serial on your Arduino is still running at 115200 baud rate.

This means that when you send the next instruction AT+UART_DEF=9600,8,1,0,3 the Arduino Mega sends it at a baud rate of 115200, while the esp is listening to a baud of 9600.

Solution:
Look into the following link for how to permanently change the baud rate of the ESP8266
https://www.esp8266.com/viewtopic.php?f=13&t=718

Next use your current setup to send the command that you found in the upper link.

Next update the code of your Arduino Mega to have 9600 as baud rate for the software serial, and don't send any more baud changing commands via the Mega.

gre_gor
  • 6,669
  • 9
  • 47
  • 52
Nitro
  • 1,063
  • 1
  • 7
  • 17