X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/b17f34b42aa5e6ca959d8f3d748012c87d4d8999..85439fb1907acf97eba629f9432cf824d9ebf28c:/examples/luftdaten.py?ds=inline diff --git a/examples/luftdaten.py b/examples/luftdaten.py index 2177a56..d22be88 100755 --- a/examples/luftdaten.py +++ b/examples/luftdaten.py @@ -5,7 +5,7 @@ import json import requests import ST7735 from bme280 import BME280 -from pms5003 import PMS5003 +from pms5003 import PMS5003, ReadTimeoutError from subprocess import PIPE, Popen, check_output from PIL import Image, ImageDraw, ImageFont @@ -55,9 +55,15 @@ def read_values(): values["temperature"] = "{:.2f}".format(comp_temp) values["pressure"] = "{:.2f}".format(bme280.get_pressure() * 100) values["humidity"] = "{:.2f}".format(bme280.get_humidity()) - pm_values = pms5003.read() - values["P2"] = str(pm_values.pm_ug_per_m3(2.5)) - values["P1"] = str(pm_values.pm_ug_per_m3(10)) + try: + pm_values = pms5003.read() + values["P2"] = str(pm_values.pm_ug_per_m3(2.5)) + values["P1"] = str(pm_values.pm_ug_per_m3(10)) + except ReadTimeoutError: + pms5003 = PMS5003() + pm_values = pms5003.read() + values["P2"] = str(pm_values.pm_ug_per_m3(2.5)) + values["P1"] = str(pm_values.pm_ug_per_m3(10)) return values # Get CPU temperature to use for compensation