Would the ability to copy from or save Serial Monitor be an evil thing?

I would like the ability to extract information from Serial Monitor. To find out exactly where in the program something odd or out of place originates, without having to tpe in to the find function what my antique eyes can barely see.

I would like the ability to save Serial Monitor output to a .txt file, so I can rearrange functions created in random order as I discovered the need for them into the order as presented on the screen

I can't be the first person who thought of this, so there is probably a reason for why it is not done. Does anyone know that reason?

Hello Geek_Emeritus

Use a terminal program, e.g. Coolterm, to make a datalogging.

HTH

Hi @Geek_Emeritus,

I do not know the reason but some ways to get the data into a file ... Would that also be of interest for you?

anything that gets me to a hard copy would be appreciated

The easiest way is as follows if you use Windows:

Click into the Serial Monitor window of the IDE
Press CTRL-A
Press CTRL-C
Open notepad
Press CTRL-V
Save from notepad to a file

Hope it helps...

It is also possible to copy everything from serial to a file (unfortunately you cannot read on the screen in parallel) like this:

Connect the board to the PC and memorize the com port (e.g com5)
Close the IDE Serial Monitor
Open a command window
Type at the prompt
>mode com5 (or whatever you memorize)
You should see some lines regarding the comX
Type
>type com5 >log.txt

If you think you logged enough data press CTRL-C

Now you should have a file log.txt in the current directory. Open it with
>notepad log.txt

Of course the best way is to download a serial terminal program like puTTY or Coolterm etc.

Hope it helps you also...

on a Raspberry Pi running Debian Linux, CTRL-A and CTRL-C work in the editing window, but not in the serial monitor

I'm using CuteCom under debian and it works fine. I'm outputting my data seperated by commas - so I can seve the file in .csv format and open it in excel (or open office / libre office calc etc)

Any terminal programme will do this, there is no need to mess about with the serial monitor.

1 Like

I was not sure about the OS you are using. The most convenient suggestions are to use a serial terminal program of course.

For Linux users there are some solutions explained here

https://www.cyberciti.biz/hardware/5-linux-unix-commands-for-connecting-to-the-serial-console/

If one does not want to install a separate software using console or python may be an alternative.

Works in Linux as well. Select, Copy, Paste. and print!

The Arduino IDE developers are tracking this feature request here:

Thanks, just a question:

Did you use CTRL or SHIFT-CTRL?

Just, because @Geek_Emeritus seemed to have no success while using Debian Linux with my suggestion for Windows...

The Serial Monitor was never meant to be a full fledged terminal program but to be a simple debugging tool.

There is actually only one reason that really justifies the presence of Serial Monitor and that is that it can be controlled from the IDE. The IDE can close the connection opened by Serial Monitor so Serial Monitor does not interfere with an upload.

For anything else, you're far better off using a dedicated terminal program.

Note:
To my knowledge there is still a bug in IDE 2.x that only allows you to copy what is visible.

1 Like

These are the two bugs related to copying content from the Arduino IDE 2.x Serial Monitor:

odd thing. I have 4 Raspberry Pis and 8 OS TF cards. I have to rotate through the OS cards to keep everything updated

One OS card lets me copy from Serial Monitor, and one lets me watch YouTube videos. so, I can do it, if I use the right card. I need to figure out how to combine those traits into one OS card and duplicate that card

I use Ubuntu with Mint. That has worked for me for at least ten years. I have several versions running and they all work with the keyboard shortcut. I use just the CTRL key and and the C or V or X etc. (Copy, Paste, Cut) same as windows. I do not use the shift key with them.

Check to see whether you have different versions of Arduino IDE installed on each of the cards. The version is shown on the IDE window title bar and also in the Help > About dialog.

Thanks @gilshultz,

I also found the same [Edit: To be more clear -> Copy/Paste worked well!] using a Raspberry Pi 4 with Arduino IDE 2:1.0.5+dfsg2-4.1. So there must be a difference between our experience and @Geek_Emeritus' setup ...

Anyhow, I wrote a small python script that does the job also and tested it with

Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 5.10.43v64

import serial
import sys
comPort = '/dev/ttyACM0'
logFile = 'log.txt'
ser   = serial.Serial(comPort,115200, timeout=0)
ser.flushInput()

f = open(logFile,'w')

print("Reading from: "+comPort)
print("Writing to  : "+logFile)
print("------------------------")

while True:
	try:
		byteIn = ser.read()
		if len(byteIn) != 0:
			f.write(byteIn.decode())
			sys.stdout.write(byteIn.decode())
			sys.stdout.flush()
	except:
		print('------------------------')
		print('Stopped')
		f.close()
		break

Just change the following lines where required

comPort = '/dev/ttyACM0'
logFile = 'log.txt'
ser = serial.Serial(comPort,115200, timeout=0)

and start the script. It can be loaded into Geany or the Thonny Python IDE for easy changes. It should work with Python 2 as well as Python 3 without modifications.

To stop the script press CTRL-C!

Using Python to store the serial data allows to easily add further functionality (like to start and/or stop logging depending on commands or certain sequences from serial or to limit the dump to a specific amount of data, to start/stop logging at a given time etc.).

they are all Arduino 1.8-19. The OSes seem to have their own personalities

Not sure if you know but that is an antique version; and I mean ANTIQUE :smiley: