How to keep the first text line in the serial monitor?

Hello, teachers and friends,

I think Arduino is easy ,but difficult. I have a problem about the serial monitor.

I’d like to know how to continuously keep the first text line which describes the data into the serial monitor?

for example of serial monitor;

AX BX CX // first text line
0 0 0 // input data (1 data per 1sec)
1 1 1 // input data (1 data per 1sec)
2 2 2 // input data (1 data per 1sec)
0 0 0
1 2 3
1 3 2

But, as you know, the first text line will be disappeared in the serial monitor after about 30sec…
I want to see the first text line for data and the newest data at the same time.

In general, the source code as follows.
This is the example in the Arduino program.

void setup()
while (!Serial) {


Serial.print(“Initializing SD card…”);

if (!SD.begin(chipSelect)) {
Serial.println(“Card failed, or not present”);

Serial.println(“card initialized.”);

Serial.println(“AX, BX, CX”); // first text line for data, how to continuously keep?

void loop()

String dataString = “”;

for (int analogPin = 0; analogPin < 3; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += “,”;

File dataFile =“datalog.txt”, FILE_WRITE);

if (dataFile) {


else {
Serial.println(“error opening datalog.txt”);

I’m very appreciate if you prompt reply.
Thank you in advance.

Using a terminal app like HTerm, you can set a ‘clear at’ byte. So you can refresh your output keeping the structure you desire.

By sending the clear byte when you need to refresh the display, you can simply print the header and then your data.

The serial monitor does not, and most probably never will support this (Has been discussed and dismissed).