Merge pull request #37 from Kostadin/pms5003_graphing_fix
[EVA-2020-02-2.git] / examples / particulates.py
1 #!/usr/bin/env python
2
3 import time
4 from pms5003 import PMS5003, ReadTimeoutError
5 import logging
6
7 logging.basicConfig(
8 format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
9 level=logging.INFO,
10 datefmt='%Y-%m-%d %H:%M:%S')
11
12 logging.info("""particulates.py - Print readings from the PMS5003 particulate sensor.
13
14 Press Ctrl+C to exit!
15
16 """)
17
18 pms5003 = PMS5003()
19 time.sleep(1.0)
20
21 try:
22 while True:
23 try:
24 readings = pms5003.read()
25 logging.info(readings)
26 time.sleep(1.0)
27 except ReadTimeoutError:
28 pms5003 = PMS5003()
29 except KeyboardInterrupt:
30 pass