And hello again geektimes . This material is a continuation of my previous article - ESP8266 and Arduino, connection, pinout , and I must say that they are interrelated. I will not touch on topics that are already disclosed.
And today, I will tell you how to program ESP8266 using the Arduino IDE , also flashing other firmware, for example NodeMcu ... In general, this material is not limited to just one Arduino theme.
')
The theme of ESP8266 is pretty complicated. But, if you work with these Wi-Fi modules in the Arduino IDE development environment, the threshold of entry drops to an acceptable level for an ordinary arduinschik. And not only arduinschik, and any person who has a desire to bungle something on the topic of IoT (Internet of Things) , and not spending a lot of time reading the documentation for the chip and learning the API for these modules.
This video completely duplicates the material presented in the article below. Well, we already know how to connect the ESP8266 and put it into programming mode, now let's move on to something more useful.
I will say right away - once having programmed the module in the Arduino development environment, we are demolishing the native firmware, and we will not be able to work with the module using AT commands. Personally, from this, it’s not cold / not hot, but if someone needs it, towards the end of the article I’ll show you how to flash the native firmware back into the module, well, or some NodeMcu-type loader.
To begin with, on off.sayte download the latest version of the Arduino IDE , at the moment it is 1.6.7. Older versions like 1.0.5. they will not work, because they simply do not have the necessary functionality, and we are not interested in dancing with a tambourine, is it?
Run the development environment and immediately go to File / Settings:
Insert the link in the "Additional links for the Card Manager:" field and click "OK".
A window of the manager of the boards appears in front of us, scrolling it down to the bottom, and if everything is done correctly we will see something like this:
Click the cursor on the inscription " esp8266 by ESP8266 Community " after that, we have a button "Installation", choose the version you want, I take the last one, today it is 2.1.0. and install it. The development environment will download the files it needs (about 150 megabytes) and “INSTALLED” will appear next to the inscription " esp8266 by ESP8266 Community ", that is, it will be installed:
We scroll down the list of boards and see that we have many different ESPs in the list, we take the “Generic ESP8266 Module”:
Go to "Tools" and select the desired COM port (I have it COM32) Arduino or USB UART converter , then set Upload Speed: "115200":
Next, open the console in the Arduino IDE, power on the module, if everything was done correctly, we will see something like this:
We set the speed of 74880 and “NL & CR” and again turn off and power up and it will respond with some debug information:
Note that 74880 is not the main speed of ESP8266, it just sends debug information on it. If the module does not send anything to the console, then something is probably not connected as it should.
By default, the speed should be 115200, but in some cases there may be 9600 and others ... So try to pick up.
After selecting the desired speed, send the module "AT" and he must answer that everything is "OK". The “AT + GMR” command displays information about the firmware.
Before you start to flash ESP8266 in the Arduino IDE, I advise you to finish reading the article to the end.
Now let's try flashing the ESP8266 through the Arduino IDE. We translate the module into the programming mode (as I wrote in the previous article ).
Let's flash the flasher with a regular LED:
// By Mr youtube.com/RazniePodelki // special to geektimes.ru/post/271754/ #define TXD 1 // GPIO1/TXD01 void setup() { pinMode(TXD, OUTPUT); } void loop() { digitalWrite(TXD, HIGH); delay(1000); digitalWrite(TXD, LOW); delay(1000); }
Zamigal? So everything is done correctly. Where did I get that the LED is connected to the first pin? In the previous article there is a picture with pinout of different modules , and there is a marking of ports, when using the Arduino loader (the pins are marked in pink).
LED flashing is nice, but some web server should be patched up or started to control the LED at least with the help of buttons in the browser, isn't it? But I will tell you about this some other time.
And now how to flash back the native firmware , and how to even flush the module with third-party loaders. For ESP8266 there is such a program as NodeMCU Flasher , which was originally designed for flashing the NodeMCU bootloader. But as it turned out, it perfectly flushes other firmware.
I will attach an archive with this program and firmware to the article for convenience, but here you can always download the new version of NodeMCU Flasher.
There are 2 Win64 and Win32 folders in the nodemcu-flasher-master folder, and depending on how much bit your OS chooses. Next, in the Release folder, run “ESP8266Flasher.exe” and see the program interface:
Select the desired COM port and go to the “Config” tab, remove the tag near “INTERNAL: // NODEMCU” and put it one point below, as in the screenshot:
(If you want to flash the NodeMCU loader, remove the tag where it was not, and install it where it was, that is, near “INTERNAL: // NODEMCU”).
Then click on the gear and choose where our firmware is, the firmware is usually in * .bin format (in the attached archive it is “v0.9.5.2 AT Firmware.bin” which is in the main folder), and also choose “0x00000” as and higher.
Next we go to the tab “Advanced” and change the speed there to 115200, it is this speed that will be the main one and the module will respond to AT commands in case of the corresponding firmware.
We return again to the “Operation” tab; we translate the module into programming mode and click “Flash”:
Everything, the module began to flash, after flashing we do not forget to restart the module and voila, it is flashed with the firmware we need.
We check with the AT-command GM + that we have done everything right: