How to print continuously on the same line in Serial Monitor

I want to print continuously in the same line in Serial Monitor for a continuously changing output, how do I do that?

Serial monitor is a pretty lame terminal applet.

Try PuTTY or TeraTerm to get access to a more complete terminal emulator with line and page positioning as well as complete emulation protocols.

Your topic was MOVED to its current forum category which is more appropriate than the original as it is not an Introductory Tutorial

You cannot control the cursor position of the Serial monitor, hence the suggestion to use a more fully featured terminal emulator

You can use the screen command. Open a terminal and and install it with

sudo apt install screen

Then start it up with

screen /dev/ttyUSB0 57600

(but using whichever serial port and speed that you would use with serial monitor)

From your code, you can use

Serial.print("\r");

to return to the start of the current line without moving to the next line.

And wouldn't it be nice if IDE 2.0's soon-to-be Serial Monitor revamp added a terminal emulator mode that did some of the normal things a 70's terminal would do? Default mode would have to be similar to the IDE 1.x Serial Monitor, but there's so much more. Imagine being able to update the Serial Monitor window in an 80x25 character screen, with everything you need to display right there! Make it green text on black, instantly recognizable to anyone with grey hair. Wow, throwback indeed!

Just dreaming, I guess. OTOH, a green-black text screen might trigger my insomnia.

1 Like

Can you tell me about the code for windows

If you want control cursor trought serial port need a terminal emulator on PC side.
There are several emulatios types. the less complex is VT52 and the most used is ANSI.
See VT52 standard commands:
https://en.wikipedia.org/wiki/VT52
You can use HyperTerminal who have VT52 escape sequences support.
The ANSI protocol is complex and adds printer support and other stuffs.
https://en.wikipedia.org/wiki/ANSI_escape_code

for example if you Arduino sends 0x1b+"[2J" erases all the screen in ANSI Terminal emulator like HyperTerminal.
ANSI is wide used for terminal programs.

Arduino IDE serial monitor doesn't support both VT52 and ANSI. Only RAW (no escape sequences).
I recommend VT52 for testing but is better ANSI escape sequences.
You can inplement some ANSI like goto cursor, erase screen,
for expample: char(27)+char('[')+char('1')+char('2')+char(';')+char('6')+char('H') send cursor to 12:6 on the screen

char(27)+char('[')+char('0')+char('m')+"Hey, "+
char(27)+char('[')+char('1')+char('m')+"Hello"+
char(27)+char('[')+char('0')+char('m')+" Word"+

writes "Hey, Hello Word"
...

No, sorry, I don't use Windows.

isn't this a linux command?

Yes, it is.

Well a Unix one - not just Linux

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.