Wifi wont connect - ESP32 itsybitsy - Bad Board?

I am trying to set up a adafruit_itsybitsy_esp32 (Overview | Adafruit ItsyBitsy ESP32 | Adafruit Learning System) but I can not get it to connect to wifi. When I scan with it it sees the wifi networks so it looks like the wifi module is working. When I run a similar sketch on other boards (adafruit feather esp32 s3 reverse tft) it connects fine. I even set up an open SSID and it still won't connect.

On password protected SSIDs it was kicking out status 6, on the open SSID it kicked out status 4.

Any ideas?

trial wifi code below:

// Adafruit ItsyBitsy ESP32 Wi-Fi 

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

// Wi-Fi credentials
const char* ssid = "iceshots24";
const char* password = "";


void setup() {
  // Initialize serial communication
  Serial.begin(115200);
  delay(5000);

  Serial.println("\nStarting Wi-Fi Scanner...");

  // Set Wi-Fi to station mode
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Scanning for Wi-Fi networks...");
int n = WiFi.scanNetworks();
  Serial.println();
  Serial.printf("Found %d networks:\n", n);

  for (int i = 0; i < n; ++i) {
    // Print SSID, RSSI, and encryption type
    Serial.printf("%d: %s (%d dBm) %s\n", i + 1, WiFi.SSID(i).c_str(), WiFi.RSSI(i),
                  (WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? "Open" : "Secured");
  }

  Serial.println("\nScan complete. Scanning again in 5 seconds...");
  delay(5000); // Delay 5 seconds before scanning again


  // Connect to Wi-Fi
  Serial.print("Connecting to Wi-Fi---");
  Serial.print(ssid);
  Serial.print("||");
  Serial.println(password);
  WiFi.disconnect(true); // Clear previous Wi-Fi connections
  WiFi.mode(WIFI_STA);   // Ensure station mode
  WiFi.begin(ssid, password);

  int attempts = 0;
  while (WiFi.status() != WL_CONNECTED && attempts < 20) { // Attempt for 20 seconds
    delay(2000); // Extended delay for stability
    attempts++;
    Serial.print("Attempt ");
    Serial.print(attempts);
    Serial.print(": Status = ");
    Serial.println(WiFi.status());

    // Display connection status
    switch (WiFi.status()) {
      case WL_NO_SSID_AVAIL:
        Serial.println("ERROR: SSID not available.");
        break;
      case WL_CONNECT_FAILED:
        Serial.println("ERROR: Connection failed. Check password.");
        break;
      case WL_DISCONNECTED:
        Serial.println("ERROR: Disconnected from Wi-Fi.");
        break;
      default:
        Serial.println("Attempting to connect...");
    }
  }

  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("\nWi-Fi connected!");
    Serial.print("IP Address: ");
    Serial.println(WiFi.localIP());
  } else {
    Serial.println("\nFailed to connect to Wi-Fi after 20 attempts.");
    return;
  }

}


void loop() {
  

}

Serial printout:


Starting Wi-Fi Scanner...

Scanning for Wi-Fi networks...

Found 11 networks:

1: iceshots24 (-62 dBm) Open
2: iceshots2 (-63 dBm) Secured
3: iceshots-good (-67 dBm) Secured
4: NETGEAR19 (-83 dBm) Secured
5: ORBI62 (-83 dBm) Secured
6: yurowifi (-87 dBm) Secured
7: ATT136 (-87 dBm) Secured
8: Pineapple Xfinity (-91 dBm) Secured
9: iceshots-good (-92 dBm) Secured
10: HT-A5000.l066, (-92 dBm) Open
11: Pineapple Mesh (-93 dBm) Secured
Scan complete. Scanning again in 5 seconds...

Connecting to Wi-Fi---iceshots24||
Attempt 1: Status = 4
ERROR: Connection failed. Check password.
Attempt 2: Status = 4
ERROR: Connection failed. Check password.
Attempt 3: Status = 4
ERROR: Connection failed. Check password.
Attempt 4: Status = 4
ERROR: Connection failed. Check password.
Attempt 5: Status = 4
ERROR: Connection failed. Check password.
Attempt 6: Status = 4
ERROR: Connection failed. Check password.
Attempt 7: Status = 4
ERROR: Connection failed. Check password.
Attempt 8: Status = 4
ERROR: Connection failed. Check password.
Attempt 9: Status = 4
ERROR: Connection failed. Check password.
Attempt 10: Status = 4
ERROR: Connection failed. Check password.
Attempt 11: Status = 4
ERROR: Connection failed. Check password.
Attempt 12: Status = 4
ERROR: Connection failed. Check password.
Attempt 13: Status = 4

to make it even more strange, if I enter a password for the open SSID, I get status 6, then status 1s:

modified code:

// Wi-Fi credentials
const char* ssid = "iceshots24";
const char* password = "123";

serial:

Connecting to Wi-Fi---iceshots24||123
Attempt 1: Status = 6
ERROR: Disconnected from Wi-Fi.
Attempt 2: Status = 1
ERROR: SSID not available.
Attempt 3: Status = 1
ERROR: SSID not available.
Attempt 4: Status = 1
ERROR: SSID not available.

When I try to connect to a protected SSID with correct credentials I get Status 6s:

Connecting to Wi-Fi---iceshots-good||##Password##
Attempt 1: Status = 6
ERROR: Disconnected from Wi-Fi.
Attempt 2: Status = 6
ERROR: Disconnected from Wi-Fi.
Attempt 3: Status = 6
ERROR: Disconnected from Wi-Fi.
Attempt 4: Status = 6
ERROR: Disconnected from Wi-Fi.
Attempt 5: Status = 6
ERROR: Disconnected from Wi-Fi.

Are you sure the password of the router is NULL, or perhaps blank(s). Try using a password and see if it works (it should) then your issue is your code is "" which is what in ascii and the router is ??? Bet they are different.

Since we can't see what password or ssid you entered in the router, it's hard to know what is wrong.

It is null, when I connect with a different board it doesn't matter if there is a password entered or not. As it is a open network it connects either way. You can see it is an open network and the SSID is correct from the wifi scan.

In my previous reply I show what happens when a password is used on the open network as well as if the correct password is used on a protected network.

I can run the same code on a different board (adafruit feather esp32 s3 reverse tft) and it works fine.

Ok, do it your way, good luck.

Sorry, didn't mean to force my way. Just trying to update you guys with as much info as I had.

I did manage to fix the issue for anyone with similar problems. It appears the Wifi module on this smaller board is a bit more temperamental and I needed to give it more time and sometimes several tries to connect.

Thanks @sonofcy for the help

Matt

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.