[SOLVED] SD library prints to Serial, not SerialUSB


I’m doing some stuff with the Sodaq ONE, and used the standard SD library from the Arduino IDE. I tried some of the examples and find out that I was having no output on them. After a bit of research, I realised that for example printDirName() uses Serial.print by default, and that was the reason why I was not getting output.

Is there a way to stop this behaviour that doesn’t involve going through all the library files and changing it by hand? I’m worried of a) not getting output and having to review each and every file before using it, and B) code writing to Serial (which is used by the modem, if I am not mistaken) and sending data that I don’t want to send.



You need to change them by hand if you want to use Serial AND SerialUSB.
If you only need SerialUSB and not Serial you can override Serial.

#define Serial SerialUSB


Damn! That was so obvious it hurts!

As a matter of fact, I just used that same piece of code in a different example and didn’t even thought about applying it to this case.

Thanks for your quick reply!