ESP8266-01S: Timed out waiting for packet header

Hi All,

1st post here so if I need to post this elsewhere or make a dumb error please help me get it right.

I have been trying to upload the "Blink" sketch to my ESP8266 for 3 days and I'm struggling to get the sketch to upload.

Sketch:

/*
  ESP8266 Blink by Simon Peter
  Blink the blue LED on the ESP-01 module
  This example code is in the public domain

  The blue LED on the ESP-01 module is connected to GPIO1
  (which is also the TXD pin; so we cannot use Serial.print() at the same time)

  Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
  // but actually the LED is on; this is because
  // it is active low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

Setup:

  • Arduino Mega 2560 Rev3

  • ESP8266-01S from AZ Delivery (ESP8622-01S)

  • Power supply for ESP8266: PSU from AZ Delivery

  • ESP8266, PSU & reset button mounted on breadboard

  • I have the TX => TX and RX => RX between the Arduino and the ESP8266

  • I have a ground connection between the breadboard and the Arduino

  • I have the GPIO0 connected to Ground

  • I have a reset button connected to the reset (RST) pin

Actions I take:

  1. Power up Arduino and ESP8266
  2. Connect Ardunio IDE (2.0.3) to Ardunio via standard USB cable.
  3. Open Serial Monitor. Set "Both NL & CR" & "74880 baud" options.
  4. Press the reset button for the ESP8266
  5. Observe ets Jan 8 2013,rst cause:2, boot mode:(1,7) showing on screen. I understand that the "1" indicates that I am in programming mode.
  6. Close Serial Monitor
  7. Click "Upload"
  8. Observe output.
  9. The last few lines show: "C:\Users\Des\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1/python3" -I "C:\Users\Des\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.1/tools/upload.py" --chip esp8266 --port "COM3" --baud "115200" "" --before default_reset --after hard_reset write_flash 0x0 "C:\Users\Des\AppData\Local\Temp\arduino-sketch-115050097BAF3ED954AC2171AD3C831D/Blink.ino.bin" esptool.py v3.0 Serial port COM3 Connecting........_____....._____....._____....
  10. While this is happening the blue LED on the ESP8266 is flashing.
  11. While the "Connecting" dots and dashes are marching, I press the RST button. No observable change on screen. Blue flashing LED briefly stops, then resumes.
  12. Eventually, I get, A fatal esptool.py error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
  13. I then spend many hours Googling the error and everything about this issue.

So, any ideas, thoughts, suggestions or requests for more info would be happily recieved!

Finally, it may be worth mentioning that if I disconnect the ground from GPIO0 and run AT from the Serial Monitor I get:

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 1856, room 16 
tail 0
chksum 0x63
load 0x3ffe8000, len 776, room 8 
tail 0
chksum 0x02
load 0x3ffe8310, len 552, room 8 
tail 0
chksum 0x79
csum 0x79

2nd boot version : 1.5
  SPI Speed      : 40MHz
  SPI Mode       : DIO
  SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

rf cal sector: 249
rf[112] : 00
rf[113] : 00
rf[114] : 01

SDK ver: 1.5.4.1(39cb9a32) compiled @ Jul  1 2016 20:04:35
phy ver: 972, pp ver: 10.1

However, if I change to "115200 baud" and reset the ESP8266 I get a load of gibberish followed by:

Ai-Thinker Technology Co. Ltd.

ready

Thanks for your time and look forward to any input,
Des

can you provide a schematic showing the wiring of the Mega, ESP-01 and power supplies
for programming and initial testing of ESP-01 devices I use a ESP-01 Helper V3 then connect into the final circuit when working
also note that the Mega uses 5V logic and the ESP-01 3.3V so connecting the devices directly can damage the ESP-01 - use potentical drivers or level shifters to interconnect

Hi @horace,

Thanks for your reply. Here is a schematic to show my set up. I have tried to keep it super simple but included the button just to make the reset more certain.

I did try a pair or resistors to bring the RX voltage down to 3.3v but then I got no joy with the AT commands. Should I persevere with the resistors?

Look forward to your thoughts.

I assume you are attempting to program the ESP-01 via the Mega
I always use ESP-01 programmers (have a look on EBAY) it makes life much simpler
see post ESP-01 in a ESP-01 Helper V3 programmer connected via serial to an Arduino Due

Hi @horace,

Yes, I'm using the Mega to program the ESP8266.

I feel that this should work without needing me to buy more kit.

Eventually, the ESP8266 will be used to relay data from the Mega so having it working as I have it is important.

If you look at point 9 in my original post you will see:

"C:\Users\Des\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.1/tools/upload.py" --chip esp8266 --port "COM3" --baud "115200" "" --before default_reset --after hard_reset write_flash 0x0 "C:\Users\Des\AppData\Local\Temp\arduino-sketch-115050097BAF3ED954AC2171AD3C831D/Blink.ino.bin"

I am interested in the options --before default_reset --after hard_reset write_flash 0x0 how are these options set and might changing them help?

The feeling I have is that either the baud rate is incorrect. The IDE is sending at 115200 but I get the most sense when using 74880 in the Serial Monitor

or

That the reset that I understand has to be made during the "Connecting" phase is not trigering the correct response ...

Well, sadly, this kit seems to be far too flakey for me to invest any further time.
I've ordered an Arduino Ethernet Shield so hopefully I'll finally get reliable network connectivity.

Pity that this kit is so unpredictable!

Sorry to anyone searching this in the future hoping for answers ...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.