Serial Monitor printing funny chars

Hi,

I was working on a project and found that suddenly things that I printed to the Serial Monitor were showing strange characters.

I created a new super-simple sketch, and it's still happening.

This is my code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Hello World!");
}

void loop() {
  // put your main code here, to run repeatedly:
}

And this is what is shown in Serial Monitor:

I suspect it's something to do with the serial buffer, but I really don't know. I've unplugged the board from my PC and plugged it in again, doesn't seem to make a difference.

In fact, I'm seeing that when I upload a new sketch, the Serial Monitor continues to show me characters that were printed to the Serial Monitor from the previous sketch. See my screenshot below - 'Hello World!' is not mentioned anywhere in the sketch that is now running in my board.

image

Any ideas?

On some Arduinos, the IDE reboots and then reconnects the serial monitor after upload, so the program starts twice.

The first "Hello World" probably came from the previous program, before the new program was uploaded.

Spurious characters on startup can be expected until the PC operating system stabilizes all the connections. This usually helps:

  Serial.begin(9600);
  while (!Serial);  //wait for connection to be established
  Serial.println("Hello World!");
1 Like

Thanks @jremington , but this behaviour hasn't stopped. I even burned the bootloader, but it still prints out funny characters (funnily enough now it's before Hello World!. I connected another (generic) Uno, and it's working fine (see attached screenshot - first 5 attempts are with problematic board, last two are with another board) so it can't be the PC.

Do you think it could be a hardware failure?

That is the PC OS. It should happen only once on startup. I learned to live with it.

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