Raspberry Pi http server example not working

Good morning

I recently received the 3-pack Ruuvi Tag sensors and I am trying now to do a kivy app using a touch screen to show the sensor values…

I grabbed the follwoing example: Raspberry Pi 2 Simple HTTP Server using ruuvitag_sensor package

Is there a more recent example available for the sensors as I get either:

TypeError: RuuviTagSensor() takes no arguments

Or if I leave out the macAddr in “sensor = RuuviTagSensor(macAddr)”

AttributeError: ‘RuuviTagSensor’ object has no attribute ‘update’

This is the stripped down version of the http example:

from ruuvitag_sensor.ruuvi import RuuviTagSensor
from time import sleep

sensor = None
macAddr = 'E9:39:41:56:D6:2D'

def run():
	# start server
	global sensor
	global macAddr

	sleepTime = 2.5

	print('Connect to RuuviTag Beacon ' + macAddr)
	sensor = RuuviTagSensor()

	# give it some time...
	sleep(sleepTime)

	state = sensor.update()
	state = sensor.state
	dump = json.dumps(state)
	data = json.loads(dump)
	print("Data:" + str(data))
	
run()

thanks in advance
richard

Hello,

Have you tried the up-to-date examples at https://github.com/ttu/ruuvitag-sensor/tree/master/examples ? Do they work?

Have got it now working together with other kivy background tasks…

def run_get_data_background(macs, queue):
	def callback(data):
		data[1]['time'] = str(datetime.now())
		queue.put(data)
		print(data)

	RuuviTagSensor.get_datas(callback)

if __name__ == '__main__':
	m = Manager()
	q = m.Queue()
	executor = ProcessPoolExecutor(1)
	executor.submit(run_get_data_background, list(tags.keys()), q)
	DemoApp().run()

Guess I can remove the queue stuff as I can manipulate the onscreen values directly …

Or is it better to use the queue to push/fetch all data?

I’m not too familiar with Python, but my guess is that it’s better to use queue and handle the queued data outside the callback-context

Hmm…seems so…

As soon I want to directly manipulate the onscreen display I only see the data coming once during start-up…then it just hangs…well…the ruuvi background process hangs…

Guess some race condition going on (o;

Okay…queue then (o;

Okay…first version looks like:

Hmm…are those RuuviTag temperature sensors so far off?
Doesn’t feel like 26.6 degrees in my office (o;

2 Likes

Looks great :slight_smile:

The temperature sensors of RuuviTags match very well other RuuviTags and alternative sensors, but placement of RuuviTag is critical for temperature accuracy. For example being near radiator or in sunlight can rise the temperature by several degrees. Same goes for electronic devices which produce a lot of heat such as desktop computers and monitors.

There’s also some response time for the sensor to settle in ambient temperature, the sensor stays warm for a few minutes after being handled.

I noticed this when I once positioned a RuuviTag on a shelf half a meter above our TV. Afterwards I could clearly see in my Grafana dashboard that the temperature rose with 0.5 degrees when we were watching TV, and it dropped again afterwards :slight_smile: