Data["temperature"]) KeyError: 'temperature'

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.

Any suggegstions?

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”


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
print("Press Ctrl+C to quit.\n\r\n\r")

# Wait for 2 seconds and start over again
except KeyboardInterrupt:
    # When Ctrl+C is pressed execution of the while loop is stopped

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.

This sounds like something @otso could possibly help with.

Anyone anything?

Complete reinstall helped.

1 Like

Hello @ripa , glad to hear that reinstall fixed this issue.