This is a simple Prometheus exporter that exports metrics for Ruuvi Bluetooth LE advertisements, data formats 3, 5 and 6.
Data format 6 carries air quality measurements and is sent for example by Ruuvi Air. Air quality readings are not exported while the sensor reports calibration in progress; see the ruuvi_calibrating metric.
I run this as a gokrazy appliance on a Raspberry Pi: add
github.com/joneskoo/ruuvi-prometheus to your gokrazy instance's packages,
alongside github.com/gokrazy/bluetooth for the BLE adapter.
The service binds listen address to :9521 by default.
For usage with Grafana, see grafana-example-dashboard.json.
To keep the exporter stateless (I run it on a headless read-only Raspberry), it is better to add the logical names for sensors in Prometheus configuration. For example:
- job_name: 'ruuvi-prometheus'
static_configs:
- targets: ['ruuvi-prometheus:9521']
metric_relabel_configs:
# ... id and name relabel config for each sensor
- source_labels: ['device']
target_label: 'id'
regex: 'e7:37:3b:37:d9:74'
replacement: '2'
- source_labels: ['id']
target_label: 'name'
regex: '2'
replacement: 'garage'
# Map location based on id
- source_labels: ['id']
regex: '2|3|5|6|7|9'
target_label: 'location'
replacement: 'indoors'
- source_labels: ['id']
regex: '1|4'
target_label: 'location'
replacement: 'outdoors'- ruuvi_acceleration_g
- Ruuvi tag sensor acceleration X/Y/Z
- ruuvi_battery_volts
- Ruuvi tag battery voltage
- ruuvi_frames_total
- Total Ruuvi frames received
- ruuvi_humidity_ratio
- Ruuvi tag sensor relative humidity
- ruuvi_pressure_hpa
- Ruuvi tag sensor air pressure
- ruuvi_rssi_dbm
- Ruuvi tag received signal strength RSSI
- ruuvi_temperature_celsius
- Ruuvi tag sensor temperature
- ruuvi_format_info
- Ruuvi frame format version; the value is always 1 and the version (3, 5 or 6) is carried in the
versionlabel - ruuvi_movement_count
- Ruuvi movement counter as reported by the sensor
- ruuvi_seqno_current
- Ruuvi frame sequence number
- ruuvi_txpower_dbm
- Ruuvi transmit power in dBm
- ruuvi_pm2_5_ug_m3
- Ruuvi sensor PM2.5 particulate matter concentration
- ruuvi_co2_ppm
- Ruuvi sensor CO2 concentration
- ruuvi_voc_index
- Ruuvi sensor VOC (volatile organic compounds) index
- ruuvi_nox_index
- Ruuvi sensor NOx (nitrous oxides) index
- ruuvi_luminosity_lux
- Ruuvi sensor ambient light level
- ruuvi_sound_avg_dba
- Ruuvi sensor A-weighted average sound level
- ruuvi_calibrating
- 1 while the Ruuvi sensor calibration is in progress
Not every metric is available from every device — for example particulate matter, CO2, VOC and NOx readings are only present on devices using data format 6, and acceleration and battery voltage are only present on data formats 3 and 5.
- Linux
- Bluetooth LE; bluetoothd must not be running.
The exporter is pure Go with no cgo: it talks to the controller over a raw
HCI socket via golang.org/x/sys.
The Bluetooth LE scanning stack and the Ruuvi frame decoder under internal/
are a vendored fork of bluewalker by Jukka Taimisto, extended here with Ruuvi
data format 6 support. The whole project is under the 2-clause BSD license (see
LICENSE), which lists both copyright holders. Every source file carries an
SPDX BSD-2-Clause identifier and per-file copyright notices recording its
authorship — Jukka's for the forked code, and both holders' for files that mix
his code with changes made here.