Unprintable junk at start of Serial.print()

When I use Serial.print() or Serial.println() I get a random number of unprintable characters (small squares) at the beginning of the first line. I suspect I have some sort of initialization problem but the examples I've seen look the same to me.

Aurdino Uno R3, current IDE (2.3.2). Code and output follows.

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Serial.println ( "***** initial output line, begins/ ends with *****");

}

void loop() {
}

The output has a variable number of small squares displayed and then the actual output. Unfortunately the small squares won't copy/paste so I'm showing the bottom right corner of the serial monitor. You can see that the baud rate is correct (9600) and the "junk"

image

I had the same. It's due to the step down of baud rate to 9600 while the sketch is loading. Press the reset button to run the code that's already installed and there's no box characters.

Add a delay of a few seconds after the Serial.begin(9600); so the connection can be made BEFORE beginning the data transmission!

Thanks, adding the delay worked.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.