Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Spurious output in Serial Monitor after upload #927

Open
arduino/serial-monitor
#32
Labels
criticality: lowOf low impact topic: CLIRelated to Arduino CLI topic: codeRelated to content of the project itself topic: serial monitorRelated to the Serial Monitor type: imperfectionPerceived defect in any part of project
@per1234

Description

Describe the problem

The first output printed to Serial Monitor after an upload is some "garbage" characters.

image

To reproduce

Equipment

  • Arduino board that uses the ATmega16U2 USB chip:
    • Arduino Uno
    • Arduino Uno Mini
    • Arduino Mega

Steps

  1. Upload a sketch to your board that prints to Serial:
    void setup() {
     Serial.begin(9600);
     Serial.println("hello world");
    }
    void loop() {}
  2. Open the "Serial Monitor" view.

🐛 The output starts with some unexpected content:

しろいしかくしろいしかくしろいしかくしろいしかくしろいしかくしろいしかくしろいしかくしろいしかくしろいしかくしろいしかくしろいしかくhello world

Expected behavior

Serial monitor output always reflects the data sent by the board.

Arduino IDE version

Original report

2.0.0-rc5-snapshot-4de7737

Last verified with

c3adde5

Operating system

Windows

Operating system version

  • 10
  • 11

Additional context

The number of しろいしかく in the demonstration matches the number of characters that are printed by the sketch.


The spurious output does not occur when the output is triggered by resetting the board, so it is specific to the upload operation.


The issue does not occur when using Arduino IDE 1.x


I have only been able to reproduce this issue with the Arduino boards that use an ATmega16U2 USB to serial adapter chip.

I could not reproduce it when using boards with other USB interfaces:

  • Native USB (Leonardo, Nano 33 IoT)
  • FTDI FT232R (Nano, Pro Mini)
  • WCH CH340 (3rd party boards)

Originally reported at https://forum.arduino.cc/t/serial-monitor-contains-garbage-after-upload/972312

Additional reports

Related

Workaround

Add a delay before the first Serial.print (etc.) call:

void setup() {
 Serial.begin(9600);
 delay(2000);
}
void loop() {
 Serial.println("hello");
 delay(1000);
}

i The choice of 2000 ms for the delay in the snippet above is somewhat arbitrary. You might find that a shorter delay will also serve (1000 ms works for me). Or you might even find that 2000 ms is not sufficiently long. You can do some experimentation to determine the shortest delay that will reliably prevent the garbage output on your system.


Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Labels

criticality: lowOf low impact topic: CLIRelated to Arduino CLI topic: codeRelated to content of the project itself topic: serial monitorRelated to the Serial Monitor type: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /