how do I change baud rate on esp8266 01?

How do I change the baud rate on an esp8266 01 board from 115200 to 9600? I'm communicating to it via software serial on a uno board. Some AT commands seem to work, if short ones, but I tried on another esp bard to send AT+UART =9600,8,1,0,0 and I've no idea what that did, it was garbled in transmitting, I guess, due to software serial speed trying for 115200 with the relatively long message, and consequently no AT commands at any baud rate work on that board. Last night I almost got it finding my wifi hub, but not now.
I've tried sending AT+UART_DEF=? and get error on another esp 01 board, maybe it's not the newer firmware. I'm running out of esp boards.

I've spent hours poking around on the web, google etc, but I've not found anything that I'm happy to try on this type of board, most seem to refer to 'boards with more pins'. If I have to flash new esp firmware, I think somewhere, not sure where, it stated you could remove the chip from the uno board, and connect rx/tx of the esp 01 to the rx/tx of the Uno, but what then happens to the voltage on the rx/tx pins? Which is the preferred firmware, and from where, for this board, or will any do?

I'm new to this wifi stuff, and it's a steep learning curve, imnsho.

Best wishes,
Ray

raymw:
most seem to refer to 'boards with more pins'.

The ESP8266 microcontroller is the same on every ESP8266 module. The only differences are the amount of flash memory (that's provided by a separate chip), the number of pins available (the microcontroller itself always has the same number of pins but on the ESP-01 they didn't bother to break out more than a few of the GPIO pins), and the form factor. The only one of those that's relevant to the use of the AT firmware is the flash memory, since some versions of the AT firmware require more flash memory than some versions of the ESP-01 module (some ESP-01 have a 0.5 MB flash chip, others have a 1 MB flash chip).

raymw:
If I have to flash new esp firmware, I think somewhere, not sure where, it stated you could remove the chip from the uno board, and connect rx/tx of the esp 01 to the rx/tx of the Uno

That's correct. If your Uno doesn't have the socketed DIP chip then you can connect the reset and ground pins to disable the ATmega328P instead. For this usage, you are communicating between your computer and the ESP8266 via the USB to TTL serial chip on the Uno so the ATmega328P serves absolutely no purpose.

raymw:
what then happens to the voltage on the rx/tx pins?

The RX pin (pin 0) on the Uno will use 5 V logic levels, while the ESP8266 uses 3.3 V logic levels. Although many people have gotten away with subjecting the ESP8266 to 5 V logic, there is the possibility it could damage it. So if you have been using some level shifting circuitry between the ESP-01 and your Uno then go ahead and use the same circuit for this new connection. The TX pin (pin 1) on the Uno will be acting as an input and it can work with the 3.3 V logic levels of the ESP8266 with no problem. The reason why the RX and TX on the Uno are acting the opposite of what you'd normally expect is because those pins are marked according to the ATmega328P, but you're not using the ATmega328P. Since the USB to TTL serial adapter chip is connected to the ATmega328P with the normal RX-TX, TX-RX connection, pin 0 on the Uno is connected to the TX pin on the USB chip and pin 1 on the Uno is connected to the RX pin on the USB chip.

raymw:
Which is the preferred firmware, and from where

I've always used the AT firmware distributed by the manufacturer of ESP8266, Espressif:

They provide a "flash download" tool to install it:

The manual for the AT firmware is here ("ESP8266 Non-OS AT Instruction Set"):

Make sure to read the installation instructions carefully, especially about the flash memory requirements, since the ESP-01 modules have limited flash memory.

raymw:
I'm new to this wifi stuff, and it's a steep learning curve, imnsho.

You haven't seen a steep learning curve until you start on the nightmare of trying to use Espressif's horrible documentation to flash the AT firmware. I haven't had any luck with the most recent AT firmware versions so if you have trouble try the older versions.

