projects
/
EVA-2020-02-2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adding Python 3 shebang
[EVA-2020-02-2.git]
/
examples
/
particulates.py
diff --git
a/examples/particulates.py
b/examples/particulates.py
index 99803ec05a96ff502fc440e115b5c7aa581888a3..9aa9c37814a0bc3f6d34bf03f1df52d58fa3408f 100755
(executable)
--- a/
examples/particulates.py
+++ b/
examples/particulates.py
@@
-1,9
+1,15
@@
#!/usr/bin/env python
import time
#!/usr/bin/env python
import time
-from pms5003 import PMS5003
+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!
Press Ctrl+C to exit!
@@
-14,8
+20,11
@@
time.sleep(1.0)
try:
while True:
try:
while True:
- readings = pms5003.read()
- print(readings)
- time.sleep(1.0)
+ try:
+ readings = pms5003.read()
+ logging.info(readings)
+ time.sleep(1.0)
+ except ReadTimeoutError:
+ pms5003 = PMS5003()
except KeyboardInterrupt:
pass
except KeyboardInterrupt:
pass