本站改版新增arduino频道
arduino esp32 判断是否连接wifi 如果没有 则重启设备
#include <WiFi.h> const char* ssid = "your_SSID"; const char* password = "your_PASSWORD"; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); Serial.print("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nConnected to WiFi"); } void loop() { if (WiFi.status() != WL_CONNECTED) { Serial.println("WiFi not connected, restarting..."); ESP.restart(); } // 其他代码 //delay(10000); // 每10秒检查一次WiFi连接状态 }
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0095369815826416 seconds