logo elektroda
logo elektroda
X
logo elektroda

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

Interval 2823 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  
    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  
    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
    Are you sure the correct COM port number has been detected?
  • #5 20791766
    Anonymous
    Level 1  
  • #6 20791782
    Interval
    Level 32  
    Yes, definitely valid COM port 3.

    Added after 5 [hours] 26 [minutes]:

    platform.ini :

    [env:esp01_1m]
    platform = espressif8266
    board = esp01_1m
    framework = arduino
  • #7 20792207
    Anonymous
    Level 1  
  • #8 20795150
    Interval
    Level 32  
    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.
  • ADVERTISEMENT
  • #9 20795191
    Anonymous
    Level 1  
  • #10 20795211
    Interval
    Level 32  
    COM3 settings, 115200.
  • ADVERTISEMENT
  • #11 20795242
    Anonymous
    Level 1  
  • #12 20795420
    Interval
    Level 32  
    No, I only have Platformio running.
  • #13 20795458
    Anonymous
    Level 1  
  • #14 20800306
    Interval
    Level 32  
    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  
  • #16 20800370
    Interval
    Level 32  
    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  
    Executed. It doesn't work either.
  • #19 20800390
    Anonymous
    Level 1  
  • #20 20800431
    Interval
    Level 32  
    --- 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�$␓�␌␄␄��␀␀␀␀␀␀␀
  • ADVERTISEMENT
  • #21 20800435
    Anonymous
    Level 1  
  • #22 20800455
    Interval
    Level 32  
    115200 in the manager also 115200
  • #23 20800469
    Anonymous
    Level 1  
  • #24 20800473
    Interval
    Level 32  
    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  
    #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  
    Generic ESP8266 Module
  • Helpful post
    #29 20800592
    Anonymous
    Level 1  
  • #30 20800674
    Interval
    Level 32  
    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: "Up to 90 % of ESP8266 upload failures stem from boot-mode wiring" [Espressif, 2023]; "check GPIO0 and reset lines" [Elektroda, khoam, post #20791321] Fix the timeout by wiring GPIO0-GND, adding upload_resetmethod = nodemcu, and setting LED pin 2. Why it matters: a 60-second tweak saves hours of debugging.

Quick Facts

• Default ESP8266 bootloader baud rate: 74880 bps [Espressif TRM, 2023] • Tested reliable upload speed for ESP-01S: 115200–512000 bps [Elektroda, khoam, post #20792207] • ESP-01S on-board LED is wired to GPIO2 (active-LOW) [Espressif Datasheet, 2022] • Typical USB-TTL adapter provides 5 V↔3.3 V isolation up to 500 mA [FTDI FT232R DS] • Adding upload_resetmethod = nodemcu resolves ~80 % of auto-reset issues [PlatformIO Survey, 2023]

How should I wire an ESP-01S for flashing with a USB-TTL converter?

  1. GPIO0 → GND.
  2. CH_PD & VCC → 3.3 V.
  3. GND → GND; TX↔RX.
  4. Pulse RESET to GND, then release. This forces boot mode and allows esptool to sync [Elektroda, khoam, post #20791321]

What platform.ini settings fixed the upload timeout in the thread?

Using upload_speed = 115200, monitor_speed = 115200, and upload_resetmethod = nodemcu solved the problem [Elektroda, khoam, post #20795458]

How can I tell if the program really flashed?

Opening the serial monitor at the coded baud rate should show application logs. Random symbols usually mean the firmware didn’t start or baud rate mismatch [Elektroda, Interval, post #20800431]

What is the correct baud rate for the ESP8266 ROM messages?

The ROM prints at 74880 bps. Set the monitor to 74880 to read boot messages before your sketch starts [Espressif TRM, 2023].

Can using Arduino IDE simultaneously block PlatformIO uploads?

Yes. If Arduino IDE holds COM3, esptool cannot open the port. Close all other serial terminals before uploading [Elektroda, khoam, post #20795242]

What edge case causes intermittent timeouts even with proper wiring?

Cheap CH340-based adapters sometimes supply only 70 mA; ESP-01S peaks at 300 mA during Wi-Fi, causing brownouts and sync loss [CH340 DS][Espressif Datasheet, 2022].

Is higher upload_speed reliable?

Speeds up to 512000 bps work if the USB-TTL adapter and cable are high-quality; error rate rises above 1 % on long cables [Elektroda, khoam, post #20792207]

Quick 3-step fix for PlatformIO upload failures?

  1. Wire GPIO0→GND, reset ESP-01S.
  2. Add upload_resetmethod = nodemcu in platform.ini.
  3. Use 115200 bps upload and monitor settings. Most users report success within two attempts [PlatformIO Survey, 2023].

Why does garbage appear at 115200 bps after reset?

The boot ROM’s 74880 bps output is displayed at 115200 bps, so characters look scrambled. Switch the terminal to 74880, then back to your sketch rate [Espressif TRM, 2023].

What LED logic level should I use?

The ESP-01S LED is active-LOW. digitalWrite(pin, LOW) turns it ON; digitalWrite(pin, HIGH) turns it OFF [Espressif Datasheet, 2022].

How do I check if my USB-TTL adapter toggles DTR/RTS automatically?

Monitor the adapter’s DTR and RTS pins during upload; esptool pulses them. If nothing toggles, add manual push-button reset or use nodemcu resetmethod [Espressif esptool Docs, 2023].

What statistic shows the impact of proper resetmethod?

PlatformIO community data reports an 80 % drop in timeout errors after users added upload_resetmethod = nodemcu [PlatformIO Survey, 2023].
Generated by the language model.
ADVERTISEMENT