Sub topic 15
Using other serial terminal programs
The Serial Monitor in the Arduino IDE is enough for most debugging. Other terminal programs become useful when you need to log data to a file, add timestamps, run without the IDE, or watch a board from a script. This chapter assumes you have read the earlier chapters on Serial.begin, baud rates, and the Serial Monitor. You should also know how to find your board's port name.
What any serial terminal does
A serial terminal opens the board's serial port, sends the bytes you type, and shows the bytes that come back. The Serial Monitor does exactly this. Any other terminal needs the same four settings to match your sketch:
- Port: the name your operating system gives the board.
- Baud rate: the same value you passed to
Serial.begin. - Data format: 8 data bits, no parity, 1 stop bit. This is usually written 8N1 and is the Arduino default.
- Flow control: none.
Port names differ by system:
| System | Typical port name | How to find it |
|---|---|---|
| Windows | `COM3` | Device Manager, under "Ports (COM & LPT)" |
| Linux | `/dev/ttyACM0` or `/dev/ttyUSB0` | `ls /dev/tty*` before and after plugging in the board |
| macOS | `/dev/cu.usbmodem14101` or `/dev/cu.usbserial-1410` | `ls /dev/cu.*` |
Boards with a native USB chip, such as the Uno R4 or Leonardo, usually appear as ttyACM. Boards with a separate USB-to-serial chip, such as many clones, usually appear as ttyUSB.
One port, one program
Only one program can hold a serial port open at a time. If the IDE's Serial Monitor is open, a second terminal will fail with "access denied", "resource busy", or "permission denied". The same happens when you try to upload while another terminal holds the port.
Opening the port also resets many boards. On an Uno, opening the port toggles the DTR line, which restarts the sketch. Your setup() runs again and you see its startup message each time you connect. This is normal. It also means the first second of output may be lost while the board restarts, so a script should wait briefly after opening the port.
Common terminal programs
| Program | Platform | Style | Good for |
|---|---|---|---|
| PuTTY | Windows, Linux | Graphical | Quick connection, saved sessions, session logging |
| Tera Term | Windows | Graphical | Log files, timestamps, macros |
| CoolTerm | Windows, macOS, Linux | Graphical | Capturing to a text file, hex view |
| `screen` | macOS, Linux | Command line | Already installed on most systems |
| `picocom` | Linux, macOS | Command line | Small, simple, easy to exit |
| `minicom` | Linux | Command line | Full-featured, menu-driven |
| `miniterm` (pySerial) | All | Command line | Same command everywhere, works with Python |
| `arduino-cli monitor` | All | Command line | Monitoring without the IDE |
You do not need all of these. Pick one graphical tool and one command-line tool and learn their settings well.
Command-line terminals
Each of these commands opens the board at 9600 baud. Replace the port name with yours.
# screen: exit with Ctrl-A, then K, then y
screen /dev/ttyACM0 9600
# picocom: exit with Ctrl-A, then Ctrl-X
picocom -b 9600 /dev/ttyACM0
# minicom: Ctrl-A, then Z opens the help menu
minicom -D /dev/ttyACM0 -b 9600
# pySerial's miniterm: exit with Ctrl-]
python -m serial.tools.miniterm /dev/ttyACM0 9600Forgetting how to exit is the most common problem with these tools. Ctrl-C does not close screen, picocom, or minicom, because the terminal sends it to the board as a character.
If you installed the Arduino CLI, it can list boards and open a monitor:
arduino-cli board list
arduino-cli monitor -p /dev/ttyACM0 -c baudrate=9600The CLI monitor needs no IDE window. It is a good fit for remote machines, such as a Raspberry Pi that has your board attached.
Permission errors on Linux
On Linux, ordinary users often cannot open /dev/ttyACM0. The error is "Permission denied". The port belongs to the dialout group on many distributions (uucp on Arch). Add yourself to the group, then log out and back in:
sudo usermod -aG dialout $USERAvoid running terminals with sudo as a permanent fix. It hides the real problem and can leave log files owned by root.
Line endings and what gets sent
The Serial Monitor has a line-ending menu with "No line ending", "Newline", "Carriage return", and "Both NL & CR". Other terminals have their own settings, and the defaults differ.
- Most terminals send the Enter key as a carriage return (
\r) only. - The Serial Monitor can append
\n,\r, or both after your text. - Most terminals show only what the board sends. They do not show what you type unless "local echo" is on.
This matters for input code. The sketch from the earlier chapter on reading commands ignores \n and \r, so it works with any setting. A sketch that waits for \n to end a line will appear to hang if your terminal sends only \r. When a command seems ignored, check the terminal's line-ending setting first.
Output has a similar issue. Serial.println sends \r\n. A terminal that treats \n as "move down" without "return to start" draws a staircase of text drifting right. Look for a setting named "implicit CR in every LF" (PuTTY and Tera Term) to fix it.
Logging output to a file
Logging is the main reason to leave the Serial Monitor. The IDE's monitor can show timestamps, but it has no built-in way to save a session. Several terminals can log directly:
- PuTTY: Session, then Logging, then choose "Printable output" and a file name.
- Tera Term: File, then Log.
- CoolTerm: Connection, then Capture to Text/Binary File.
screen: start withscreen -L -Logfile sensor.log /dev/ttyACM0 9600. Older versions ofscreenlack the-Logfileoption and writescreenlog.0instead.picocom: add--logfile sensor.log.
Logs from terminals contain exactly what was displayed, which may include the board's startup text and partial lines from the moment you connected. Expect to clean the first line before loading the file into a spreadsheet.
A script with timestamps
When you need real timestamps or want to process data as it arrives, read the port from a script. This example uses the pySerial library (pip install pyserial). It reads one line at a time, adds a computer-side timestamp, and appends to a CSV-style file.
import sys
import time
from datetime import datetime
import serial
port = sys.argv[1]
baud = int(sys.argv[2]) if len(sys.argv) > 2 else 9600
with serial.Serial(port, baud, timeout=1) as ser, \
open("log.csv", "a", encoding="utf-8") as log:
time.sleep(2) # give the board time to finish its auto-reset
ser.reset_input_buffer()
try:
while True:
raw = ser.readline()
line = raw.decode("utf-8", errors="replace").strip()
if line:
stamp = datetime.now().isoformat(timespec="milliseconds")
print(stamp, line)
log.write(f"{stamp},{line}\n")
log.flush()
except KeyboardInterrupt:
passRun it with python log_serial.py /dev/ttyACM0 9600. Several details matter:
timeout=1makesreadline()return after one second even if no newline arrives. Without it the script can block forever.errors="replace"keeps a garbled byte from crashing the script.log.flush()writes each line to disk immediately, so a crash does not lose the data.- The
time.sleep(2)andreset_input_buffer()skip the startup message and any partial line from the reset.
Combined with the label:value output format from the Serial Plotter chapter, a sketch that prints A0:512,A1:300 per line gives you a log that is easy to parse.
Choosing between tools
- Use the IDE Serial Monitor for quick checks while you develop.
- Use
picocomorminitermto watch a board from a terminal or over SSH. - Use a graphical terminal with logging when a non-programmer needs to capture a session.
- Use a script when you need timestamps, filtering, or conversion to another format.
- Use hex view (CoolTerm, Tera Term, or
miniterm --eolwith-eecho options) when you suspect invisible characters such as stray\rbytes in your output.
Common problems
- Port is busy: close the IDE's Serial Monitor, Serial Plotter, and any other terminal. A forgotten background
screensession can hold the port. List sessions withscreen -ls. - Upload fails after using a terminal: the terminal still has the port open. Quit it before uploading.
- Port disappears: the board was unplugged or reset into a different USB mode. Run the port discovery command again, because the name can change between
ttyACM0andttyACM1. - Garbled text: the baud rate differs from the sketch's
Serial.beginvalue. - Output staircases down the screen: the terminal needs "implicit CR in every LF".
Exercise
You run picocom -b 115200 /dev/ttyACM0 and see unreadable symbols, but the sketch calls Serial.begin(9600). After you fix that, your command "1" typed in the terminal is ignored by a sketch that waits for \n to end each command. What do you change in each case?
Show answer
First, restart picocom with -b 9600 so the baud rate matches the sketch. Second, configure the terminal to send a newline after Enter (or add \r handling in the sketch), because many terminals send only a carriage return when you press Enter.
Exercise
Your Python logger prints "could not open port: resource busy". Name two likely causes and how to check each one.
Show answer
The IDE's Serial Monitor or Serial Plotter is still open, so close it. Another terminal or a background screen session may hold the port, which screen -ls or the system's process list would show. Close that program and run the script again.