Unable to get sensor data

I try to start working with my ruuvitag.
I tried it with Raspberry Pi 3, somewhat following the instructions from ruuvitag-sensor/install_guide_pi.md at master · ttu/ruuvitag-sensor · GitHub but when running this script:
from ruuvitag_sensor.ruuvitag import RuuviTag
sensor = RuuviTag(‘AA:2C:6A:1E:59:3D’)
state = sensor.update()
state = sensor.state
print(state)
the result is:
{}
Any idea what I should do to diagnose the problem? I did read this: Ruuvitag_sensor doesn't find devices on raspberry pi 3 but it didn’t help me.

I actually tried it with a Windows computer also, and then the result was this:
{‘temperature’: 24.0, ‘humidity’: 30.0, ‘pressure’: 995.0, ‘identifier’: None}
However, these values are incorrect and don’t update. I am not seriously planning to use it with Windows, but I am just curious. Does anybody know why the result is what it is? :slight_smile:

First make sure you have the packages bluez and bluez-hcidump installed, you should have hcitool and hcidump commands. If you don’t have them installed, you can install them with:

sudo apt install bluez bluez-hcidump

Operating the Bluetooth in an advanced way requires higher privileges on Linux, you need to either run the script as root (for example with sudo), or issue the following two commands first:

sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcitool`
sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcidump`

You can test it with command: hcitool lescan
If you get “Set scan parameters failed: Operation not permitted” then you need to do either of the above steps first. If you instead get scan results or at least no errors, then the python script should work as well.

1 Like

:muscle: :+1: