"""
MicroPython IoT Weather Station Example for Wokwi.com
To view the data:
1. Go to http://www.hivemq.com/demos/websocket-client/
2. Click "Connect"
3. Under Subscriptions, click "Add New Topic Subscription"
4. In the Topic field, type "wokwi-weather" then click "Subscribe"
Now click on the DHT22 sensor in the simulation,
change the temperature/humidity, and you should see
the message appear on the MQTT Broker, in the "Messages" pane.
Copyright (C) 2022
"""
import network
import time
from machine import Pin
print("<<< WIFI CLIENT >>>")
#crea el led asociado al pin 13
led = Pin(2,Pin.OUT)
led.off() #apaga el led
print("Connecting to WiFi", end="")
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('Wokwi-GUEST', '')
#esperando se conecte a la wifi
while not sta_if.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
print("IP Address: ", sta_if.ifconfig()[0])
print("Gateway Address: ", sta_if.ifconfig()[2])
initial_value = 1
while True:
initial_value^=1
led.value(initial_value)
time.sleep(1)