ESP32 使用 micropython 开发的话,可以使用以下的代码来重新连接 WiFi。
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('Connecting to WiFi...')
sta_if.active(True)
sta_if.connect('SSID', 'PASSWORD')
while not sta_if.isconnected():
pass
print('Connected to WiFi: ', sta_if.ifconfig()