logo elektroda
logo elektroda
X
logo elektroda

[Solved] VS Code + PlatformIO: ESP-01S Upload Fails - Timed Out Waiting for Packet Header

Interval 3192 30
Best answers

Why does PlatformIO fail to upload to an ESP-01S with "Failed to connect to ESP8266: Timed out waiting for packet header"?

Put the ESP-01S into flashing mode correctly, verify the USB-TTL wiring and COM port, and use the proper PlatformIO board settings; after a platform.ini change, the upload succeeded in the thread [#20791321][#20791699][#20800306] For the blink test, do not rely on LED_BUILTIN on this module—set the pin explicitly to the ESP-01S GPIO used by the LED, and in this case changing it to GPIO2 made the LED blink [#20800592][#20800674]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20790596
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    I have written a simple program to blink the LED. The program has compiled, when I press Upload it doesn't want to connect to the ESP

    "Auto-detected: COM3
    Uploading .piobuild.bin
    esptool.py v3.0
    Serial port COM3
    Connecting........_____....._____....._____....._____....._____....._____...............__________

    A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
    *** [upload] Error 2"
  • ADVERTISEMENT
  • #2 20791321
    Anonymous
    Level 1  
  • #3 20791574
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    I am using a link 1.0 esp module mounted in a socket, so it is connected correctly. When using the arduino it works. The problem occurs when I use the PlatformIO.
  • #4 20791699
    xury
    Automation specialist
    Posts: 7075
    Help: 877
    Rate: 1489
    Are you sure the correct COM port number has been detected?
  • #5 20791766
    Anonymous
    Level 1  
  • #6 20791782
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    Yes, definitely valid COM port 3.

    Added after 5 [hours] 26 [minutes]:

    platform.ini :

    [env:esp01_1m]
    platform = espressif8266
    board = esp01_1m
    framework = arduino
  • ADVERTISEMENT
  • #7 20792207
    Anonymous
    Level 1  
  • #8 20795150
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    After modification to form:

    [env:esp01_1m]
    platform = espressif8266
    board = esp01_1m
    framework = arduino
    upload_speed = 115200
    monitor_speed = 115200
    monitor_dtr = 0
    monitor_rts = 0

    still message:

    Looking for upload port...
    Using manually specified: COM3
    Uploading .. pio\n_1mfirmware.bin
    esptool.py v3.0
    Serial port COM3
    Connecting........_____....._____.........._____.........._____.........._____....._____.........._____

    A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
    *** [upload] Error 2.
  • #9 20795191
    Anonymous
    Level 1  
  • #10 20795211
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    COM3 settings, 115200.
  • #11 20795242
    Anonymous
    Level 1  
  • #12 20795420
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    No, I only have Platformio running.
  • ADVERTISEMENT
  • #13 20795458
    Anonymous
    Level 1  
  • #14 20800306
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    After changing the platform.ini, the programme was uploaded successfully, but it does not start. It does not show any errors.
  • #15 20800359
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #16 20800370
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    I uploaded the Blink program, the diode should blink - just like on the Arduino, it doesn't.
  • #17 20800378
    Anonymous
    Level 1  
  • #18 20800380
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    Executed. It doesn't work either.
  • #19 20800390
    Anonymous
    Level 1  
  • #20 20800431
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    --- Terminal on COM3 | 115200 8-N-1
    --- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
    --- More details at https://bit.ly/pio-monitor-filters
    --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
    -␀␀␀␀{d␀d��|␀�d�|␃␄␌␌�␄d�␌c|��␃�␛�r�c�␄c��gn�$og��␄c␜p��l;lsl8�o�␐␂␌␄�␄l␌��␄␄␌c␌n�|␃�␌�␜�␄c��'n�␀l��d`␃�␛␒gn␄l`␂␇␃o{���'␄␄#l�␇lp�o�␘␃␄␄{�ܜ�␜��␂␌b␄o�|␃␄�␄c��no�␀␌␌d`␃�␛␒g'␄$`␂␇␃n{���g␌␄c��`␃␇s��g␌␄c��`␂�␃␄␄␌�␌�p�$`␂��'�␇l��␃�␛�g�s��o|�␌�d�␜{d␜c�␛␃␌�|␂{�␃l�'�␌�o�␀␌d`␃��r�d�$␓�␌␄␄��␀␀␀␀␀␀␀
  • #21 20800435
    Anonymous
    Level 1  
  • #22 20800455
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    115200 in the manager also 115200
  • #23 20800469
    Anonymous
    Level 1  
  • #24 20800473
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    Ok, the diode when uploading behaves like when uploading with Arduino, it blinks.

    Added after 1 [minute]:

    Serial port COM3
    Connecting....
    Chip is ESP8266EX
    Features: WiFi
    Crystal is 26MHz
    MAC: bc:dd:c2:27:cb:ca
    Uploading stub...
    Running stub...
    Stub running...
    Configuring flash size...
    Compressed 265648 bytes to 195769...
    Writing at 0x00000000... (8 %)
    Writing at 0x00004000... (16 %)
    Writing at 0x00008000... (25 %)
    Writing at 0x0000c000... (33 %)
    Writing at 0x00010000... (41 %)
    Writing at 0x00014000... (50 %)
    Writing at 0x00018000... (58 %)
    Writing at 0x0001c000... (66 %)
    Writing at 0x00020000... (75 %)
    Writing at 0x00024000... (83 %)
    Writing at 0x00028000... (91 %)
    Writing at 0x0002c000... (100 %)
    Wrote 265648 bytes (195769 compressed) at 0x00000000 in 17.1 seconds (effective 124.1 kbit/s)...
    Hash of data verified...

    Leaving...
    Hard resetting via RTS pin...
    =========================================================== [SUCCESS] Took 27.44 seconds ===========================================================
    * Terminal will be reused by tasks, press any key to close it.
  • #25 20800489
    Anonymous
    Level 1  
  • #26 20800496
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    #include // include file Arduino.h

    int pin = LED_BUILTIN; // GPIO number for LED

    void setup() {
    pinMode(pin, OUTPUT); // set GPIO as output
    }

    void loop() {
    digitalWrite(pin, HIGH); // turn on LED with high state
    delay(1000); // wait 1 second
    digitalWrite(pin, LOW); // turn off LED with low state
    delay(1000); // wait 1 second
    }
  • #27 20800538
    Anonymous
    Level 1  
  • #28 20800540
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    Generic ESP8266 Module
  • Helpful post
    #29 20800592
    Anonymous
    Level 1  
  • #30 20800674
    Interval
    Level 32  
    Posts: 1730
    Help: 186
    Rate: 439
    Ok, I defined the "pin" as 2 and it works. Thank you very much for your time and help.

Topic summary

✨ The discussion revolves around an issue with uploading a simple LED blink program to an ESP-01S module using VS Code and PlatformIO, where the user encounters a "Timed out waiting for packet header" error. Initial troubleshooting steps included verifying the USB converter connection, ensuring the correct COM port (COM3) was selected, and examining the platform.ini configuration. Modifications to the platform.ini file, including adjusting upload and monitor speeds, were suggested. After several attempts, the user successfully uploaded the program but reported that the LED did not blink as expected. Further investigation revealed that defining the LED pin explicitly in the code resolved the issue, allowing the program to function correctly.
Generated by the language model.

FAQ

TL;DR: For VS Code + PlatformIO users flashing an ESP-01S on COM3, 115200 baud plus "upload_resetmethod = nodemcu" turned repeated packet-header timeouts into a working upload path. This FAQ solves two linked problems: PlatformIO upload failures and Blink sketches that upload but still do not run until the LED pin is set to GPIO2. [#20795458]

Why it matters: This thread shows that ESP-01S failures can come from both upload/reset settings and wrong LED pin mapping, so fixing only one side may still leave Blink apparently broken.

Tool or setting What happened in the thread Result
Arduino IDE + Generic ESP8266 Module Upload worked earlier Sketch behavior used as reference
PlatformIO + basic esp01_1m config Upload timed out on COM3 Failed to connect
PlatformIO + upload_speed = 115200 + upload_resetmethod = nodemcu Upload completed Flashing succeeded
Blink with LED_BUILTIN LED did not blink Misleading "not running" symptom
Blink with explicit pin = 2 LED blinked Working result

Key insight: The timeout was fixed by changing PlatformIO upload/reset behavior, but the final Blink result required a second fix: define the LED pin explicitly as GPIO2 instead of relying on LED_BUILTIN.

Quick Facts

  • PlatformIO first auto-detected COM3, and the user later confirmed COM3 was the correct port. [#20791782]
  • The working PlatformIO proposal used upload_speed = 115200, monitor_speed = 115200, and upload_resetmethod = nodemcu. [#20795458]
  • The successful flash log identified an ESP8266EX with a 26MHz crystal and wrote 265648 bytes in 17.1 seconds. [#20800473]
  • The serial monitor was opened at 115200 8-N-1, yet reset output still appeared as garbage before the final diagnosis. [#20800431]
  • Blink started working only after the LED pin was set explicitly to GPIO2 (pin = 2). [#20800674]

1. Why does PlatformIO in VS Code show "Failed to connect to ESP8266: Timed out waiting for packet header" when uploading to an ESP-01S?

PlatformIO showed that error because esptool.py v3.0 opened COM3, kept retrying Connecting........, and never received a valid response header from the ESP8266. In this thread, the board compiled correctly, but the upload handshake failed before flashing started, so the problem was connection or reset behavior, not C++ compilation. [#20790596]

2. How should a USB-to-serial converter be connected to an ESP-01S for flashing, including GPIO0 and reset wiring?

Connect the USB-to-serial converter in the standard ESP-01S flashing arrangement, and short GPIO0 to ground before starting the flash process. The helper explicitly asked for that condition and showed a reference wiring image; the thread supports GPIO0 -> GND for flashing but does not provide a full written pin-by-pin reset schematic. [#20791321]

3. What should the platform.ini file look like for an ESP-01S using the esp01_1m board in PlatformIO?

A working platform.ini in this case kept platform = espressif8266, board = esp01_1m, and framework = arduino, then added upload_speed = 115200, monitor_speed = 115200, and upload_resetmethod = nodemcu. Earlier additions such as monitor_dtr = 0 and monitor_rts = 0 were tried first, but the final proposal included the reset method change. [#20795458]

4. How do I set the correct COM port manually in PlatformIO when auto-detection finds the wrong upload port?

Manually force PlatformIO to use the confirmed port, then verify the upload log says Using manually specified: COM3. In this thread, COM3 was the valid port, and the log changed from auto-detection to a manual selection message, which is the key check that the override took effect. [#20795150]

5. Which PlatformIO upload settings helped fix ESP-01S flashing in this case, such as upload_speed and upload_resetmethod?

The settings that helped were upload_speed = 115200, monitor_speed = 115200, and especially upload_resetmethod = nodemcu. That final platform.ini proposal was the turning point before the user reported that the program uploaded successfully instead of timing out waiting for the packet header. [#20795458]

6. What is upload_resetmethod = nodemcu in PlatformIO, and why can it help with ESP8266 uploads?

upload_resetmethod = nodemcu is a PlatformIO upload setting that changes how the board is reset into upload mode, using a NodeMCU-style reset sequence rather than leaving reset behavior implicit. In this thread, changing to that reset method, together with 115200 upload speed, moved the ESP-01S from repeated timeout failures to successful flashing. [#20795458]

7. What does "Timed out waiting for packet header" mean in esptool.py for an ESP8266?

It means esptool.py started the serial connection but did not receive the expected first response packet from the ESP8266. "Packet header" is the initial serial-response marker that starts an ESP8266 upload exchange, confirming the chip is answering in the required communication state. In the thread, the tool stayed in repeated Connecting... attempts and then aborted. [#20790596]

8. Arduino IDE vs PlatformIO for ESP-01S uploads: what settings differ and why can a sketch upload in Arduino but fail in PlatformIO?

In this case, Arduino IDE used Generic ESP8266 Module, while PlatformIO used a separate esp01_1m environment and needed extra upload tuning. That difference changed defaults enough that Arduino uploads worked as a reference, but PlatformIO still needed explicit reset and speed settings before it would flash the same ESP-01S reliably. [#20800540]

9. How can I check whether an ESP8266 sketch was actually flashed successfully if PlatformIO reports SUCCESS but the program seems not to run?

Check the upload log for chip detection, byte counts, verification, and reset. In the successful run, PlatformIO reported Chip is ESP8266EX, Crystal is 26MHz, wrote 265648 bytes, verified the hash, and ended with Hard resetting via RTS pin plus [SUCCESS] Took 27.44 seconds. Those lines confirm the flash completed. [#20800473]

10. Why does the serial monitor on an ESP-01S show garbage characters after reset even when monitor_speed is set to 115200?

In this thread, garbage text at 115200 8-N-1 suggested the expected sketch output was not actually running, even though the monitor speed matched the configured speed. After the user confirmed 115200 in both code and monitor, the next diagnosis was blunt: the program looked not to have loaded correctly after all. [#20800469]

11. How do I reset an ESP-01S after uploading so the new firmware starts running normally?

Do a system reset immediately after upload, then watch the serial monitor and the LED behavior. In this case, a helper advised a system reset, but reset alone did not solve the issue, which proved that a clean restart is necessary yet not sufficient when the upload sequence or LED pin selection is still wrong. [#20800378]

12. Which LED pin should I use for Blink on an ESP-01S in PlatformIO, and why might LED_BUILTIN not work as expected?

Use GPIO2 for Blink on this ESP-01S setup. The original code used LED_BUILTIN, but the LED still did not blink after a successful upload; once the pin was defined explicitly and then corrected to 2, the Blink test worked, showing that the built-in alias did not match this hardware/profile combination. [#20800674]

13. Why did defining the LED pin explicitly as GPIO2 make the Blink sketch work on the ESP-01S?

Defining the pin as GPIO2 made Blink work because that was the actual LED-controlled line on this board setup. The user first relied on LED_BUILTIN, saw no blink, then changed the code to an explicit pin and reported success with pin = 2, which removed the board-definition ambiguity. [#20800674]

14. What is the difference between selecting Generic ESP8266 Module in Arduino IDE and esp01_1m in PlatformIO?

The practical difference in this thread was the board profile and its defaults. Arduino IDE worked with Generic ESP8266 Module, while PlatformIO used the esp01_1m environment name; that change affected behavior enough that PlatformIO needed extra upload settings and an explicit LED pin before the same simple Blink logic matched the hardware. [#20791782]

15. How can I troubleshoot an ESP-01S that uploads successfully in PlatformIO but still does not blink or start the expected program?

Use this 3-step check: 1. Confirm the flash log shows chip detection, byte writes, hash verification, and SUCCESS. 2. Reset the module and watch the serial monitor at 115200. 3. Test Blink with an explicit LED pin, and on this setup use GPIO2. That exact last change turned a "successful" but non-blinking upload into a working result. [#20800674]
Generated by the language model.
ADVERTISEMENT