Serial console full of binary data

I am debugging some code, and sometimes (but not always) the console just returns “random” data like this:


(there is some plaintext in the second screenshot)

do you have an idea how this could happen? What do I have to look for to fix it?

EDIT: Using Serial with: Serial.begin(9600);

Coffee, is the output on the Spark’s Serial1 or Serial ports? What baudrate are you using?

I am Using Serial with 9600 baud: Serial.begin(9600);

The problem looks like:

  1. The linux com port is not set to 9600, or
  2. The linux port is not set for 8bits, 1 stop bit, No parity, or
  3. The connecting wires are loose or poorly connected, or
  4. The Spark is under-powered via the USB connector for some reason (not enough current or voltage or both).

Check the first three and if you can, power the Spark from a different power supply than the USB (if you are not doing so already). :smile:

I believe it was due to variables not beeing initialized are or accessing pointers that point to old/freed memory. … still testing …

i have the feeling that Serial.print() prints a not-initialized String and after dumps the whole memory. Just an idea. :smile:

Yeah, looks like bad pointers. Can you post your code? Also, do the checks @peekay123 recommended.

My mama always told me never to point… with bad pointers that is!