Color Messages to Terminal via Serial Monitor

I currently output status messages during arduino development (using vs code) to Platformio’s Terminal via the arduino’s serial monitor print and println commands and everything works just fine. I would like to highlight certain critical messages by prefixing them with a code string that would produce a color message.

Is this possible? If so, would you please point me in the right direction so I could implement color messages to the Platformio terminal.

I notice that when compiling a module, one of the first things to appear on the Platformio Terminal is the module name IN COLOR! - exactly like what I am trying to do. So it seems to be possible. I just don’t know how the module name was produced in color.

Thank you…

Duplicate of Some bizare characters prints on serial monitor with ESP-IDF hello world example – basically you’re looking for how to transmit ANSI color codes from the firmware and have them displayed correctly in the VSCode terminal.

Thanks MAX…

In detail, what I did was append ‘monitor_flags = --raw’ to the end of my platformio,ini, then prefixed the critical messages with “\e[1;31m” and suffixed them with “\e[1;37m” and, voila, red messages…


Using monitor_flags = --raw does indeed work to get colored messages in the terminal, but it does have an ugly side effect - Log files requested by setting:

monitor_filters =

are being created, but remain completely empty!

Can I get both colored messages and a full log file?

(IDF framework produces a lot of such colored debug messages, which are nice in colors and awkward to read otherwise)

For anyone else coming to this in 2023, the monitor_flags property is no longer available. Instead there is a dedicated monitor_raw = yes property you can set.


awesome, thanks a lot!