X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/85439fb1907acf97eba629f9432cf824d9ebf28c..f9d69568aec8773d9541809f6cd22d44b0197431:/examples/particulates.py?ds=inline diff --git a/examples/particulates.py b/examples/particulates.py index e71ca5d..c1b3c67 100755 --- a/examples/particulates.py +++ b/examples/particulates.py @@ -2,8 +2,14 @@ import time from pms5003 import PMS5003, ReadTimeoutError +import logging -print("""particulates.py - Print readings from the PMS5003 particulate sensor. +logging.basicConfig( + format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', + level=logging.INFO, + datefmt='%Y-%m-%d %H:%M:%S') + +logging.info("""particulates.py - Print readings from the PMS5003 particulate sensor. Press Ctrl+C to exit! @@ -16,8 +22,7 @@ try: while True: try: readings = pms5003.read() - print(readings) - time.sleep(1.0) + logging.info(readings) except ReadTimeoutError: pms5003 = PMS5003() except KeyboardInterrupt: