You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
647 B
29 lines
647 B
import dht
|
|
import machine
|
|
import time
|
|
import ssd1306
|
|
import network
|
|
import json
|
|
|
|
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
|
|
screen = ssd1306.SSD1306_I2C(128, 64, i2c)
|
|
|
|
probe = dht.DHT22(machine.Pin(16))
|
|
|
|
screen.init_display()
|
|
|
|
#configFile = open('config.json', 'r')
|
|
#config = json.loads(configFile.readall())
|
|
|
|
#wlan = network.WLAN(network.STA_IF)
|
|
#wlan.active(True)
|
|
#wlan.connect(config["essid"], config["password"])
|
|
|
|
while True:
|
|
probe.measure()
|
|
screen.fill(0)
|
|
screen.text("Temp : {}C".format(probe.temperature()), 0, 20)
|
|
screen.text("Humi : {}%".format(probe.humidity()), 0, 40)
|
|
screen.show()
|
|
time.sleep(1)
|