marcelm / radonwave

Read radon levels from Airthings Wave
MIT License
26 stars 8 forks source link

intermitted issue reading data #11

Closed Vendo232 closed 2 years ago

Vendo232 commented 2 years ago

Using standard AMD based server with BT USB dongle and Airthingwave Wave sensor.

the script fails probably when no broadcast is captured after some time.

the workaround is cron job every 5 min.

image

^Cserver@frigate:~/radonwave$ ./radonlog.sh Could not connect Traceback (most recent call last): File "/home/server/radonwave/radonwave.py", line 133, in <module> main() File "/home/server/radonwave/radonwave.py", line 119, in main 'temperature': measurement.temperature, UnboundLocalError: local variable 'measurement' referenced before assignment server@frigate:~/radonwave$ ./radonlog.sh Could not connect Traceback (most recent call last): File "/home/server/radonwave/radonwave.py", line 133, in <module> main() File "/home/server/radonwave/radonwave.py", line 119, in main 'temperature': measurement.temperature, UnboundLocalError: local variable 'measurement' referenced before assignment server@frigate:~/radonwave$ ./radonlog.sh 2022-03-24 19:01:59 17.00 31.50 0 0 0 50 server@frigate:~/radonwave$ ./radonlog.sh Could not connect Traceback (most recent call last): File "/home/server/radonwave/radonwave.py", line 133, in <module> main() File "/home/server/radonwave/radonwave.py", line 119, in main 'temperature': measurement.temperature, UnboundLocalError: local variable 'measurement' referenced before assignment server@frigate:~/radonwave$ ./radonlog.sh 2022-03-24 19:02:17 17.00 31.50 0 0 0 50 server@frigate:~/radonwave$ ./radonlog.sh 2022-03-24 19:03:05 17.00 31.50 0 0 0 50 server@frigate:~/radonwave$ ./radonlog.sh 2022-03-24 19:03:15 17.00 31.50 0 0 0 50 server@frigate:~/radonwave$ ./radonlog.sh 2022-03-24 19:03:21 17.00 31.50 0 0 0 50 server@frigate:~/radonwave$ ./radonlog.sh Could not connect Traceback (most recent call last): File "/home/server/radonwave/radonwave.py", line 133, in <module> main() File "/home/server/radonwave/radonwave.py", line 119, in main 'temperature': measurement.temperature, UnboundLocalError: local variable 'measurement' referenced before assignment

marcelm commented 2 years ago

The crash should be fixed now, thanks for reporting! I recommend the cron job anyway because you don’t have to worry about the script crashing once in a while, and also the times at which the measurements are taken are then at nice, round numbers. That is, you get a measurement at 10:00, 10:30, 11:00 etc.

Note that the radon level changes only once an hour, so if you’re interested mostly in that, then querying at 5-minute intervals is more than necessary and will probably just drain the battery quicker. It’s fine of course if you want the temperature and humidity at that time resolution.

Vendo232 commented 2 years ago

Thank you very much so the script actually pings the sensor to get data? I was under impression that it just scans and sniffs data. If that is the case than yes adjusting timing of cron for 1hr interval is more than enough.

marcelm commented 2 years ago

Yes, every time the script runs, it establishes a Bluetooth connection to the device and requests the sensor data. The device doesn’t actually broadcast any data, as far as I know, so in that regard, it’s different from "dumb" wireless thermometers and similar.

Vendo232 commented 2 years ago

That makes perfect sense I thought it just broadcasts data. Thank you again for quick and great support.