improved logging with timestamps (instead of print)
[EVA-2020-02-2.git] / examples / gas.py
CommitLineData
0cf10e5b
PH
1#!/usr/bin/env python
2
3import time
8ab4cd2d 4from enviroplus import gas
10b73e18 5import logging
0cf10e5b 6
10b73e18
CM
7logging.basicConfig(
8 format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
9 level=logging.INFO,
10 datefmt='%Y-%m-%d %H:%M:%S')
11
12logging.info("""gas.py - Print readings from the MICS6814 Gas sensor.
0cf10e5b
PH
13
14Press Ctrl+C to exit!
8ab4cd2d 15
0cf10e5b
PH
16""")
17
18try:
19 while True:
20 readings = gas.read_all()
10b73e18 21 logging.info(readings)
0cf10e5b
PH
22 time.sleep(1.0)
23except KeyboardInterrupt:
24 pass