Connecting to the serial console on Mac does not require installing any drivers or extra software. You'll use a terminal program to find your board, and screen
to connect to it. Terminal and screen
both come installed by default.
What's the Port?
First you'll want to find out which serial port your board is using. When you plug your board in to USB on your computer, it connects to a serial port. The port is like a door through which your board can communicate with your computer using USB.
The easiest way to determine which port the board is using is to first check without the board plugged in. Open Terminal and type the following:
ls /dev/tty.*
Each serial connection shows up in the /dev/
directory. It has a name that starts with tty.
. The command ls
shows you a list of items in a directory. You can use *
as a wildcard, to search for files that start with the same letters but end in something different. In this case, you're asking to see all of the listings in /dev/
that start with tty.
and end in anything. This will show us the current serial connections.
Now, plug your board. In Terminal, type:
ls /dev/tty.*
This will show you the current serial connections, which will now include your board.
A new listing has appeared called /dev/tty.usbmodem141441
. The tty.usbmodem141441
part of this listing is the name the example board is using. Yours will be called something similar.
Using Linux, a new listing has appeared called /dev/ttyACM0
. The ttyACM0
part of this listing is the name the example board is using. Yours will be called something similar.
Connect with screen
Now that you know the name your board is using, you're ready connect to the serial console. You're going to use a command called screen
. The screen
command is included with MacOS. To connect to the serial console, use Terminal. Type the following command, replacing board_name
with the name you found your board is using:
screen /dev/tty.board_name 115200
The first part of this establishes using the screen
command. The second part tells screen the name of the board you're trying to use. The third part tells screen what baud rate to use for the serial connection. The baud rate is the speed in bits per second that data is sent over the serial connection. In this case, the speed required by the board is 115200 bits per second.
Press enter to run the command. It will open in the same window. If no code is running, the window will be blank. Otherwise, you'll see the output of your code.
Great job! You've connected to the serial console!
Text editor powered by tinymce.