Log RuuviTag data to InfluxDB from multiple RuuviTags.
For Docker implementation see Docker Version
Influx database needs to be set up separately. I recommend the official influxdb docker image for platforms that support it, or an unofficial mendhak/arm32v6-influxdb for Pi Zero setups. Instructions for a full deployment can be found in ruuvitags-raspberrypi-zero repository.
OS: | Linux |
---|---|
Architecture: | ARMv6, ARMv7, ARM64, x86, AMD64 and others |
*Docker images may not be available for all platforms, but can be built with the included script.
- Bluetooth for example integrated in Raspberry Pi Zero W and later
- RuuviTags: RuuviTag default RAW-format is used.
- Python 3.6+ or newer
- Linux OS
- Bluez (requires Linux)
- RuuviTag Sensor Python Package by Tomi Tuhkanen
- influxdb-python library
- Listenes to selected RuuviTags
- Collects:
- Temperature
- Humidity
- Pressure
- Voltage
- Outputs measurements to stdout
- Send to InfluxDB via HTTP
- Optional data processing and filtering
- Configurable with config.yml
- Docker ready
Dedicated docker page: https://hub.docker.com/r/jvaltteri/ruuvi2influx
Instructions for setting up everything else: ruuvitags-raspberrypi-zero
docker pull jvaltteri/ruuvi2influx
At the time of writing, the ready image is only for ARM32v6 (Rasapberry Pi Zero).
Create a config.yml
in the same directroy, where you'll be starting the container from.
You can use the example_config.yml as a template. See Config section for detais.
Debian based image
$ docker run \
-d \
--name ruuvi \
--restart unless-stopped \
--net=host \
--cap-add=NET_ADMIN \
--mount type=bind,source="$(pwd)"/config.yml,target=/app/config.yml,readonly \
ruuvi2influx:latest
To build a container compatible with your device run
$ docker build -f Debian.dockerfile --tag ruuvi2influx .
$ sudo ./install.sh
$ sudo apt-get update
$ sudo apt-get install python3
$ sudo apt-get install python3-pip
sudo apt-get -y install python3-pip
sudo pip3 install --upgrade pip
sudo apt-get install bluez
sudo apt-get install bluez-hcidump
$ pip3 install -r requirements.txt
Edit config.yml
file and set desired settings.
Key | Default | Explanation |
---|---|---|
"sample_interval" |
2 | Time between pings |
"event_queue" |
15000 | How meny pings are buffered if network is interrupted. |
"db_name" |
"db" | The InfluxDB name |
"db_user" |
"user" | Username to log in to the InfluxDB |
"db_password" |
the InfluxDB password | |
"db_host" |
"localhost" | the address to the InfluxDB. !! omit 'https:\\' !! |
"db_port" |
8086 | Port used to connect to the InfluxDB |
Note: the sample interval effects only the minimum time between outputting new datapoints. Listening is constant. If you are building a databace, you may use this to limit the data resolution to a reasonable rate.
The measurements from the sample interval are collected and averaged. The result is sent forward to the databace. This reduces databace bloat and makes queries faster.
To turn off filtering and internal processing, set sample_interval to 0. Do this if you have room for a large databace and processing power for large queries and want to controll all the processing your self.
For light weight Raspberry Pi setup, the 60-900 seconds should be fine.
# SAMPLE INTERVAL
sample_interval: 60 # seconds
If the connection to the databace is interrupted, how meny measurements should be held in queue, untill connection resumes.
Large queue takes up RAM. When connection resumes, a very large WRITE reaquest may be rejected by the DB.
# EVENT QUEUE
event_queue: 15000
Settings for the HTTP connection to your InfluxDB
# INFLUX DB
db: True # Enable or disable database
db_name: ruuvitags
db_user: sensor
db_password: password
db_host: 127.0.0.1
db_port: 8086
List the MAC addresses for your tags and give them names:
# RUUVITAGS
# List and name your tags
tags:
"CC:CA:7E:52:CC:34": Backyard
"FB:E1:B7:04:95:EE": Upstairs
"E8:E0:C6:0B:B8:C5": Downstairs
Now you can run it manually:
$ ./ruuvi2influx.py
OR
$ python3 ruuvi2influx.py
For non-docker setups it is recommended to setup a start script utilizing screen
screen -S logger -d -m python3 ruuvi2influx.py
Thre is a ready script for that
start_logger.sh
The influxdb needs to be installed seperately. If you don't already have a system for visualizing the data. I recommend Grafana.
For legacy version with MySQL and Dweet support, see the legacy branch
docker pull influxdb:latest
mendhak/arm32v6-influxdb
docker pull grafana/grafana
There doesn't seem to be any reasonably up-to-date Grafana version compatible with Raspberry Pi Zero W (ARMv6). It is recommended to use a Pi 3 or newer for hosting Grafana. Official grafana/grafana:latest
image supports ARMv7 and newer.
I may yet try to build a Zero compatible image, but since I have a working image on another Pi, the incentive for me is low right now.