Why do I need to change the Baudrate after I send a Reset to the ESP8266?

喜欢而已 提交于 2019-12-08 11:35:46

问题


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?


回答1:


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.




回答2:


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.


来源:https://stackoverflow.com/questions/40708356/why-do-i-need-to-change-the-baudrate-after-i-send-a-reset-to-the-esp8266

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!