PlatformIO Community

Inability to get a serial connection

This is what I get after the software detects the COM port in use:

Serial port COM4
Connecting....

A fatal error occurred: Timed out waiting for packet header
*** [upload] Error 2
The terminal process "C:\Users\Greg\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.
------------ 

What steps do I need to do to correct this? I am new to the program, but absolutely love what I see and would like to continue using it.

Thanks

Sorry, Vital info needed: Win10x64, desktop PC, Have tried both CMD and Powershell. I get replies from the board itself when I select the serial monitor icon at the bottom of the window. I got replies when I edited PIO ini file.

What board (buy link)? are you using with what platformio.ini? If it’s an ESP8266 or ESP32, have you manually put it into bootloader mode (FLASH and RESET)?

It is a WEMOS D1 ESP32 chip. I have tried a generic ESP board as well. I can program the board via ArduinoIDE on either of my two COM ports. The terminal shows Com back from the board, but obviously, the board isn’t getting programmed by PlatformIDE. I have reset the board repeatedly. It shouldn’t have to be in FLASH mode, if I understand the board correctly.
I did have to adjust the Platformio.ini to allow for coms at 115200, and that com rate works fine.
I was thinking of using an external Terminal program?? Like the built-in WIN10 terminal program?

By default PlatformIO will try a upload baud rate of

When you select this speed in the Arduino IDE, does the upload also not work?

It appears to try to com at that rate, but it doesn’t give anything but gibberish.
It looks like Chinese and numbers.

Where would I adjust the Com speed in PlatformIDE? In the .ini file?
I have set monitor_speed - 115200, but that only seems to adjust the comms between the board and the built-in terminal.

I found the file:
\users…\platforms\espressif32\boards\wenis_d1_mini32.json
Modified the “speed”: 115200 but it didn’t work. Restarted VSC and still no go on that parameter.

The flashing / upload speed via the serial bootloader can be adjusted using upload_speed (docs), the baud rate for the serial monitor is monitor_speed. Since you have problems uploading, you need play with upload_speed.

Thanks, going to those docs now.

This is what my .ini file contains now:
[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
; Serial Monitor options
monitor_speed = 115200
;upload options
upload_speed = 115200

I also tried a slower speed, but this speed works fine in arduinoIDE and is my default there.

arduinoIDE com port can be set to 500000 and I have used that successfully on existing code.
FYI. 460800 in PIO didn’t work likely because of that difference.

I’ve made the experience that is a good practice to fix transmission rates in platformio.ini
as well as in your code - otherwise you rely on externally set values that are not controlled by you and could change without your intervention.

1 Like

You sure that’s 500000, and not 512000? :stuck_out_tongue: As I can pretty much guarantee that one will work, and the other won’t! :laughing:

image

Another thing to be aware of is the question of whether the upload process on the Arduino IDE is actually running at that speed or not. As I know the esptool uploader on the esp8266 automatically reverted to 460800 if you try to specify a speed above that (not sure if it still does that or not)… perhaps the ESP32 uploader does the same… you have to check the output of the upload to see what speed it actually uses.

If you are ‘seeing gibbeish’ … you need to set the monitor_speed to the same as your Serial.begin() speed. If the upload is failing, you need to look factors such as is the upload_speed too fast for that board/your development environment, is the right COM port being used, is the cable/connector dodgy, and is the board resetting properly - sometimes the auto-reset is a bit dodgy.

1 Like

Thank you. I need to give up on this software. The upload speed on the ArduinoIDE is set at 921600 like you show in the provided figure. I will try that speed in the upload settings on PlatformIO IDE and see if that works.

I don’t like to give up, so I decided to load everything on a Win10 laptop that is only a year or so old.
I found the exact same issues, and the inability to program the Wemos D1. In addition, I tried a different board and the same error 1 or error 2 appeared. So, it isn’t a speed or hardware issue.