ESP8266 WPA EAP minimal example
This example shows how to connect to WPA2-EAP wifi with username and password on the ESP8266 using the Arduino framework:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "wpa2_enterprise.h"
char ssid[] = "MyWifiSSID";
char username[] = "MyEAPUsername";
char password[] = "MyEAPPassword";
void setup()
{
Serial.begin(115200);
wifi_set_opmode(STATION_MODE);
// Configure SSID
struct station_config wifi_config;
memset(&wifi_config, 0, sizeof(wifi_config));
strcpy((char *)wifi_config.ssid, ssid);
wifi_station_set_config(&wifi_config);
// DO NOT use authentication using certificates
wifi_station_clear_cert_key();
wifi_station_clear_enterprise_ca_cert();
// Authenticate using username/password
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));
// Connect
wifi_station_connect();
// Wait for connect
while (WiFi.status() != WL_CONNECTED)
{
Serial.println("Wifi connecting...");
delay(500);
}
// Print wifi IP addess
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop()
{
// put your main code here, to run repeatedly:
}