import network
import time
import requests

from random import randint

valor = 0

def conexao():
    print("Conectando na WiFi", end="")
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    wlan.connect("Wokwi-GUEST", "")
    while not wlan.isconnected():
        print(".", end="")
        time.sleep(0.1)
    print(" Conectado!")
    print(wlan.ifconfig())

def randominco():
    global valor
    valor = random.randint(0, 60)
    print(f"Valor randomico: {valor}")


api_key = "PRGIBOGO5P3SVPMV"

data = {"field1": "valor1", "field2": "valor2"}

response = requests.post(
        f"https://api.thingspeak.com/update",
        params={"PRGIBOGO5P3SVPMV": api_key, "field1": "valor1", "field2": "valor2"}
)