Serial.print buffer - can it over flow

If my code has extensive Serial.print calls but no serial monitor connected can it cause any sort of overflow? I am asking if the serial output is cached waiting a connection.

I do note that the establishment of a serial monitor session on an already running device does seem to cause a sort of reset / restart

It depends on which Arduino.

Basic AVR Arduinos like the UNO will reset each time they detect a serial connection (on USB).

More advanced ones like the Micro and DUE will cache a small amount. It never overflows although I do have one project on a DUE which halts if you unplug the USB while it's operating. I never worked out why; I just reset power after unplugging.

Arduino Mega 2560 Clone. It is happy to have the USB connected and disconnected without any interruption, however opening the serial monitor does cause an apparent restart.

I was just pondering on the issue and wondering if I should disable calls to Serial.print in the release code as there will not be a serial monitor (or USB) connection in normal operation.

So I am coding:

define SERIAL_MON true // true/false

. . . . if (SERIAL_MON) Serial.print("Hello world etc"); // as needed.

If your coding habit is consistent, a simple text editor find/replace “Serial.print” with “//Serial.print” would be easy to implement.

Reduces your complied code size and processing cycles so Win/Win.

on Mega the Serial data are transferred to USB chip (ATmega16u2 on R3), no matter if it has an USB connection or not.

@Slumpert, replace is the worst option. intelligent solution is to use a macro like DEBUG_PRINT(msg)