from machine import Pin, I2C
from time import sleep_ms
from secret import ssid, password
from ssd1306 import SSD1306_I2C
import network
import dht
dht22 = dht.DHT22(Pin(15))
i2c = I2C(1, scl=Pin(3), sda=Pin(2), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
print("Logging to WIFI")
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() != True:
print("Connecting.....")
sleep_ms(1000)
print("Connected Sucessfully")
sleep_ms(1000)
print("Displaying DHT22 INFO")
while True:
dht22.measure()
temp = dht22.temperature()
humi = dht22.humidity()
oled.fill(0)
oled.text("Temperature: ", 0, 0)
oled.text(f"{temp} C", 0, 10)
oled.text("Humidity: ", 0, 30)
oled.text(f"{humi}%", 0, 40)
oled.show()
sleep_ms(500)
Loading
pi-pico-w
pi-pico-w
Loading
ssd1306
ssd1306