Saturday, December 5, 2015

HOW TO: View Arduino Serial Data from Command Line

In the past I have always viewed the information I printed to the serial port within the Arduino IDE by opening the Serial Monitor.  However, you can view the same information from the command line.  To do so simply follow these steps.

Put this in an Arduino sketch:

void setup() {

void loop() {
Serial.println("ImagineN4tion, right MEOW!");

Upload it to whatever development board you are working with.

Then, on Mac, open Terminal and execute the following command:

ls /dev/tty.*

This will list all the serial connections.  Identify which serial port you would like to listen to.  Then execute the following command to listen to that port:

screen /dev/tty.[yourSerialPortName] [yourBaudRate]

You will enter your specific information to replace what is between the [ ] in this command.  Thus, for me it becomes:

screen /dev/tty.SLAB_USBtoUART 9600

A screen window will be opened within your terminal and you will be able to see whatever your development board is printing to the serial port, yahoo!  The sketch I provided above simply prints "ImagineN4tion, right MEOW!" repeatedly.

No comments:

Post a Comment