Errors with WiFi Configuration

With the following code, I'm getting errors with both an Sparkfun Pro Micro ESP32 and Arduino Giga. With the ESP32, it doesn't connect to WiFi and the the while loop below runs continuously:

while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
}

Using a Giga, I get this error:

Failed to mount the filesystem containing the WiFi firmware.

Usually that means that the WiFi firmware has not been installed yet or was overwritten with another firmware.

The code is below:

#include <WiFi.h>
#include <Wire.h>
#include "SparkFun_STTS22H.h"

const char ssid []    = "";
const char password [] = "";

SparkFun_STTS22H mySTTS; 

float temp; 

int status = WL_IDLE_STATUS;

WiFiClient client;

void setup() {
 Serial.begin(9600);
 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, password);

    // wait 3 seconds for connection:

    Serial.println("status: " + status);
    delay(3000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

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

}

Thank you.

what is " Arduino Pro Micro ESP32 "?

My apologies, it's a Sparkfun board: SparkFun Pro Micro - ESP32-C3

Might be the repeated call to WiFi.begin() within the for loop. Try this instead:


  // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
  status = WiFi.begin(ssid, password);
  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);

    // wait 3 seconds for connection:

    Serial.println("status: " + status);
    delay(3000);
    status = WiFi.status();
  }
  Serial.println("Connected to wifi");

< edit >
This line will give you meaningless output. status is an integer, it is being added to the char* that points to the string "status:", instead of printing the text followed by the integer value.

    Serial.println("status: " + status);

Putting Wifi.begin() outside of the loop resolved the issue as well as doing the following steps in this link for the Giga: Giga R1 Wifi firmware mounting failure & crashing on writing to Fashl