From f9d69568aec8773d9541809f6cd22d44b0197431 Mon Sep 17 00:00:00 2001 From: Sam Birch Date: Mon, 9 Dec 2019 21:55:42 +1300 Subject: [PATCH] Remove inappropriate sleep between reads The PMS5003 seems to buffer unread samples. If you are reading at a lower rate than it takes readings, then a progressively larger delay will occur between changes in actual PM levels and indicated PM levels. To see the issue: 1) run this example with the `time.sleep(1)` *included* 2) wait a few minutes 3) burn a piece of paper near the sensor and wait for the reported PM levels to spike With the sleep included, there is a delay between introducing smoke and seeing reported levels rise (often a few minutes or longer). With the sleep removed you will see reported levels update almost immediately. The correct way to use the sensor is to read as fast as the sensor allows, and not make any assumptions about what rate samples will be published at --- examples/particulates.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/particulates.py b/examples/particulates.py index 9aa9c37..c1b3c67 100755 --- a/examples/particulates.py +++ b/examples/particulates.py @@ -23,7 +23,6 @@ try: try: readings = pms5003.read() logging.info(readings) - time.sleep(1.0) except ReadTimeoutError: pms5003 = PMS5003() except KeyboardInterrupt: -- 2.30.2