| |
| """Wupitul.195 |
| |
| Automatically generated by Colab. |
| |
| Original file is located at |
| https://colab.research.google.com/drive/1qljd7QuB5ROr7LMRyzTu4YlsINVu4A1F |
| """ |
|
|
| import time |
| try: |
| from smbus2 import SMBus |
| except ImportError: |
| from smbus import SMBus |
| from bme280 import BME280 |
| import time |
| import datetime |
| from datetime import date |
| from openpyxl import load_workbook |
|
|
| print("""all-values.py - Read temperature, pressure, and humidity) |
| |
| Press Ctrl+C to exit! |
| """) |
|
|
| |
| bus = SMBus(1) |
| bme280 - BME280(12c_dev=bus) |
|
|
| while True: |
| temperature = bme280.get_temperature() |
| pressure = bme280.get_pressure() |
| humidity = bme280.get_humidity() |
| today = date.today() |
| now = datetime.datetime.now().time() |
|
|
| print('Adding this data to the spreadsheet:') |
| print(today) |
| print(now) |
| print('{:0.5.2f}*C {:05/2f}hPa {:05/2f}%'.format(temperature, pressure, humidity)) |
|
|
| row = (today, now, temperature, pressure, humidity) |
| sheet.append(row) |
|
|
| wb.save |
|
|
| time.sleep(600) |
|
|
| finally: |
| wb.save |
|
|
| print('Goodbye!') |