RuuviTag sensor listener in Rust

I’ve implemented a command-line app to stream RuuviTag sensor events using InfluxDB line protocol to stdout in Rust. This output can be piped to Telegraf socket listener and further to InfluxDB itself.

$ ruuvitag-listener --influxdb-measurement=ruuvi --alias F1:FC:AA:80:4E:59=Bedroom --alias F1:FC:AA:80:4E:59=Kitchen
ruuvi,name=Kitchen acceleration_x=-0.01,acceleration_y=-0.051,acceleration_z=-1.04,battery_potential=2.983,humidity=23.5,pressure=98.068,temperature=19.57 1547382737329288194
ruuvi,name=Bedroom acceleration_x=-0.043,acceleration_y=-0.009,acceleration_z=1,battery_potential=3.007,humidity=21.5,pressure=97.993,temperature=21.16 1547382737755386271
ruuvi,name=Kitchen acceleration_x=-0.012,acceleration_y=-0.05,acceleration_z=-1.039,battery_potential=2.971,humidity=23.5,pressure=98.069,temperature=19.57 1547382739332303359

I wanted to store RuuviTag sensor values in a remote InfluxDB and use Telegraf in between for perform aggregation and buffering. The RuuviTag part should preferably require minimal dependencies, output InfluxDB line protocol to stdout and be a single binary for simple installation.

There didn’t really seem to be anything that would quite fit these requirements, so I implemented my own in Rust. Libraries are available for both Bluetooth LE and RuuviTag manufacturer data parsing, which made the task of building your own easier.

The underlying Bluetooth LE library does use raw BlueZ socket API. This is a bit inconvenient as it does require exclusive access to the Bluetooth device and some special permissions to run. DBus could be better option in the future.

Unfortunately, I was not aware of Bluewalker when I started. The projects are quite similar. However, ruuvitag-listener guesses the Bluetooth device which is convenient as on my Intel Nuc/Arch Linux there is no /dev/hci0.

2 Likes

Awesome to see these new projects popping up :sunglasses: Thanks for sharing!