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?
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.
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)
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.
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.
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.).