Serial Applications for Embedded Development
Where I discuss various serial monitor applications and why I believe CoolTerm is the best one.
Introduction
The serial port is an invaluable, if not mandatory tool, for developing programs in embedded computing. Given the popularity of software development for embedded computers, one would think there would be a clear answer or solution. For several years, I wasn’t able to determine the best solution. However, after more work on my part to understand a specific solution, I can conclusively say use this multiplatform, free solution: CoolTerm
Be sure to check out Wait There’s More! below, as it can save you a considerable amount of time in development by automating the complete cycle of disconnecting from your serial interface, uploading a program and reconnecting and activating the serial interface.
Background
Whether you are developing using the Arduino, Pi Pico or the ESP32, having a serial connection is important. The connection provides you the ability to print debug statements, upload programs and provide a connection for the user.
What is also important is the ability for that serial program to connect and disconnect easily so that you are able to upload programs with another application. For example, when programming the Pi Pico in MicroPython, I frequently use the application mpremote to copy files from my computer to the Pico. I am not able to do that with my serial monitor connected to the Pico. I must disconnect (via software) the Pico from the serial monitor then use mpremote then reconnect the serial monitor, often dozens of times a day.
The Arduino IDE 1.8 is a great example of an application which solves this issue. It will automatically disconnect the Serial Monitor to upload a sketch then reconnect. Great! There are a few other programs which also do it, Thonny for MicroPython also performs this quite nicely. This is great if either of those two applications provide specifically what you want or need in developing code. For my purposes, they don’t. I am a long time user of Sublime Text and wish to use it for my embedded development, whether it is Forth, AVR_C or MicroPython.
Which means I need a stand-alone serial monitor which has the following capabilities:
- Easily connect at whatever baud rate and port, I choose
- Easily connect and disconnect without quitting the monitor
- Automation was thought of as a nice to have, after spending time in an automated build, it is mandatory
- Visually appealing is nice, and for that reason, I prefer a standalone application as compared to a CLI tool
- Good support. Having a forum is very helpful and having an active forum with a responsive developer is OUTSTANDING
- Multi-platform support has become critical. This site and my student’s will use all three platforms, Windows, Linux and macOS, so its become important to identify a common solution.
CoolTerm
It is a Multi-platform serial monitor, for free, which supports ALL of the capabilities above.
ONLY DOWNLOAD FROM THIS SITE: https://freeware.the-meiers.org
AND after downloading CoolTerm, please take one more step to confirm the image is the proper one. Roger Meier has done a great job in providing the checksums for the latest releases.
Please do the following and confirm your downloaded image checksum matches the proper one on the list in the text file provided on his site:
- Copy the appropriate hash of your download from the SHA-256 Checksums link (below the list of downloads).
- Run the platform-specific command to generate a hash on the downloaded program
- Use the Python REPL to confirm they are identical (examples below)
macOS and Linux example
openssl sha256 /Users/lkoepsel/Downloads/CoolTermMac.dmg
SHA2-256(/Users/lkoepsel/Downloads/CoolTermMac.dmg)= 7972a2cc93d1a4ae25c5018f81c951d21930032d9ea51fa1e680ea53c6c860fb
# Confirm using Python REPL
# d = hash of downloaded file, r = hash from Roger's forums page, answer must be True
python3
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> r = '7972a2cc93d1a4ae25c5018f81c951d21930032d9ea51fa1e680ea53c6c860fb'
>>> d = '7972a2cc93d1a4ae25c5018f81c951d21930032d9ea51fa1e680ea53c6c860fb'
>>> r == d
True
>>>
Note that the comparison by the Python REPL is True!
Windows
For Windows, the command is different, however the process is similar. The below example was run in Git Bash:
$ certutil -hashfile '/c/Users/Lief Koepsel/Downloads/CoolTermWin64Bit.zip' SHA256
SHA256 hash of C:/Users/Lief Koepsel/Downloads/CoolTermWin64Bit.zip:
70bd44f868834b14c3fbf18eced7b3563ca44f69d3422009681affb1a5c8c641
CertUtil: -hashfile command completed successfully.
# Confirm using Python REPL
# d = hash of downloaded file, r = hash from Roger's forums page, answer must be True
$ python -i
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> d = "70bd44f868834b14c3fbf18eced7b3563ca44f69d3422009681affb1a5c8c641"
>>> r = "70bd44f868834b14c3fbf18eced7b3563ca44f69d3422009681affb1a5c8c641"
>>> r == d
True
>>>
Once you have confirmed the hashes are identical, install CoolTerm and enjoy!
Wait There’s More!
For macOS and Windows users, CoolTerm has a scripting interface which provides the opportunity to automate disconnecting and reconnecting. An great example is provided in this repository.
Following the instructions on this repository, will provide you with the ability to automatically disconnect, upload a file then reconnect and activate CoolTerm using Sublime Text. A great timesaver when programming an Uno in C or the Pico in MicroPython!
Other Serial Monitors
Here is are reviews and comments on all of the serial monitors I have used to come to my conclusion:
macOS Serial
Serial, great program, macOS only and connects to everything. Also a $40 serial program. It doesn’t do automation well, though it can be to some degree. Given how well CoolTerm works, I’ve moved completely away from this solution.
macOS and Linux tio
For a command line solution, I like tio, the most. It can be easily installed using Homebrew or via Linux apt commands. It does what it says, its a simple serial monitor. It doesn’t easily disconnect/reconnect and it must be run as a CLI program. I like it and recommend it as a simple program, providing you use a Mac or a Linux computer.
To install tio, use your appropriate package manager. For macOS, I use Homebrew.
brew install tio
To run tio, connect your Uno to your computer and:
# easy way to list your connected devices
tio -L
# look for a device which doesn't have bluetooth in the name or the one you found using the Arduino IDE
# connect to your Uno (your device will be different)
tio -b 250000 /dev/cu.usbserial-01F4D348
# once in tio:
# to quit tio enter "Ctrl-t q"
# for help enter "Ctrl-t ?"
Using tio is similar to Arduino Serial Monitor, as you will need to exit tio, every time you want to upload code. This isn’t as bad, as tio will run in the same Terminal window, in which you run make flash. So it becomes second nature to:
- Ctrl-t q to quit tio
- up-arrow (twice) to get make flash, allow the code to upload
- up-arrow (twice) to re-play the tio command
Ultimately, if you use tio a great deal, you can setup a config file in ~/.config/tio/config which looks like this:
[uno]
device = /dev/cu.usbserial-AR0JYQQB
baudrate = 250000
color = 11
And run tio using this command:
tio uno
You can add different configurations using the [name] and tio name
command, so you can easily switch between different boards. Use the man tio
command to understand more about tio.
Note: As of August 24, 2023, I’ve been getting a “Error: select() failed (Bad file descriptor)” error as the last command of tio, as I quit tio. I haven’t been able to find a cause nor any solution, however, it doesn’t seem to cause problems. For now, ignore.
Linux moserial
I’ve used moserial exclusively on my Linux systems. It is very similar to Putty, works well and connects to most devices.
Multi-platform Arduino IDE Serial Monitor
Arduino IDE Serial Monitor is multi-platform abnd works for communicating with the Uno. Given the number of processors for which the Arduino supports and the ease of using it, I always recommend downloading the legacy Arduino IDE 1.8 to be part of your toolbox. As stated before, installing the Arduino IDE is great for debugging any issues between your PC and the Uno. The Arduino Serial Monitor isn’t without its issues. It has a clunky interface, which requires a different field to enter data as to receiving the data.
I recommend using the Serial Monitor initially to test the Uno serial connection. You start the monitor by one of the following options:
- Arduino IDE -> Tools -> Serial Monitor
- Shift-Control-M or Command-M
- Clicking the icon in the upper right corner of the IDE. (See image below)
Once the Serial Monitor is running, it needs to be setup properly. Make sure the correct port is in the upper left-hand corner, the “No line ending” is selected and the baud rate is 250000:
If you are NOT using the IDE to compile and load your Arduino code, the issue with the Serial Monitor is that it needs to be closed, every time you want to upload code to the Uno. If it isn’t closed, you will have an error such as this one:
make flash
avrdude -c Arduino -p atmega328p -F -V -P /dev/cu.usbmodem4201 -b 115200 -U flash:w:main.hex
avrdude: ser_open(): can't open device "/dev/cu.usbmodem4201": Resource busy
avrdude: opening programmer "Arduino" on port "/dev/cu.usbmodem4201" failed
avrdude done. Thank you.
make: *** [flash] Error 1
Windows PuTTY
For several years, Putty is a good Windows solution. Be sure to ONLY use the one from this website! The best way to ensure you are getting the right PuTTY program is to install from the Microsoft Store. Make sure the PuTTY entry looks like the one below. (Note the name Simon Tatham and the icon of two PC’s). I recommended it in the past, however, CoolTerm looks far better and works much better, so I don’t recommend it.
Once downloaded and installed, you will need to determine the COM port number being used. Use the one you found with the Arduino IDE. Be sure to change the Speed to 250000 (not 115200, as in the image) and click the radio button “Serial”.
You can also unplug/replug the Uno and the port which disappears and reappears in the PuTTY window is the COM port you want to use. Or one more method, shown in the image, is to use Windows Search to go to the Device Manager, then go to Ports(COM & LPT), and this will show the Uno port number.
Multi-platform Thonny IDE
As an IDE, Thonny is multi-platform and supports MicroPython quite well. While Thonny can be a bit cumbersome if you already know Python, it does have advantages in being able to provide fundamental file management capability. Its helpful to be able to copy files, list files and folders on the Pico, delete files and rename them. Its biggest issue is that a hardware reset will disconnect the board and reconnecting with the board, causes the board to soft reset. Which prevents you from easily running a main.py program via reset. I have also tested this using the new Arduino Lab for MicroPython and it suffers from the same problem. Very disappointing.
Comments powered by Talkyard.