nanoframework esp32 wifi connection fails

903 Views Asked by At

I am trying to connect to wifi using esp32 nanoframework. Have tried various samples, for example: https://github.com/nanoframework/Samples/blob/main/samples/Wifi/ScanWiFi/Program.cs

I am getting the below exception on this line:

WifiAdapter wifi = WifiAdapter.FindAllAdapters()[0];

Exception:

Starting Wifi scan
    ++++ Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ++++
    ++++ Message: 
    ++++ System.Device.Wifi.WifiAdapter::NativeScanAsync [IP: 0000] ++++
    ++++ System.Device.Wifi.WifiAdapter::ScanAsync [IP: 000d] ++++
Exception thrown: 'System.InvalidOperationException' in System.Device.Wifi.dll
message:Exception was thrown: System.InvalidOperationException
stack:System.Device.Wifi.WifiAdapter::NativeScanAsync
System.Device.Wifi.WifiAdapter::ScanAsync

I have tried various things such as

  • reboot device
  • manually enter network config, set enabled etc.
  • reflash
2

There are 2 best solutions below

0
On BEST ANSWER

So looks like it was an issue to do with the same SSID on 5GHz as I had on 2.4GHz.

Things I looked at that weren't actually necessary to get it working

The only thing was that the esp should connect to the SSID on 2.4GHz and not the same one on 5GHz.

0
On

May be a matter of firmware, I also encountered this exception when using ESP32-S2-PICO. Then I bought an ESP32-WROOM-32, it work properly with the same code.