本帖最后由 526598 于 2022-4-20 08:56 编辑
我也遇到网络不稳定的问题,我是这么写的
- char auth[] = "**********";
- char ssid1[] = "wifi_ssid_1";
- char pswd1[] = "psw1";
- char ssid2[] = "wifi_ssid_2";
- char pswd2[] = "psw2";
- bool default_wifi = true;
- int WiFi_connect_coun=0;
复制代码
- if(WiFi.status()!=WL_CONNECTED){
- WiFi_connect_coun++;
- if(WiFi_connect_coun>300){
- Blinker.disconnect();
- if (default_wifi){
- Blinker.begin(auth, ssid2, pswd2);
- }else{
- Blinker.begin(auth, ssid1, pswd1);
- }
- default_wifi = !default_wifi;
- WiFi_connect_coun=0;
- }
- digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
- Blinker.delay(1000);
- }else{
- WiFi_connect_coun=0;
- }
复制代码
|