Showing posts with label Generic ESP8266 Module. Show all posts
Showing posts with label Generic ESP8266 Module. Show all posts

Thursday 9 January 2020

How to Flash ESP8266 Modules

Method 1: Auto Resetting Programmer Using a NodeMCU




Flash ESP-01 easily with your NodeMCU

Basically we are going to disable the ESP8266 on the NodeMCU by forcing the EN pin low, this will prevent the ESP8266 module on the NodeMCU from booting. We are then going to connect all the relevant pins of the NodeMCU board to our external ESP8266.
Wiring it up
To wire it up, you will need the standard ESP8266 wiring as shown in the previous step and then to add the following connections (also shown in the image above):
·         Connect 3V of the NodeMCU to VCC of the ESP8266
·         Connect GND to GND
·         Connect TX of the NodeMCU to TX of the ESP8266 (This is different than the previous step)
·         Connect RX of the NodeMCU to RX of the ESP8266
·         Connect D3 of the NodeMCU to GPIO 0 of the ESP8266 (D3 is GPIO 0 of the ESP8266)
·         Connect RST of the NodeMCU to RST of the ESP8266
·         Connect EN of the NodeMCU to GND
Uploading a sketch
Once you have the ESP8266 wired up, you need to do the following:
·         Select the port number of the NodeMCU (Tools->Port)
·         Select the Board type "NodeMCU 1.0 (ESP12-E Module)"
·         Click upload
And that's it! It will automatically enable programming mode and will automatically reset when finished uploading so it will start executing the sketch.
Using this in your board designs
In order to use this method in your board designs, you simply need to break out the following pins:
·         Ground
·         GPIO 0
·         VCC
·         TX
·         RX
·         RST
And when you want to program your boards, wire it up as above.

Method 2: Using Basically Any USB to Serial Converter



Normal Operation:

 

Before we get started on programming we first need to take a look at the what external components the ESP8266 needs to run. For normal operation an ESP-12 module needs the following
·         EN, RST and GPIO 0 needs to be pulled high using a 10K resistor
·         GPIO 15 needs to be pulled to Ground using a 10K resistor
·         3.3V power supply capable of about 250mA of current (A cap between VCC and GND is recommended)
With the above configuration the ESP8266 when powered on will be in Normal operating mode, so it will run whatever sketches you have programmed to it.

The modules have the resistors setup for the EN and GPIO 15 pin, so you will still need to add the pull-up resistor for RST and GPIO 0,

Enabling Programming mode:

 

To get it into programming mode, GPIO 0 needs to be pulled low when the ESP is starting up. The easiest way to do this is to add buttons to GPIO 0 and the RST pin that connect to ground when pressed. Then to enable flash mode, you simply
·         Hold down the GPIO 0 button
·         Press the RST button
·         Then let go of both buttons
You don't need to perform this sequence at any particular time during the upload process or anything, once the ESP is in programming mode it will stay there til the next reset, so just perform the steps any time before uploading.

Programming with a USB to serial adapter:

 

Enabling program mode is only half the battle, now we need to actually program the module. Most USB to serial adapters can not provide enough current to the ESP8266 so it's recommended that you power the ESP8266 using an external 3.3V source.
To wire up the programmer you need to connect the following pins (also shown in an image above):
·         Connect TX of the programmer to RX of the ESP8266 (Not a typo, the connections are reversed)
·         Connect RX of the programmer to TX of the ESP8266
·         Connect Ground of the programmer to Ground of the ESP8266
To upload your sketch, do the following steps:
·         Select the port number of your Serial adapter (Tools->Port)
·         Enable programming mode on your ESP8266 as described above
·         Click the upload button. (If it fails double check your wiring and try reseting your board into programming mode again)
·         Click the reset button when the upload has finished
Here are the board settings I used when uploading using this method:
·         Board: Generic ESP8266 Module
·         Flash Mode: DIO
·         Flash Size: 4M (3M Spiffs)
·         Reset Method: ck
·         Flash Frequency: 40MHz
·         Upload Speed: 115200
-
Note: This artical is copied from Internet, not written by me.