WPA-2 Enterprise Connection Failure

a-equinox
Posts: 1
Joined: Mon Jun 07, 2021 2:38 pm

WPA-2 Enterprise Connection Failure

Postby a-equinox » Mon Jun 07, 2021 2:49 pm

Hi all,

I have been trying to connect my ESP32 board to my university network (WPA-2 Enterprise, i.e., needs ID, username, and password to connect) for almost a month now to no avail. I am attempting to continuously stream temperature and relative humidity data from a DHT22 sensor to a web server called "InitialState" so that I can consistently monitor the temperature and humidity for an experiment. I know the code I have works on a standard WPA-2 network, as it performs when I use my iPhone's personal hotspot. Recently, I have been receiving the following error in the Arduino Serial Monitor (shown in bold text below):

-----------------------
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
ESP32 Device
Initializing...

WiFi
Connecting to eduroam
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d836b PS : 0x00060330 A0 : 0x800d9122 A1 : 0x3ffb1f20
A2 : 0x3ffc19ec A3 : 0x3ffbdcd4 A4 : 0x0000000d A5 : 0x3ffb8488
A6 : 0x00000021 A7 : 0x57002140 A8 : 0x00000000 A9 : 0x3ffb1f10
A10 : 0x00000000 A11 : 0x00000001 A12 : 0x00000000 A13 : 0x0000000d
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000008 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000003c LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x400d836b:0x3ffb1f20 0x400d911f:0x3ffb1f40 0x400d0c2c:0x3ffb1f70 0x400d616e:0x3ffb1fb0 0x400898a6:0x3ffb1fd0

Rebooting...
ets Jun 8 2016 00:22:57

----------------------

My code is as follows:

Code: Select all

//-------- User Settings -----------
const char* ssid = "eduroam";
#define EAP_ID "ID"
#define EAP_USERNAME "USERNAME"
#define EAP_PASSWORD "PASSWORD"
const char* accesskey = "insert access key here";
const char* accesskey2 = "same";
const char* bucketkey = "insert bucket key here";
const char* bucketkey2 = "same";
const char* signalname = "temperature";
const char* signalname2 = "humidity";
//----------------------------------

HTTPClient ask;
int counter = 0;  
static bool hasWifi = false;

//////////////
// Network //
////////////

static void InitWifi()
{
Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);
    
    // WPA2 enterprise magic starts here
    WiFi.disconnect(true);  
    //wifi_auth_mode_t(WIFI_AUTH_WPA2_ENTERPRISE);
    esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
    esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID));
    esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
    esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
    esp_wifi_sta_wpa2_ent_enable(&config);
    // WPA2 enterprise magic ends here

    WiFi.begin(ssid);

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    hasWifi = true;
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
  }
  hasWifi = true;
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void setup()
{
  Serial.begin(115200);
  Serial.println("ESP32 Device");
  Serial.println("Initializing...");
  
  dht.begin();

  // Initialize the WiFi module
  Serial.println(" > WiFi");
  hasWifi = false;
  InitWifi();
  if (!hasWifi)
  {
    return;
  }
}

//////////////
//Send Data//
////////////

void loop(){
  if (WiFi.status() == WL_CONNECTED) { //if we are connected
    counter = 0; //reset counter
    Serial.println("Wifi is still connected with IP: "); 
    Serial.println(WiFi.localIP());   //inform user about his IP address
  }else if (WiFi.status() != WL_CONNECTED) { //if we lost connection, retry
    WiFi.begin(ssid);      
  }
  while (WiFi.status() != WL_CONNECTED) { //during lost connection, print dots
    delay(500);
    Serial.print(".");
    counter++;
    if(counter>=60){ //30 seconds timeout - reset board
    ESP.restart();
    }
  }

  // Reading temperature or humidity
  float t = dht.readTemperature(true);
  // Create a URL for the request
  String url2 = "https://groker.init.st/api/events?accessKey=";
  url2 += accesskey;
  url2 += "&bucketKey=";
  url2 += bucketkey;
  url2 += "&";
  url2 += signalname;
  url2 += "=";
  url2 += t;

  Serial.print("*** requesting URL");
 
  // ask.begin;
  ask.begin(url2); //Specify the URL
  
  //Check for the returning code
  int httpCode = ask.GET();       

  Serial.print(httpCode);

  float h = dht.readHumidity(true); 
  String url = "https://groker.init.st/api/events?accessKey=";
  url += accesskey2;
  url += "&bucketKey=";
  url += bucketkey2;
  url += "&";
  url += signalname2;
  url += "=";
  url += h;

  Serial.print("*** requesting URL");
 
  // ask.begin;
  ask.begin(url); //Specify the URL
  
  //Check for the returning code
  int httpCode2 = ask.GET();       

  Serial.print(httpCode2);
  if (httpCode2 > 0) { 
      String payload2 = ask.getString();
  } else {
      Serial.println("Error on HTTP request");
  }
  ask.end(); //End 
  Serial.println("*** End ");
  delay(10000);    // delay
}
If anyone has any advice, please let me know! Sorry if this is formatted poorly, I'm a newbie to the forums here.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: WPA-2 Enterprise Connection Failure

Postby ESP_Sprite » Tue Jun 08, 2021 4:50 am

Suggest you decode that backtrace to figure out what went wrong... https://github.com/me-no-dev/EspExceptionDecoder

martinius96
Posts: 33
Joined: Thu Dec 13, 2018 1:39 am

Re: WPA-2 Enterprise Connection Failure

Postby martinius96 » Fri Jun 11, 2021 8:20 pm

Why you are testing implementation for WiFi connection with HTTPClient too.
The best habit is to use only wifi connection without any other libraries and other code that "can" cause some problems.

Do you use esp_wpa library? Because it looks like you haven't show us full code.
I have created eduroam connection example in 2018 year: https://github.com/martinius96/ESP32-eduroam
Also user @debsahu from Github created example with certificate that is required for every eduroam network in connection example after last updates of RADIUS servers. That users reported to me. So try minimal example and as was mentioned by Sprite, use Decoder, it can give you better view where is problem and where program crashed. You can use some Verbose Debug output too.

Who is online

Users browsing this forum: No registered users and 60 guests