Last active
November 22, 2016 23:04
-
-
Save kentaylor/9624af0f77622285605f487ce22a8eb8 to your computer and use it in GitHub Desktop.
Arduino code to test how long ESP8266 takes to connect to WiFi
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
IPAddress ip= IPAddress(192,168,1,27); | |
IPAddress gw= IPAddress(192,168,1,1); | |
IPAddress subnet= IPAddress(255,255,255,0); | |
IPAddress dns= IPAddress(192,168,1,1); | |
static struct station_config conf; | |
char mac[18] = { 0 }; | |
void setup() { | |
start = millis(); | |
WiFi.config(ip,gw,subnet, dns); | |
if (WiFi.SSID()=="") WiFi.begin("SSID","password"); | |
Serial.begin(115200); | |
Serial.println("Starting..."); | |
printf("SDK version:%s\n", system_get_sdk_version()); | |
Serial.print("Start millis = "); | |
Serial.println(start); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(1); | |
} | |
now = millis(); | |
codeTime = now - start; | |
Serial.print("Now millis = "); | |
Serial.println(now); | |
Serial.print("Program Time = "); | |
Serial.println(codeTime); | |
wifi_station_get_config(&conf); | |
sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", conf.bssid[0], conf.bssid[1], conf.bssid[2], conf.bssid[3], conf.bssid[4], conf.bssid[5]); | |
Serial.println(mac); | |
//WiFi.begin("SSID","password",6,conf.bssid,1); | |
ESP.deepSleep(3*60*ONE_SECOND, WAKE_RF_DEFAULT); | |
} | |
void loop() { | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment