Serial Port debug printing - library recommendation

I found a nice library, advancedSerial, for debug printing to the Serial Monitor port. I’ve tested it successfully in both VSCode (250k baud) and the Arduino IDE (500k baud) and printing in the Serial Monitor.

I’m still looking into other alternatives. I’d still like a printf-like solution that supports Flash properly and does not become a memory hog (e.g. format strings).

You can add it to the Arduino IDE via “Include Library” (which will be picked up by VSCode). It works well with the existing Blinks ServicePortSerial class, and it supports using Flash for text strings, chaining method calls, as well as controlling what’s displayed quite easily!

Here’s an example (I modified one that comes with the library so it uses the ServicePortSerial Print class and demonstrates chaining too):

#include “Serial.h”
#include “advancedSerial.h”

advancedSerial aSerial;
ServicePortSerial sp;

void setup() {
sp.begin(250000); // kenj: mod to support 250k baud for VSCode

// Specify to use our SerialPortMonitor

/* Uncomment the following line to disable the output. By defalut the ouput is on. */

void loop() {
// This message will be printed
aSerial.v().println(“Level v() is less verbose than the filtering threshold”);

// This message also will be printed
aSerial.vv().println(“Level vv() is equal to the filtering threshold”);

// Chaining calls
aSerial.v().p(“Level v() using shortened name”).p(" and chaining").p(" multiple prints");

// This message won’t be printed
aSerial.vvv().println(“Level::vvv is more verbose than the filtering threshold”);

// This message won’t be printed
aSerial.vvvv().println(“Level::vvvv is more verbose than the filtering threshold”);

// Consider storing long strings on flash memory rather than RAM using F() macro
aSerial.v().pln(F(“This string will be stored in flash memory”));

// Two empty lines


This is a really cool library. Definitely handy for some quick filtering of debug messages. It is not my favorite syntax, but I understand the idea of few keystrokes and chaining. Part of me would prefer to see verbosity level passed as a parameter and otherwise fall back on a default value. That said, the vvv structure might be more glanceable for developers. I’ll be curious to see if our advanced users are using this tool, if so we can adopt something that suits this need.

Yeah, not my favorite syntax either. I’m working on a “printf” syntax version as I write.

I completed development of a new LogSerial class which supports a printf style log messaging. It’s been uploaded to my git branch and a pull request submitted.

Details here: Using LogSerial with results