Why do I need to change the Baudrate after I send

2019-06-13 19:54发布

So I have succesfully attached a Esp8266 to an Arduino Due. I can communicate with it via Serial Monitor if I choose the Baudrate to be 74880. Then all the commands come to it correctly and can be read back correctly. However, when I send the command AT+RST which restarts the Esp8266 I can no longer communicate with it and need to reopen the serial connection with a Baudrate of 115200. I have to repeat this every time I load the code new to the Arduino or when I power off the Esp8266.

Any ideas where this behaviour comes from?

2条回答
不美不萌又怎样
2楼-- · 2019-06-13 20:40

Here you are an explanation about where are the origins of such a behavior:

Baudrate of 74880 Bd is ESP's 'native' baud rate for sending debug messages generated automatically by the system itself during the boot in case there is 26 MHz instead of 40 MHz crystal used on board - and as we can see, mostly that is the case.

With 40 MHz crystal the baudrate would be as expected (115200) but with 26 MHz crystal instead, baudrate is 115200 * 26/40 = 74880.

Later after bootloader ends baudrate is controlled in other way so that's why you have two different baudrates - the first is the default one (74880) and the second is the one that is active later (the one you can set).

I usually set baudrate to 74880 so I can see both the messages generated automatically and the messages I send from the code.

查看更多
Ridiculous、
3楼-- · 2019-06-13 20:47

In order to set UART baudrate persistent after a reset you should use AT+UART_DEF.

From the AT instruction :

  1. AT+UART_DEF – default UART configuration This command sets the UART configuration and save it to flash. It is stored as the default parameter and will also be used as the default baudrate henceforth.
查看更多
登录 后发表回答