Arduino Giga R1 WiFi takes too long to reconnect again

Hello,

I use an Arduino Giga R1 board as the main brain of an automated system. I am trying to connect the system to the Internet via WiFi, and if the WiFi is disconnected, the board will try to reconnect. When it tries to reconnect, it takes about 36 sec and freezes the whole loop. I tried the same sketch below with ESP32; the reconnection took less than a second.


#include <WiFi.h>

const char* ssid = "Sparky";            // Replace with your network SSID (name)
const char* password = "HAYDER098123";  // Replace with your network password

void setup() {
  Serial.begin(115200);
  delay(1000);

}

void loop() {
  // Check the status of the WiFi connection
  Serial.println("I am in the loop");
  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("WiFi connection lost. Attempting to reconnect...");
    WiFi.disconnect();
    Serial.println("Before WiFi.begin");
    WiFi.begin(ssid, password);
    Serial.println("After WiFi.begin");
  }

  Serial.println("");
  Serial.println("Reconnected to WiFi.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  delay(100);  // This is just a placeholder delay for the example
}

And here are the serial monitor prints
4:44:34.598 -> I am in the loop
14:44:34.598 -> WiFi connection lost. Attempting to reconnect...
14:44:34.598 -> Before WiFi.begin
14:45:10.371 -> After WiFi.begin
14:45:10.371 ->
14:45:10.371 -> Reconnected to WiFi.
14:45:10.371 -> IP address:
14:45:10.371 -> 0.0.0.0
14:45:10.441 -> I am in the loop
14:45:10.441 -> WiFi connection lost. Attempting to reconnect...
14:45:10.441 -> Before WiFi.begin

Would you please help find out where the problem is?

Try to "Update Wi-Fi firmware on GIGA R1 WiFi" following Update Wi-Fi firmware on GIGA R1 WiFi and use 2.4Ghz wifi that the SSID and password is not too long and have no special characters.

Thank you so much for your reply. I did as you recommended and still have the same problem. Unlike ESP32, I used the same sketch, and everything was perfect. It sounds like an Arduino Giga problem.

Use this to test GIGA R1 WiFi Network Examples
your board.

Thank you, @Dozie , for your reply. I tested the board with this code and had the same problem. If the WiFi network is not available at starting, the code is kept frozen for ~36 sec each cycle.

Try the steps listed below:

and then try using a 2.4Ghz wifi from your phone hotspot to test with the Arduino examples.