from machine import Pin
import time
import dht
import machine
import network
import urequests as requests
# ESP32 Pin assignment
d = dht.DHT22(machine.Pin(33))
n = 0
print("Connecting to WiFi", end="")
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('Wokwi-GUEST', '')
while not sta_if.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
while True:
d.measure()
n = n + 1;
t = d.temperature()
h = d.humidity()
url=f'https://api.thingspeak.com/update?api_key=J12RL5OLTC6AONJA&field1={t}&field2={h}'
requests.get(url)
print(f"lan do {n}")
time.sleep(15)