Unable to upload code to ESP8266 board

Hi there ,

I’m trying to upload code on Arduino Nano with selected board “Generic ESP8266 Module” but getting following error -
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

Selected baud rate is 115200. I’m powering ESP8266 with 3.3V pin.

How can you connect Arduino nano and select Generic Esp8266?

I’ve got a tutorial link that specifies that in order to use esp8266 with Arduino uno/nano , i’ve to install Generic ESP8266 board and select ESP8266 board to upload the code.

Can you please provide me any documentation/support link to connect Arduino uno/nano to wifii using ESP8266 module??


The esp8266 can itself host and run the Arduino compatible code and can be programmed by Arduino IDE.
But if you looking to use Arduino Boards as main controller then use Esp8266 in AT command mode. By default these modules come in AT command firmware. If not, you can flash the AT command firmware using NodeMCU tools.

The flash timeout occur when wrong board type is selected or non updated Arduino IDE or wrong serial connections. Or not entering the boot mode using the GPIO0 of Esp8266.

I’m using Generic ESP8266 board in IDE, and serial connection Rx of esp to Rx of uno and Tx of esp to Tx of uno. I’ve also grounded the GPIO0 of esp.

Pin Connection of ESP with Arduino Nano

ESP Pins Arduino Pins
Pin 1 GND
Pin 2 Tx
Pin 3  
Pin 4 3.3V
Pin 5 GND
Pin 6  
Pin 7 Rx
Pin 8 3.3V

Are holding the gpio down during bootloading process.?

At time of bootloading process, i’ve only made the power supply connection and GND connection of ESP to Arduino . So now serial or GPIO connection at time of bootloading.

The Tx pin of one device should be connected to the Rx pin of the other. Tx means “transmit” and Rx “receive”.

But at time of sketch upload i pull off Rx, Tx connection. And i am facing problem in uploading sketch.

If you do not need the ESP8266 when uploading the sketch, try fully disconnecting it (including the power pins) and then try to upload the sketch to the arduino nano.

Does it work that way?

I removed every connection of esp8266 with arduino uno and then tried to upload sketch to uno.

Arduino: 1.8.9 (Windows 8.1), Board: “Generic ESP8266 Module, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), ck, 26 MHz, 40MHz, DOUT (compatible), 512K (no SPIFFS), 2, nonos-sdk 2.2.1 (legacy), v2 Lower Memory, Disabled, None, Only Sketch, 115200”

Sketch uses 275808 bytes (55%) of program storage space. Maximum is 499696 bytes.
Global variables use 27664 bytes (33%) of dynamic memory, leaving 54256 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.6
esptool.py v2.6
Serial port COM14
Connecting……____Traceback (most recent call last):
File “C:\Users\Dell\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.1/tools/upload.py”, line 25, in
File “C:/Users/Dell/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.1/tools/esptool\esptool.py”, line 2653, in main
File “C:/Users/Dell/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.1/tools/esptool\esptool.py”, line 468, in connect
raise FatalError(‘Failed to connect to %s: %s’ % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
the selected serial port _
does not exist or your board is not connected

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

Ok, the thing is, you seem to have selected the option to program the esp8266, but you have connected a Arduino UNO. Maybe you don’t know, but there are two ways to use a esp8266 in the context of Arduino:

  • As a WIFI module. In this case you program the Arduino UNO as usual (you have to choose Arduino UNO as Board), and you comunicate with the ESP8266 through AT commands using the Serial pins of the Arduino. AT commands are just messages in text that start with the letters “AT” (e.g.: “AT+CSPIN”).

  • As an independent Arduino-compatible microcontroller. In this case, you can directly access the pins and functionality of the esp8266 from your sketch code, instead of relying on AT commands to tell the esp8266 what to do. For this, you have to interface the esp8266 with the PC using a Serial to USB converter, and choose for example “Generic ESP8266 Module” as Board (as you have done).

I’m not sure, but I assume you are trying option 2, in which case there are two conserns:

  1. You MUST have a good Serial connection between the Arduino and the esp8266 while you are uploading your sketch. You CAN NOT use the hardware Serial pins of the UNO, as it needs them to comunicate with the PC, you’ll have to try with the SoftwareSerial library and connect the esp8266 in some other pins.

  2. Even then, it might not work, because I’m not sure if the UNO is compatible with the specific speed needed for the esp8266 sketch upload baud rate. What is more likely to work is a dedicated chip, such as the FTDI and clones.

1 Like