Wemos D1 mini连接到wifi

时间:2019-01-15 15:55:46

标签: adafruit micropython

我正在尝试使用Lolin/Wemos D1迷你板连接到wifi。

我担心可能存在硬件问题,因为我尝试了不同的方法,但似乎无法连接到wifi。

以下是我的代码:

# This file is executed on every boot (including wake-boot from 
deepsleep)
import esp
esp.osdebug(None)
import gc
#import webrepl
#webrepl.start()
gc.collect()

def WifiConnect():
import network
import time
from machine import Pin
led = Pin(2, Pin.OUT)
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
    print('Connecting to wifi...')
    sta_if.active(True)
    sta_if.connect('HUAWEI-B315-4057', '49504ARTBAJ')
    while not sta_if.isconnected():
        print('Trying to connect...')
        while True:
            if led.value():
                led.off()
            else:
                led.on()
            time.sleep(1)
print('Wifi Connected, IP Configuration:', sta_if.ifconfig())
led.on()
time.sleep(0.5)
led.off()

WifiConnect()

我确定凭据正确无误。

0 个答案:

没有答案