I am trying out IDE 2 using an Arduino UNO and I get strange behavior with the serial monitor. If I try to use print() or println() in setup(), I get a line of garbage before I get the correct text, I know the BAUD rate is correct because my text prints after the garbage.
I found I can stop the initial garbage if I put a delay(2000); before the first print statement.
Any ideas on how to fix this? It seems like a bug in IDE 2.
Hi @KQRR4449. Thanks for your report. The Arduino IDE developers are tracking this bug here:
If you have a GitHub account, you can subscribe to that thread to get notifications of any new developments related to this subject:
Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.
The workaround you found of adding the delay is the best one I am aware of.
The only other workaround I know of is to use a Arduino IDE 1.x (the bug seems to be specific to Arduino IDE 2.x).
I see this with the ESP devices even on the older IDEs, and yes the 2 second delay solves that problem. I posted something on that on this forum and another a few years back. Nobody has corrected me so I am assuming this is correct.
What I think is happening is the processor is sending diagnostic messages while it is uploading and booting. This is at its default baud. When the IDE is finished uploading and determines it is successful it 'connects' the output of the board to the terminal.
The ESP board has acknowledged the successful load but prints a few more messages, the IDE switches when the upload is successful and changes its baud to what you set. When the ESP finishes it switches baud to what you set and everything is gold. What you are seeing is the tail end of the diagnostic messages before the ESP switches to your code and starts running it.
If you do not specify the baud rate, the default baud rate is 460800. If you need to specify the baud rate, replace BAUD with the baud rate you need. IE Serial.begin(115200) which is also the default user baud.
This is correct for the ESP microcontrollers. However, @KQRR4449 is using an UNO board. The ATmega328P microcontroller of the UNO does not print any diagnostic messages, so it is not applicable in this specific case.
Of course even the UNO is certainly transmitting data during the upload process, but I don't think the garbage we are seeing is coming from that. The reason is this distinctive characteristic of the fault: