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

sensor=dht.DHT22(Pin(13))

while True:
  try:
    sleep(2)
    sensor.measure()
    temp=sensor.temperature()
    hum=sensor.humidity()
    temp_f=temp*(9/5)+32
    print ('Temperatura:%3.1f C'%temp)
    print ('Temperatura:%3.1f F'%temp_f)
    print('Humidity:%3.1f %%'%hum)
  except OSError as e:
    print('Failed to read sensor ')

wlan=network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("Wokwi-GUEST","")
while not wlan.isconnected():
  pass
URL="https://tc22022-fd78c-default-rtdb.firebaseio.com/Sensores/.json"
dato="{\"Temperatura\":10}"
r=urequests.patch(URL,data=dato)
results=r.json()
print(results)