Created
October 17, 2018 08:26
-
-
Save li2hub/92048cf2a292157eb0c7cd32dc1e73e0 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> | |
const char *ap_ssid = "ESP8266"; | |
const char *ap_password = "12345678"; | |
const char *sta_ssid = "Your router name"; | |
const char *sta_password = "Your router password"; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(); | |
WiFi.mode(WIFI_AP_STA); | |
Serial.print("Configuring access point..."); | |
WiFi.softAP(ap_ssid, ap_password); | |
IPAddress myIP = WiFi.softAPIP(); | |
Serial.print("AP IP address: "); | |
Serial.println(myIP); | |
Serial.println(); | |
Serial.print("Connecting to "); | |
Serial.println(sta_ssid); | |
WiFi.begin(sta_ssid, sta_password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment