import network
import time
import urequests
from machine import Pin
import dht


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!")

# requests/urequests delujeta enako


sensor = dht.DHT22(Pin(14))

while True:
  sensor.measure() 
  t = sensor.temperature()
  h = sensor.humidity()
  print(t, h)
  klic = urequests.get(f"https://9ff2c133-c631-47d0-a912-2b2c92ed6606-00-7ajjg0qmdnok.janeway.replit.dev/Send_data/{t}/{h}") #preberi iz DHT
  print(klic.json())