X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/87417b927740f0950da277dd11b95a5451c509ae..85439fb1907acf97eba629f9432cf824d9ebf28c:/examples/particulates.py?ds=sidebyside diff --git a/examples/particulates.py b/examples/particulates.py index 99803ec..e71ca5d 100755 --- a/examples/particulates.py +++ b/examples/particulates.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import time -from pms5003 import PMS5003 +from pms5003 import PMS5003, ReadTimeoutError print("""particulates.py - Print readings from the PMS5003 particulate sensor. @@ -14,8 +14,11 @@ time.sleep(1.0) try: while True: - readings = pms5003.read() - print(readings) - time.sleep(1.0) + try: + readings = pms5003.read() + print(readings) + time.sleep(1.0) + except ReadTimeoutError: + pms5003 = PMS5003() except KeyboardInterrupt: pass