logo elektroda
logo elektroda
X
logo elektroda

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

Interval 1353 30
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
    khoam
    Level 42  
    How do you have the USB converter connected to the ESP-01S module? What kind of converter is it? Is the GPIO 0 pin shorted to ground before starting the flashing process?

    Yes, it should roughly look like this:

    ESP-01 module connection diagram with USB to TTL converter. .
  • #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?
  • ADVERTISEMENT
  • #5 20791766
    khoam
    Level 42  
    What does the platform.ini file look like?
  • #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
    khoam
    Level 42  
    I suggest slightly modifying the platform.ini:
    Code: Ini
    Log in, to see the code
  • #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.
  • #9 20795191
    khoam
    Level 42  
    Interval wrote:
    When using the arduino it works.
    How are the settings in the Arduino IDE?
  • #10 20795211
    Interval
    Level 32  
    COM3 settings, 115200.
  • #11 20795242
    khoam
    Level 42  
    Just a question to avoid guesswork: when you do the upload from PlatformIO, is the Arduino IDE also running and COM3 set?
  • #12 20795420
    Interval
    Level 32  
    No, I only have Platformio running.
  • #13 20795458
    khoam
    Level 42  
    This is my final platform.ini proposal:

    Code: Ini
    Log in, to see the code
  • #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
    khoam
    Level 42  
    Interval wrote:
    but it doesn't run.
    And how do you know it doesn't run?
  • ADVERTISEMENT
  • #16 20800370
    Interval
    Level 32  
    I uploaded the Blink program, the diode should blink - just like on the Arduino, it doesn't.
  • ADVERTISEMENT
  • #18 20800380
    Interval
    Level 32  
    Executed. It doesn't work either.
  • #19 20800390
    khoam
    Level 42  
    What is displayed in the serial port monitor after a reset?
  • #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�$␓�␌␄␄��␀␀␀␀␀␀␀
  • #21 20800435
    khoam
    Level 42  
    What speed do you have set for Serial in the program code?
  • #22 20800455
    Interval
    Level 32  
    115200 in the manager also 115200
  • #23 20800469
    khoam
    Level 42  
    It looks like the programme didn't load after all.
  • #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
    khoam
    Level 42  
    Please post the code for this program that you upload to the ESP.
  • #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
    khoam
    Level 42  
    Interval wrote:
    When using the arduino it works.
    With what variant of the selected board in the Arduino IDE?
  • #28 20800540
    Interval
    Level 32  
    Generic ESP8266 Module
  • Helpful post
    #29 20800592
    khoam
    Level 42  
    Try defining the 'pin' variable explicitly as 1 in the code and then reload the programme and run.
  • #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.
Summary generated by the language model.
ADVERTISEMENT