Installing ruuvitags-python and influxdb-python

[Setting up ruvvitags-python] [Setting up influxdb-python]

Installing Ruuvitags for python3

Taken from https://github.com/ttu/ruuvitag-sensor/blob/master/install_guide_pi.md#install-ruuvitag-sensor-package

Update the RasPi to the latest SW: $ sudo apt-get update && sudo apt-get dist-upgrade && echo +++ upgrade successful +++ Check if Bluetooth is installed/enabled: $ hcitool dev Expect output similar to
    Devices:
hci0 B8:27:EB:96:64:43
If no devices are listed, reboot and check again
$ reboot
If still nothing, install Bluetooth again $ sudo apt-get install bluetooth bluez blueman
$ reboot

Update Python 3 version (optional)

You might want to update default version of Python 3 to a newer version. Newer version must be installed from the sources. This will take around 20 min to complete.

Install dependencies so SSL will work with newly compiled pip (not sure if all of these are needed)
$ sudo apt-get install libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev
This example installs version 3.6.0
$ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
$ tar xzvf Python-3.6.0.tgz
$ cd Python-3.6.0/
$ ./configure
$ make
$ sudo make install
$ reboot

Install ruuvitag-sensor package

Ruuvitag-sensor package requires bluez and bluez-hcidump. Bluez is the Linux Bluetooth system and allows a Raspberry Pi to communicate with Bluetooth classic and Bluetooth low energy (BLE) devices and is included with Raspbian. Hcidump is a tool which prints data broadcasted by Bluetooth devices to console and needs to be installed.
$ sudo apt-get install bluez-hcidump && echo +++ install successful +++ Expect the usual verbose output from apt-get.
Upgrade setuptools
$ sudo pip3 install --upgrade setuptools
Install ruuvitag-sensor package from the Python Package Index (PyPI) with pip (Python package management system). Because we are using Python 3, install ruuvitag-sensor package with pip3. Add --user to install for current user.
$ pip3 install --user ruuvitag-sensor
This library includes a command line utility.

Try displaying the help.
$ python3 ~/.local/lib/python3.4/site-packages/ruuvitag_sensor --help Expect
usage: ruuvitag_sensor [-h] [-g MAC_ADDRESS] [-f] [-l] [-s] [--version]

optional arguments:
  -h, --help            show this help message and exit
  -g MAC_ADDRESS, --get MAC_ADDRESS
                        Get data
  -f, --find            Find broadcasting RuuviTags
  -l, --latest          Get latest data for found RuuviTags
  -s, --stream          Stream broadcasts from all RuuviTags
  --version             show program's version number and exit
If this fails with a Traceback, change the path to match Python's minor version, i.e. if you updated Python to version 3.6. then path is ~/.local/lib/python3.6/...

Make an alias if you choose
$ alias ruuvitag='python3 ~/.local/lib/python3.5/site-packages/ruuvitag_sensor' Try to find all tags
$ ruuvitag -f
    After several seconds, expect something like:
    F2:C0:C6:43:AD:03
    {'pressure': 1003.0, 'identifier': 'N', 'temperature': 20.0, 'humidity': 52.0}
    E9:38:3F:DD:20:BC
    {'pressure': 1004.0, 'identifier': 'r', 'temperature': 22.0, 'humidity': 100.0}
    D3:51:78:72:EC:0F
    {'pressure': 1003.0, 'identifier': 's', 'temperature': 11.0, 'humidity': 60.0}
This continues waiting for additional tags to be detected until interrupted with ^C.

Open nano editor and create test script tag_test.py
$ nano tag_test.py Add this content. Exit with Ctrl-X and select Y to save
from ruuvitag_sensor.ruuvi import RuuviTagSensor

RuuviTagSensor.find_ruuvitags()


Execute script just created. Expect the same result as from find all tags executed from the command line.
$ python3 tag_test.py

Now you are all set!

Installing Python-influx

Please go to influxdb-python's homepage

from https://github.com/influxdata/influxdb-python