Thanks for the explanation and warning. I'm hoping to follow your instructions, and I will report back. I'm thinking I may be able to get away without having to re-flash the esp-01, if Its baud rate is not 9600. (I think I've one or two which still have a usable baud rate). I guess I could use the uno, as you described, and communicate directly at 115200, and send the AT+UART query/reset commands from the arduino serial monitor, without having to reflash the esp.

However, as mentioned elsewhere on the web, why not just use the esp on it's own? Initially I only want to monitor a couple of sensors, and that may work, if I can get the code into the chip. I'm going to leave that until after I've got this linking to the uno working.

Perhaps there could be a 'sticky' post at the top of this section, giving a recommended procedure, so that everybody could start from a known place. However, to cover all options, I guess it would be a pretty lengthy task to produce such a tome and allow for future developments ...

raymw:
Thanks for the explanation and warning. I'm hoping to follow your instructions, and I will report back. I'm thinking I may be able to get away without having to re-flash the esp-01, if Its baud rate is not 9600. (I think I've one or two which still have a usable baud rate). I guess I could use the uno, as you described, and communicate directly at 115200, and send the AT+UART query/reset commands from the arduino serial monitor, without having to reflash the esp.

The key would be to find out what the new UART settings are on your ESP-01 boards. The Arduino IDE's Serial Monitor allows you to change the baud rate, but it's also possible that the other settings were corrupted and the Serial Monitor only allows communication at 8 data bits, no parity, one stop bit. However, there are other serial terminal programs that allow you to adjust all the communication parameters. With enough trial and error, you could find the correct setting but it could take a long time if you don't get lucky.

raymw:
However, as mentioned elsewhere on the web, why not just use the esp on it's own? Initially I only want to monitor a couple of sensors, and that may work, if I can get the code into the chip. I'm going to leave that until after I've got this linking to the uno working.

It's certainly an option. If I wanted to do that, I would use one of the boards that are made for that process, since the ESP-01 is missing some of the components needed to work well as a standalone board (USB to TTL serial adapter, voltage regulator). The WeMos D1 Mini is a nice little board. Adafruit also has an ESP8266 board that looks pretty nice. The ESP-01 was designed to act as a WiFi communications interface for another device (like your Uno), which is why they didn't bother to break out other pins or add power supply components or provide much flash memory.

raymw:
Perhaps there could be a 'sticky' post at the top of this section, giving a recommended procedure, so that everybody could start from a known place. However, to cover all options, I guess it would be a pretty lengthy task to produce such a tome and allow for future developments ...

I think a problem with that is this forum section is not only about ESP8266. We would be obligated to add a sticky for every other popular network interface as well and soon there would be so many stickies there would be no room left on the first page to see the new posts.

I am using one of the little interface boards, that takes care of the voltage levels, but only brings out the vcc,gnd,tx,rx. What I've found is three of the esp boards seem to be at 115200 baud, they respond to AT+RST with the first line as ' ets Jan 8 2013,rst cause:2, boot mode:(3,6)' and the checksums etc. They do not respond to AT+CWLAP (except for 'error'). The fourth board, bought from same supplier at same time, is at 9600 baud, and responds correctly with AT+CWLAP, showing my wireless networks. I am hesitant to try AT+RST on that to see which software version it is.

I will re-flash the three, if possible, but not sure if there is enough info to reset the Baud rates. iircc later versions you could use AT+UART_CUR=9600,8,1,0,0 (or def) I think, in my previous playing around, I must have successfully altered my fourth esp board, but have no idea how.

I believe I will have to work out how to hold the appropriate pin high on the adapter board when re-flashing

Thanks again, I'm getting there... no blue smoke yet!

Having had a quick peruse of the manual you referred to, I found the AT+GMR command, and I got this for all four boards

14:03:08.238 -> AT+GMR

14:03:08.238 -> AT version:1.1.0.0(May 11 2016 18:09:56)
14:03:08.306 -> SDK version:1.5.4(baaeaebb)
14:03:08.339 -> compile time:May 20 2016 15:08:19
14:03:08.373 -> OK
14:04:04.426 -> AT+UART_CUR?

14:04:04.426 ->
14:04:04.426 -> ERROR
14:04:48.490 -> AT+UART_DEF?

14:04:48.523 ->
14:04:48.523 -> ERROR

which seems to be much earlier than those on https://www.espressif.com/en/support/download/at?keys=

Have they added more AT commands, or just removed bugs/improved speed/whatever in the later versions? Any suggestion as to which version to try?

As you last mentioned, it must have been one of the server programs I tried that altered the baud rates, but I thought I'd got results for cwlap on more than one board - but trying to send via software serial at more than 9600 baud, I guess any thing could be altered.

Success, I think. As it was raining, I could put off the gardening, and spend time getting confused, but eventually I found this thread [SOLVED] unable to flash AT firmware on ESP8266-01 - Project Guidance - Arduino Forum and it's the same esp as mine. I used the uno, with reset shorted, and the small level convertor board, with jumper leads, no patchboard needed. I followed this link wrt the flasher, https://www.allaboutcircuits.com/projects/flashing-the-ESP-01-firmware-to-SDK-v2.0.0-is-easier-now/ (I tried both of the SPI modes QIO and DOUT, both seemed to flash OK) and now I have

21:34:46.063 -> at

21:34:46.063 -> OK
21:35:25.704 -> AT+UART_DEF?
+UART_DEF:0,0,0,0,0
21:35:25.704 -> OK
21:36:07.625 -> AT+UART_CUR?

+UART_CUR:105273,8,1,0,0
21:36:07.658 -> OK
21:37:03.040 -> AT+GMR
21:37:03.040 -> AT vession:1.6.2.0(Apr 13 2008 11:10:59)
21:37:03.074 -> SDK versioo:2.2.1(6
i 3nr6

(I've not yet sorted how to reliably set the baud rate to 9600, but at least I've got the chip flashed.) One problem, not yet verified, but windows 10 does not recognise the usb - so it has to work through the uno, but that may be more to do with windows 10. Thanks to everyone. Unfortunately, I'll have forgotten this before next week, so I'd better find how to set the baud rate, and then flash all the four chips and set their rate to 9600. I'm not sure if termite will work, if w10 does not recognise the esp usb port.

raymw:
Have they added more AT commands, or just removed bugs/improved speed/whatever in the later versions? Any suggestion as to which version to try?

They have changed some AT commands. I think it used to be only AT+UART, which did what AT+UART_DEF does now, and there was no AT+UART_CUR equivalent, but I could be misremebering the exact details. To make matters more confusing, there is a different variant of the AT firmware created by AI-Thinker, the company that manufactures many of the ESP8266 modules and some of their AT commands are different and I've never found any official documentation for that AT firmware. However, you didn't have that firmware or your AT+GMR would have said something about ai-thinker.

raymw:
(I've not yet sorted how to reliably set the baud rate to 9600, but at least I've got the chip flashed.)

Great work! It's probably a good idea to have the modern AT firmware anyway. I'm sure Espressif has made some improvements and fixes over time. The baud rate numbers its returning are quite strange. Are you using Serial Monitor set to 115200 baud? I'm amazed if it could communicate if the ESP8266 is really communicating at 105273.

raymw:
I'll have forgotten this before next week

Whenever I go through some complex process like this that I won't repeat often enough to remember the details, I write a set of instructions for my future self can follow. It takes a little extra effort but I'm always extremely grateful later.

Thanks. Got all four esp's set to 9600 baud, having beaten w10 and it's usb oddities. I used Termite to change all the uart settings to 9600 baud. My previous posting was before that change, and the odd values were due to using software serial on the uno, which only goes up to about 9600 baud, afaik. they are now all on sdk 2.2.1

Now to get to grips with getting these to work with wifi, again an area about which I know very little. Thanks for your help in getting me here. It's helpful to know that someone has trod this path before, since it's not just understanding the components, but understanding the multitude of things that can go wrong, loose wires, forgetting to set values, usb weirdness, reliance of floating wires to be high, etc.

Best wishes, Ray

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

One obvious thing, in hindsight, but took me maybe five hours trying other stuff. If using serial monitor, if simply txing/rxing to the esp module, you need to set the baud rate of the monitor to be the same as the esp, since there is no buffer - the esp only got 3 characters with serial set to 115200 and esp to 9600. If you use termite, you have to close it down in order to upload to the Uno.