weatherer/main.py

26 lines
562 B
Python

import sys
import time
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
from bme280 import BME280, BME280_OSAMPLE_16
# OLED
i2c0 = I2C(0, sda=Pin(0), scl=Pin(1), freq=100000)
display = SSD1306_I2C(128, 64, i2c0)
display.fill(0)
display.text("Wait...", 0, 0)
display.show()
# BME280
i2c1 = I2C(1, scl=Pin(15), sda=Pin(14))
bme = BME280(i2c=i2c1, mode=BME280_OSAMPLE_16)
while True:
display.fill(0)
display.text("T&P", 0, 0)
d = bme.values
display.text(d[0], 0, 9)
display.text(d[1], 0, 18)
display.show()
time.sleep(1)