Created
September 1, 2017 13:26
-
-
Save thomasvt1/e43ed7b2a27a25253d784b82bc4b530f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
extern "C" { | |
#include "user_interface.h" | |
#include "wpa2_enterprise.h" | |
} | |
// SSID to connect to | |
static const char* ssid = "eduroam"; | |
// Username for authentification | |
static const char* username = "myusername@myinstitution"; | |
// Password for authentication | |
static const char* password = "mypassword"; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
// 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(); | |
// 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()); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/esp8266/Arduino/issues/1032#issuecomment-314477339