ESP32 cannot connect to Wifi with Arduino framework Status is No shield found

Hi, I’m trying to connect an ESP32 (Wroom 32 module) to wifi but cannot get it to connect. It just stays in the while connection loop forever with code 255 (no wifi shield found). I tried another board. Same issue. Can anyone help?

My build output:

    Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.2.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-arduinoespressif32 3.10006.210326 (1.0.6)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.2.7        
|   |-- <SPI> 1.0       
Building in release mode
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.2% (used 13640 bytes from 327680 bytes)
Flash: [==        ]  16.4% (used 215434 bytes from 1310720 bytes)



platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
upload_speed = 115200

the code:

#include <Arduino.h>

#include <Wifi.h>

//////////////Spray settings///////////

//set the pin for the spray relay

int spray_relay = 32;

//set the spray timer intervals

const unsigned long sprayOnInt = 2000; //80000

const unsigned long sprayOffInt = 4000; //480000

//store the next spray toggleTme

unsigned long sprayToggleTime;

////////////Light Controller settings////

// Wifi: SSID and password

char WIFI_SSID[] = "blah";

char WIFI_PASSWORD[] = "blah";

int status = WL_IDLE_STATUS;

void setup()


  //init serial


  //Spray setup - should switch on initially so PIN should be LOW and set toggle for Spray on interval

  pinMode(spray_relay, OUTPUT);   //set pin mode

  digitalWrite(spray_relay,LOW); //switch on the spray

  sprayToggleTime = (millis() + sprayOnInt); // set the initial toggle time

  //Light Controller Setup

   // init the WiFi connection

  while (status != WL_CONNECTED) {

    Serial.print("Attempting to connect to WPA SSID: ");


    // Connect to WPA/WPA2 network:

    status = WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

    // wait 10 seconds for connection:




  // you're connected now, so print out the data:


  Serial.println("INFO: WiFi connected");

  Serial.print("INFO: IP address: ");



Any suggestions would be very, very welcome!!! Thanks!

In case anyone else has the same issue I solved this by 1 setting the wifi.mode to (station) I read that wifi.status does not report correctly in other modes.
This led to another issue that mode was not a member of WiFiClass. This was due to the project using WiFi.h 1.2.7 from the arduino framework. I rebuilt the project as a nodemcu-32s board which caused the project to build with WiFi.h 1.0 library which works on the esp32. NOTE: I had previously tried to change the board to nodemcu-32 in the platformio.ini file and cleaned the project but that did not force the use of WiFi 1.0 which was annoying - just in case someone tries that approach.