Installing ruuvitags-python and influxdb-python

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

Installing Ruuvitags for python3

Taken from

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
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
$ 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
                        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:
    {'pressure': 1003.0, 'identifier': 'N', 'temperature': 20.0, 'humidity': 52.0}
    {'pressure': 1004.0, 'identifier': 'r', 'temperature': 22.0, 'humidity': 100.0}
    {'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
$ nano Add this content. Exit with Ctrl-X and select Y to save
from ruuvitag_sensor.ruuvi import RuuviTagSensor


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

Now you are all set!

Installing Python-influx

Please go to influxdb-python's homepage