Ai
2 Star 3 Fork 1

猴哥/esp8266-micropython

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
modular_wifi.py 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
猴哥 提交于 2021-06-17 23:48 +08:00 . 加入iic
import network
import time
import modular_dht11
from mqtt_client import link_mqtt
#from model_temperature import getTemp
# wifi
def do_connect():
wifi_list = [
{
"ssid": "PDCN",
"password": "1234567890"
},
{
"ssid": "ANRUI",
"password": "89498841"
}
]
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
ssids = wlan.scan()
for ssid in ssids:
for wifi in wifi_list:
if ssid[0] == wifi.get("ssid"):
wlan.connect(wifi.get("ssid"), wifi.get("password"))
print('connecting to network...')
break
# wlan.connect(SSID, PASSWORD)
start = time.time()
while not wlan.isconnected():
time.sleep(1)
if time.time() - start > 5:
print("connect timeout!")
break
if wlan.isconnected():
print('network config:', wlan.ifconfig())
infinite_loop()
# 无限循环 调用查询温湿度
def infinite_loop():
while 1 == 1:
print("再来一次")
modular_dht11.get_current_context()
time.sleep(3)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/baozhuo/esp8266-micropython.git
git@gitee.com:baozhuo/esp8266-micropython.git
baozhuo
esp8266-micropython
esp8266-micropython
master

搜索帮助