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
Merge pull request #88 from pimoroni/actions
[EVA-2020-02-2.git]
/
examples
/
weather.py
diff --git
a/examples/weather.py
b/examples/weather.py
index 17aba2041ac13d819ff23f3f431cf6b8f395702f..66f18e0ac20b12f82af49f5d1b8d1ce8af646ccc 100755
(executable)
--- a/
examples/weather.py
+++ b/
examples/weather.py
@@
-1,4
+1,4
@@
-#!/usr/bin/env python
+#!/usr/bin/env python
3
import time
from bme280 import BME280
import time
from bme280 import BME280
@@
-8,7
+8,14
@@
try:
except ImportError:
from smbus import SMBus
except ImportError:
from smbus import SMBus
-print("""weather.py - Print readings from the BME280 weather sensor.
+import logging
+
+logging.basicConfig(
+ format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
+ level=logging.INFO,
+ datefmt='%Y-%m-%d %H:%M:%S')
+
+logging.info("""weather.py - Print readings from the BME280 weather sensor.
Press Ctrl+C to exit!
Press Ctrl+C to exit!
@@
-21,7
+28,7
@@
while True:
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
-
print
("""Temperature: {:05.2f} *C
+
logging.info
("""Temperature: {:05.2f} *C
Pressure: {:05.2f} hPa
Relative humidity: {:05.2f} %
""".format(temperature, pressure, humidity))
Pressure: {:05.2f} hPa
Relative humidity: {:05.2f} %
""".format(temperature, pressure, humidity))