Strange characters in serial monitor

41 Views Asked by At

I started seeing strange characters like this...

got code >���?␟<

...printing out in my serial monitor when using this code...

Serial.printf("got code >%s<\n", code);

This was despite my unit tests telling me that the (Arduino) String code actually contained printable characters (alpha-numerics and simple punctuation).

It wasn't happening for all my printf statements, but would consistently happen with the same ones.

1

There are 1 best solutions below

3
OutstandingBill On

The problem went away when I broke Serial.printf into a series of Serial.print statements, e.g.

Serial.print("got code >");
Serial.print(code);
Serial.println("<");

I still haven't figured out why, unfortunately, but I hope this saves you some time.