# OLED+DHT+Time
## 程式碼
```python=
from machine import Pin, I2C, SoftI2C, Timer
from dht import DHT11
import ssd1306
import time
#OLED設定
display = ssd1306.SSD1306_I2C(128, 64, SoftI2C(scl=Pin(22), sda=Pin(21), freq=200000))
#溫濕感應設定
dht = DHT11(Pin(15))
dht.measure()
def dht_detection(t):
display.fill(0)
time_tuple = time.localtime(time.mktime(time.localtime())+28800)
time_str = "%02d:%02d:%02d" % (time_tuple[3],time_tuple[4],time_tuple[5])
display.text(f"time: {time_str}",0,0,1)
display.text(f"Temp: {dht.temperature()}",0,8,1)
display.text(f"Humid: {dht.humidity()}",0,16,1)
display.show()
#固定頻率自動偵測
Timer(0).init(period=2000, callback=dht_detection)
```
## 圖片
