ruuviscan

command module
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

ruuviscan

This is a small utility for scanning Bluetooth Low Energy (BLE) Advertisements from Ruuvi sensors and dumping the values as JSON to standard output.

Building

Grab a precompiled release or use the Go toolchain.

Usage

Set the environment value VERBOSE=1 if you wish to see more details when a RuuviTag Advertisement is received.

Dumping human-readable temperature values in real time

$ ./ruuviscan \
      | jq -rc 'select(.Temperature.Valid) | [.Timestamp, .MAC, .Temperature.Value] | @tsv'

Storing temperature values in an SQLite database

First create a suitable database file with a table for temperature data:

$ sqlite3 temps.db <<'EOF'
CREATE TABLE temps (
    timestamp TIMESTAMP NOT NULL,
    mac STRING NOT NULL,
    temp REAL NOT NULL
)
EOF

Then you can run the program to scan and store for the values:

$ ./ruuviscan \
    | jq --unbuffered -rc \
        'select(.Temperature.Valid) |
             [.Timestamp, .MAC, .Temperature.Value] | @sh' \
    | while read -r _ts _mac _temp; do
          sqlite3 temps.db "INSERT INTO TEMPS VALUES ($_ts, $_mac, $_temp)"
      done

You may also observe the latest values as they are recorded:

$ watch sqlite3 --readonly \
      "temps.db \
           'SELECT COUNT(*) FROM temps;
            SELECT * FROM temps ORDER BY timestamp DESC LIMIT 10;'"

See temps.plt for an example how to plot the temperature data with gnuplot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL