View Full Version : Some libraries and a serial monitor for the Teensy

12-23-2013, 11:11 PM

I just finished putting together some libraries and a serial monitor program for my Teensy 3.1, so I thought I would share.

The first library, is called StrPrintf. It allows printf style output, but you get to provide a pointer to a function which actually does the output. It's based on some public domain code that I found a while ago, and I just adapted it for arduino.

The second library, is called Logging, and it allows you to put logging statements in your code (with Debug, Info, Warning, and Error levels) and have the output directed to any arduino object which is derived from the Print class (so this includes Serial, Serial1, Serial2, and Serial3).

The third program is called teensy-mon (and happens to be written in python). teensy-mon is currently for linux only. It basically acts like the serial monitor in the Arduino IDE, but it can autodetect which serial port your teensy is using, and automatically takes care of disconnects and reconnects automatically when the teensy gets reprogrammed, or unplugged and replugged.

It also supports colorizing the output (ties in with the Logging library above).

You can find all of these in my github repository. For StrPrintf and Logging, you can cd to the libraries directory (create it if it doesn't exist already) where you store your sketches.

git clone https://github.com/dhylands/StrPrintf.git
git clone https://github.com/dhylands/Logging.git

Each one has an examples subdirectory with an example.

teensy-mon is a PC side python script, so you can put it whereever you like:
git clone https://github.com/dhylands/teensy-mon


If you happen to have multiple teensy's connected, you can use:

./teensy-mon.py -l

to show them, and then use -s followed by a serial number to determine which one to connect to. So far, I've only tested all of the above on my Teensy 3.1, although the StrPrintf code has been used on AVRs quite a bit as well (just not under arduino).

I'm planning on fleshing out the README.md files a bit more real soon now.

Dave Hylands (yes - I'm Jon's brother)