Serial Console Hacks With Arduino

Battling Console

Motivation

I always hate Serial port windows. They do not automatically reconnect, and if they try (Eclipse) they don’t always work (Teensy). So I went searching for a reliable solution that will automatically reconnect after loosing a connection.

I found it! It’s called minicom!

Minicom

  • If you are command-line savvy, then install or use HomeBrew, then brew install minicom

  • Alternatively, Download Minicom Here

  • In Terminal (or iTerm2 if you are awesome) test running minicom --version

This is what I get:

minicom version 2.7 (compiled Oct 20 2014)

BASH Magic

Now add the following BASH function to your ~/.bashrc or ~/.bash_profile files:

function console {
  modem=`ls -1 /dev/cu.* | grep -vi bluetooth | tail -1`
  baud=${1:-9600}
  if [ ! -z "$modem" ]; then
    minicom -D $modem  -b $baud
  else
    echo "No USB modem device found in /dev"
  fi
}

Then you can use it as follows — in Terminal type console and it will automatically launch minicom, on the first found USB port.

If you are using baud rate other than 9600, then you can pass the new baud rate as a second parameter, eg. console 115200

The function will find a serial device and connect MiniCom to it, which then automatically reconnects upon restart of your Arduino board. Neat, eh?

To stop this monitor, close the Terminal Window.

Enjoy!

Disquss Forum — Participation is Welcomed!