Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By ttimpe
#79510 Hello everyone,

I'm currently trying to get my NodeMCU to connect to a WPA2-Enterprise enabled hotspot, however, even following [url]this GitHub project's code
(https://github.com/jtuttas/ESP8266-WPA2-Enterprise/blob/master/ino/webserver/webserver.ino) , have been unable to do so.

This is my current sketch:

Code: Select all#include <ESP8266WiFi.h>

extern "C" {
#include "user_interface.h"
#include "wpa2_enterprise.h"
}


// SSID to connect to
static const char* ssid = "Unitymedia WifiSpot";
// Username for authentification
static const char* username = "unitymedia\\USERNAME";
// Password for authentication
static const char* password = "PASSWORD";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  delay(500);


  // WPA2 Connection starts here
  // Setting ESP into STATION mode only (no AP mode or dual mode)

    wifi_set_opmode(STATION_MODE);

    struct station_config wifi_config;
    memset(&wifi_config, 0, sizeof(wifi_config));
    strcpy((char*)wifi_config.ssid, ssid);
   
    wifi_station_set_config(&wifi_config);
   
    wifi_station_clear_cert_key();
    wifi_station_clear_enterprise_ca_cert();
    wifi_station_set_wpa2_enterprise_auth(1);
    wifi_station_set_enterprise_identity((uint8*)username, strlen(username));
    wifi_station_set_enterprise_username((uint8*)username, strlen(username));
    wifi_station_set_enterprise_password((uint8*)password, strlen(password));
    wifi_station_connect();
  // WPA2 Connection ends here



  // Wait for connection AND IP address from DHCP
  Serial.println();
  Serial.println("Waiting for connection and IP Address from DHCP");
  while (WiFi.status() != WL_CONNECTED) {
    delay(2000);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}


Has anyone been successful in connecting to a WPA2-Enterprise-enabled network?