Created
November 24, 2016 19:11
-
-
Save kentaylor/b0a86187b68d33e668d0e94500f7668a to your computer and use it in GitHub Desktop.
Arduino code to test how long ESP8266 takes to connect to WiFi at power up.
This file contains hidden or 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> //https://github.com/esp8266/Arduino | |
#include <WiFiManager.h> //https://github.com/kentaylor/WiFiManager | |
const unsigned long ONE_SECOND = 1000 * 1000; | |
int start; | |
int now; | |
int codeTime; | |
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); | |
WiFi.begin("SSID","password"); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(1); | |
} | |
now = millis(); | |
codeTime = now - start; | |
wifi_station_get_config(&conf); | |
//conf.bssid[0]=conf.bssid[0]+1; | |
//WiFi.begin("SSID","password",6,conf.bssid,1); | |
Serial.begin(115200); | |
} | |
void loop() { | |
printf("SDK version:%s\n", system_get_sdk_version()); | |
Serial.print("Start millis = "); | |
Serial.println(start); | |
Serial.print("Now millis = "); | |
Serial.println(now); | |
Serial.print("Program Time = "); | |
Serial.println(codeTime); | |
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); | |
delay(10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment