Arduino 2.0.2 - Maybe Past Versions - Serial Monitor

This may not be just 2.0.2 as I am just trying to debug an UNO program using the serial monitor. I need to print out a fixt list of global variable values that are constantly being updated as the program runs. I need a control or escae code that clears the screen and prints the list over and over so I don't have a continuously scrolling screen which are impossible to keep up with. The program has 6 operational modes that are selected by the operator by keypad. The variables are related to I/O conditions that are continuously read and updated by a several functions called in timer driven loops. I need to be able to see what the variable values are within the currently selected mode of operation. The timer loop are created Neotimer loop counters driven by the ms clock.

Any suggestions would be appreciated.

Thanks,
Preston

You can not clear the screen of the serial monitor with a command from the board.

What you can do is use an 3rd party terminal program that supports ANSI escape codes [edit]and send those from your board[/edit]. Note that only one program can use the serial port at a time. So it's either the IDE or the 3rd party program; connection from the 3rd party terminal program needs to be closed before you can do an upload.

Be aware that serial prints can become blocking if you print too much. High baud rate and only printing changed data are ways to reduce that problem (but not necessarily eliminate it).

Your topic has been moved to a more suitable location on the forum as this is not a problem with the IDE 2.0.

Thank You!

The ability to clear the screen and reprint values so they do not continuously scroll would be a great help when debugging!!
If there is another way to accomplish this I would be grateful to learn how this could be done!
Sorry if this is in the wrong place in the Forum. Please advise where it has been moved.

Thanks
Preston

I'm reasonably sure that requests have been made in the past (at least for 1.8.x, possibly for 2.0 as well) to support ANSI Escape sequences in the Serial Monitor.

There are two points

  1. Serial Monitor needs to support it which is not the case.
  2. Some extra code preferably needs to be added to the Serial class so it can tell the Serial Monitor what to do; this is actually outside the purpose of the class so a derived class will be needed.

So the solution is to look at ANSI escape sequences yourself and use a 3rd party terminal program that supports ANSI escape sequences; e.g. TeraTerm or RealTerm under Windows.

Below are two functions that you can use with 3rd party terminal programs that support ANSI escape sequences.

/*
  clear the screen
*/
size_t clearScreen()
{
  return Serial.print(F("\x1B[2J"));
}

/*
  place cursor at top left
*/
size_t goHome()
{
  return Serial.print(F("\x1B[1;1H"));
}

Wherever you want to clear the screen, call them

void loop()
{
  Serial.println("Hello");
  delay(1000);
  clearScreen();
  goHome();
  delay(1000);
}

You can make it all a lot neater by positioning the cursor to a position where you want to print and only change what is needed.

Reference (there are more): ANSI escape code - Wikipedia

Look under your topic title :wink:
image

Thank you for al of your time and responses!!!
Much appreciated!!!

The brew system is working well with external PID control of heating and cooling. I am now working to handle and display temp control using max 31865s and p100 rtds.
Having difficulty getting two to work together. That's where I need the debug displays.

Thanks again!
Preston