A cheap and cheerful data logger

I had need of a portable serial data logger for proof of concept of a supplementary data logger for an APRS tracker.

The requirement is to capture RS232-TTL data at 4800bps, 8N1 to a data file for later extraction. The logger needs to restart automatically and append new records to the existing file.

A spare Raspberry Pi2 was applied to the job as a headless data logger.

cclogger01

 

Above is the RPi2 with an inexpensive FTDI USB/RS232-TTL adapter. Only the ground and RD wires attach to the modified TinyTrak.

Configuration

A user crontab entry was made to start a script in a user account when the device boots.

@reboot ./nmealog/nmealog

Crons are not all the same, the @reboot keyword works in most but not all cron implementations, IIRC it was a feature of the Vixie cron. It works in the Raspbian distro for RPi.

The script nmealog runs the logger if the logfile exists:

#!/bin/bash

#wait for everything to start
sleep 20

LOGFILE="nmealog.txt"

cd nmealog
[ -f $LOGFILE ] || exit 1 #exit if no logfile
./grabserial -b 4800 -d /dev/ttyUSB0  >>$LOGFILE

grabserial is a Python script which captures the serial port data to the logfile.

The whole thing seems reasonably robust, it restarts properly after power interruption (though of course, some NMEA sentences may have been broken around the shutdown / startup).

Demonstration

Google Earth googleearth 22/10/2015 , 10:40:09

Above is an overlay of the capture from the datalogger and the data simulaneously captured by APRS (from aprs.fi) of a ‘drive around the block’.

The proof of concept was successful, now to find the intended logger module or wait until another arrives on a slow boat from China.