import streams
# import the wifi interface
from wireless import wifi
# import wifi support !!! IMPORT ESP WIFI DRIVER
from espressif.esp8266wifi import esp8266wifi as wifi_driver
pinMode(D0,OUTPUT)
streams.serial()
sleep(5000)
state = HIGH
# init the wifi driver!
# The driver automatically registers itself to the wifi interface
# with the correct configuration for the selected device
wifi_driver.auto_init()
# use the wifi interface to link to the Access Point
# change network name, security and password as needed
print("Establishing Link...")
try:
# FOR THIS EXAMPLE TO WORK, "Network-Name" AND "Wifi-Password" MUST BE SET
# TO MATCH YOUR ACTUAL NETWORK CONFIGURATION
wifi.link("Network-Name",wifi.WIFI_WPA2,"Wifi-Password")
while True:
if state == HIGH:
state = LOW
else:
state = HIGH
print("Link Active")
digitalWrite(D0,state)
sleep(3000)
except Exception as e:
print("ooops, something wrong while linking :(", e)
while True:
sleep(1000)
Comments