Introduction: Datalogging, Timestamp, & Monitor Arduino Data With an Incredible Bash-One-Liner


The description doesn't fit on one line -- but the code does!

This is a bash one-liner for logging data from the Arduino, and for processing (e.g. timestamping, reacting to sensor readings, etc.) and then redirecting data file.

I have tried this out on Mac Os X, but I'll verify it on the Raspberry Pi right away (as linux can perform nanosecond timestamping).

Code:

cat /dev/cu.usbmodem1421 | awk '{ for (i=0; i<NF; i++) printf $i + system("date +,%s")}'

To use with your arduino:

Just replace the /dev/cu.usbmodem1421 with your arduino's serial port (an easy way to find this is to see which is checked in the Tools -> Port  of the Arduino IDE menu)

(If you have both /dev/cu.usbmodem and /dev/tty.usbmodem, then use the /dev/cu.usbmodem one)

Real-Time Monitoring:

Real-time monitoring and command line reactions are simple to add-on, for these examples visit (and please star) the project's github.