Iāve got 2 ruuvi sensors working nicely with android phone and in one RPi Zero sending data to a DB. Iām trying to install newer ruuvi samples to another RPi (3) but the samples hang and with Ctrl-C I get the above message. The same sample on Win10 laptop does not hang but always returns temp value 24.0, humidity and pressure seem to be fixed too.
On the RPi3 sudo hcitool lescan finds both sensors ok.
It stops at āStartingā, the error message after ctrl+c is:
line_tem = str.format(āTemperature: {0} Cā, data[ātemperatureā])
KeyError: ātemperatureā
This is the code on RPI 'm trying, itās from your examples:
import os
import time
from datetime import datetime
from ruuvitag_sensor.ruuvitag import RuuviTag
mac = āE1:12:95:61:A8:3Dā #mac = āCA:66:70:94:C7:6Aā
print(āStartingā)
sensor = RuuviTag(mac)
while True:
data = sensor.update()
line_sen = str.format("Sensor - {0}", mac)
line_tem = str.format("Temperature: {0} C", data["temperature"])
line_hum = str.format("Humidity: {0}", data["humidity"])
line_pre = str.format("Pressure: {0}", data["pressure"])
# Clear screen and print sensor data
os.system("clear")
print("Press Ctrl+C to quit.\n\r\n\r")
print(str(datetime.now()))
print(line_sen)
print(line_tem)
#print(line_hum)
#print(line_pre)
print("\n\r\n\r.......")
#break
# Wait for 2 seconds and start over again
try:
time.sleep(2)
except KeyboardInterrupt:
# When Ctrl+C is pressed execution of the while loop is stopped
print("Exit")
break
PPS. The above code runs on the Zero which has been running a few years now with an update to ruuvitag-sensor 2.0.0 last year. Changing to that older version 2.0.0 from the latest on RPi3 does not help, the code wonāt run.