After compilation, it was confirmed that there were no problems. However, when uploading, this error message appears.
esptool.py v3.0
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: bc:dd:c2:5e:72:35
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
A fatal esptool.py error occurred: Timed out waiting for packet header
That can mean that the compiler is having problems with the serial communication with the chip.
There can be gazillion reasons:
silly things like the usb cable not being good enough - try different cables
if you have many sensors attached the board may not be getting enough power - detach everything from the board first
on some boards you also need to keep the "boot" button pressed while uploading the code.
for some boards or if you are using an uploader usb "dongle" you also need to have correct drivers installed like FTDI, CH304x, SiLabs CP210x...
the upload baud rate can be too high/low
sadly some knockoff boards can simply be duds and don't work
I've experienced all these situations in some way or another, even on one really crap board I had to keep the "boot" button pressed then plug the board in the computer and keep the boot button pressed until the upload is finished.
Hop this gives you some ideas to try