My esp8266 it´s having an error to connect when i write his code:A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for packet header

CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp12e.htmlPLATFORM: Espressif 8266 (4.0.1) > Espressif ESP8266 ESP-12E
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:

  • framework-arduinoespressif8266 @ 3.30002.0 (3.0.2)
  • tool-esptool @ 1.413.0 (4.13)
  • tool-esptoolpy @ 1.30000.201119 (3.0.0)
  • tool-mklittlefs @ 1.203.210628 (2.3)
  • tool-mkspiffs @ 1.200.0 (2.0)
  • toolchain-xtensa @ 2.100300.210717 (10.3.0)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 48 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- CmdParser @ 0.0.0+sha.dcaa7ea
    |-- LittleFS @ 0.1.0
    |-- ota
    | |-- ArduinoOTA @ 1.0
    | | |-- ESP8266WiFi @ 1.0
    | | |-- ESP8266mDNS @ 1.2
    | | | |-- ESP8266WiFi @ 1.0
    |-- Wire @ 1.0
    |-- i2cscan
    | |-- Wire @ 1.0
    |-- mpu6050
    | |-- math
    | |-- i2cdev
    | | |-- Wire @ 1.0
    |-- magneto
    | |-- math
    |-- math
    |-- i2cdev
    | |-- Wire @ 1.0
    |-- ESP8266WiFi @ 1.0
    |-- bmi160
    | |-- i2cdev
    | | |-- Wire @ 1.0
    |-- bno055_adafruit
    | |-- math
    | |-- Wire @ 1.0
    |-- bno080
    | |-- SPI @ 1.0
    | |-- Wire @ 1.0
    |-- SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library @ 1.2.9
    | |-- SPI @ 1.0
    | |-- Wire @ 1.0
    |-- mpu9250
    | |-- math
    | |-- i2cdev
    | | |-- Wire @ 1.0
    Building in release mode
    Retrieving maximum program size .pio\build\esp12e\firmware.elf
    Checking size .pio\build\esp12e\firmware.elf
    Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
    RAM: [==== ] 43.2% (used 35368 bytes from 81920 bytes)
    Flash: [==== ] 40.4% (used 422359 bytes from 1044464 bytes)
    Configuring upload protocol…
    AVAILABLE: espota, esptool
    CURRENT: upload_protocol = esptool
    Looking for upload port…
    Auto-detected: COM3
    Uploading .pio\build\esp12e\firmware.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
========================= [FAILED] Took 30.13 seconds =========================

  • The terminal process “C:\Users\Thici.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.

Is COM3 the right port?

Have you put your board into bootloader mode by holding down the FLASH/BOOT button, pressing the reset button, and releasing the flash/boot button?

I don’t know where to change the port in studio code, normally i use the arduino ide to program, how can i see?

Just plug one esp at a time to be sure which one is being programmed if you have multiple,
and when programming esp, you need to press a button called “boot” if not wrong .
Do you use esp stand-alone module or on a dev board ?

https://docs.platformio.org/en/latest/projectconf/section_env_upload.html#upload-port