ESP32 之前连接过,但现在没有使用相同的代码连接到 WiFi

ESP32 was connecting earlier but is not connecting to WiFi now with the same code

我正在做一个必须连接到 WiFi 网络的项目。所以,我已经使用 ESP32 的这段代码连接到 WiFi 网络 -

#include <Arduino.h>
#include <WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.begin("XYZXYZ", "asdfghjkl");

  // Wait for WiFi to be connected
  uint32_t notConnectedCounter = 0;
  while (WiFi.status() != WL_CONNECTED) {
      delay(100);
      Serial.println("Wifi connecting...");
      notConnectedCounter++;
      if(notConnectedCounter > 50) { // Reset board if not connected after 5s
          Serial.println("Resetting due to Wifi not connecting...");
          ESP.restart();
      }
  }
  Serial.print("Wifi connected, IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  // put your main code here, to run repeatedly:
}

我上面提到的代码运行良好,但由于某种原因,它现在无法运行。现在,当我为 ESP32 供电时,它会发出类似于(或类似于)this-

的信息

}⸮~⸮}⸮n~⸮~ֶ⸮}⸮⸮⸮n⸮~n⸮⸮]⸮⸮⸮⸮⸮⸮D⸮b⸮⸮z⸮}⸮⸮⸮1]⸮⸮}⸮⸮~⸮⸮|⸮⸮~}⸮]⸮}⸮=~]⸮⸮]⸮⸮]⸮]⸮⸮n⸮⸮ ֎UvHX⸮.,⸮⸮a⸮⸮⸮]⸮⸮>]⸮>⸮]⸮]⸮n>⸮⸮⸮>>⸮]⸮⸮>]⸮]⸮⸮6⸮

我该怎么做才能解决这个问题?

确保您的Serial.begin(11520) 速度参数Serial Monitor 速度参数值相同。