This guide quickly explains how to flash a program on ESP8266 using Arduino IDE, in less than 5 minutes. First of all, you need to install the ESP8266 board in Arduino IDE, following the 2 steps below: add the repositories link inside File -> Properties (http://arduino.esp8266.com/stable/package_esp8266com_index.json), and then add the board, using Board Manager.
Then, connect the FTDI (USB to Serial) adapter, to the ESP8266, as below. As power voltage, be sure to use 3.3V (and not 5V!), to avoid destroying the board. I suggest using a breadboard, as I did below. RX and TX wires can be connected directly. The 3.3V pin of the FTDI adapter should be connected to both VCC and CH_PD, while 0V pin should be connected to both GND and GPIO0, in order to set the ESP8266 into "bootloading" mode. RST and GPIO2 pins can be left floating.
As a simple test, you can use the following sketch. What is does is to turn ON/OFF the integrated blue LED connected to GPIO1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#define ESP8266_PIN 1 #define DELAY_TIME 500 void setup() { pinMode(ESP8266_PIN, OUTPUT); } void loop() { digitalWrite(ESP8266_PIN, HIGH); delay(DELAY_TIME); digitalWrite(ESP8266_PIN, LOW); delay(DELAY_TIME); } |
Flash the board using the following parameters.
At the end of the flashing, the following message appears. It takes about 30 seconds - 1 minute to complete the flashing. After flashing, the program execution starts automatically (ESP8266 exits "bootloading" mode and enters "usage" mode). However, if you disconnect the 3.3V and reconnect again, in order to avoid booting in "bootloading" mode again, you should connect the GPIO0 pin to 3.3V, so that ESP8266 starts in "usage" mode.
And finally, this is how the program looks like. The LED blinks at 1 second periods (500ms ON, 500ms OFF).
hello, nice to meet you, I tried to make your example and it does not work for me, the error is:
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
Thank you!!!
Hello Gabriel, I am sorry but a long time passed since I used this code. From your errors, I guess that it is a connection problem when trying to upload the code. Is that possible?