Introduction
Serial communication, while old, is still used in many embedded systems and microcontrollers. It is commonly used with Arduino, CircuitPy, and similar boards. We will look at how to connect, send, and receive data using serial.
Connect to serial console
The easiest way to connect to a serial console over USB is to use some software that is already built for that purpose. PuTTy, MobaXTerm, GNU Screen, Android Serial Console, Android Serial USB Terminal, and Arduino IDE are examples of software you can use.
Let's look at some examples of how to do this in Windows, Linux, Mac, and Android.
Windows
- Check which serial port is being used for the device.
You can use mode
in the Command Prompt to list attached COM
serial devices
along with their baud rate.
You can use the GUI by going to Device Manager
and expanding Ports (COM & LPT)
.
You will see a device listed like USB Serial Device (COM4)
.
If you aren't sure which one it is, you can unplug and replug your device to see which one shows up as new.
- Connect
You can connect using putty or MobaXTerm with the serial option.
Set the speed to 115200
or whatever the device baud rate is
and set the port to COM4
or whatever name your device manager listed.
Linux/Mac
- Identify the serial port/device name
Check in /dev/
for serial devices.
It will have a name like ttys004
or ttyACM4
.
If you aren't sure which device it is, you
can check the list of devices in /dev/
before and after plugging it in
to see which one is new.
Try ls /dev/tty*
to see the list of devices.
Alternatively, you can use dmesg
to look for information about recently
connected devices.
- Connect using any serial client.
You can use putty
on Linux just like Windows.
You can also use screen
like screen /dev/ttyACM0 115200
. You may need
to run it with sudo
or add yourself to the device group (e.g. dialout
in Fedora).
Android
There are a couple applications that I have tested and used on an Android device to connect to USB serial consoles:
Be sure to configure the appropriate baud rate and connect to the device.
Programmatically
Note that you can also use various programming languages to connect and communicate over serial. For example, you can also use Python from your host environment to connect to the board over serial with PySerial. This isn't recommended unless you have a particular reason for connecting programmatically. The easier way is to simply use PuTTy.
Conclusion
After reading this, you should be able to connect to serial consoles over USB to communicate with devices like Arduinos using Windows, Mac, Linux, and Android.