Sensorgnome V2 serial output feed

The Sensorgnome V2 software since 2024-148 or upcoming RC15 has an experimental facility to output a serial feed of the data recorded. At the moment the purpose of this feed is to enable some experimentation with sending the data to Motus or other places using methods other than the file upload via HTTP to the Motus servers. For example, this may enable reformatting and compressing the data so it can be sent via satellite. If you would like to use this feature, please post a reply. This thread serves as documentation of what there is as well as to discuss how it could be enhanced.

Enabling the feed

The feed is designed (but not limited) to be output on the rPi’s primary UART, which is found on the 50-pin connector as GPIO 14 (TX, pin 8) and GPIO 15 (RX, pin 10). Note that the Adafruit GPS HAT uses this uart and those pins, so the uses conflict.

To enable the feed, place a JSON file at /etc/sensorgnome/feed.json with contents like:

{ "path": "/dev/serial0", "speed": 115200}

The path needs to be either a serial device or a file/pipe in the filesystem. The default speed for a serial device is 115200 but can be altered (the speed setting is optional). The serial port framing is 8N1 and the input is ignored (i.e., only TX really needs to be connected).

Feed format

The intent is to eventually be able to output multiple formats (if all this proves useful) and select the desired format using the JSON config file. Right now only a default format is supported

Tip; to quickly set the feed config file to output to a temp file so you can inspect use:

echo '{"path":"/tmp/feed"}' | sudo tee /etc/sensorgnome/feed.json

and you will need to restart the sensorgnome main process:

sudo systemctl restart sg-control

You can watch the feed using tail -f /tmp/feed (look at the pulses&tags panel in the Web UI at the same time).

Use /dev/serial0 instead of /tmp/feed for output on the serial pins.

Default format

The default feed format is to output all stanzas (lines) that are also recorded in the data files in /data/SGdata plus stanzas about Lotek tag detections using the local tag database (similar to the way these appear in the pulses&tags pane on the radio tab). The feed format includes information about GPS, time synchronization, CTT tags, Lotek pulses, and Lotek tags.

It would be nice for the format to be documented, this should really be part of the Motus documentation, but alas I don’t believe it is… A summary is:

  • each line starts with a format character which indicates the type of stanza and format
  • each stanza consists of a fixed number of comma-separated fields, mostly floating point numbers
  • each stanza is newline terminated
  • format characters:
    • G: GPS info, fields: time, lat, lon, alt; (there is no provision for “lost gps/fix” or precision)
    • C: clock info, fields: unix time, precision, step; precision/accuracy is 0->1 second, 3->1 millisecond, 6->1 microsecond, etc.; step is the number of milliseconds the clock was just stepped
    • Tn: CTT tag detection, n is the port (small integer), fields: unix time, tag ID, rssi
    • pn: Lotek pulse, n is the port, fields: unix time, freq off, signal, noise, i1, i2, i3, SNR
    • Ln: Lotek tag, n is the port, fields: unix time, tag name # id @ freq, freq off, freq SD, signal, signal SD, noise, run id, position in run, slop, burst slop, freq
    • Examples:
       G,1714605658,34.111111,-119.222222,646
       C,1714608630.796,2,0
       p3,1714607972.7395,1.236,-27.27,-42.39,14.98,0.001874,5.766e-05,31.5
       T7,1716830302.932,613455ff,-107
       T7,1716830305.338,613455ffb7,-104
       L6,1681004878.702,TestTags#1.1@166.38:25.1,3.809,0.011,-25.5,1.18,-54.4,1,3,0.0005,4.96e-05,166.38