Last active
May 2, 2017 04:18
-
-
Save 42Bots/3540927fd28d9c7020b38779eb02895f to your computer and use it in GitHub Desktop.
ESP8266 Soft Access Point Example
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
/* | |
* For more information see http://42bots.com | |
* Configure the ESP8266 unit as a Wi-Fi access point | |
*/ | |
#include <ESP8266WiFi.h> | |
/* Your WiFi Soft Access Point settings */ | |
const char* ssid = "ESP8266"; //this will be the network name | |
const char* password = "ESP8266Test"; //this will be the network password | |
void setup() { | |
delay(1000); | |
Serial.begin(115200); | |
Serial.println(); | |
Serial.println(); | |
Serial.print("Configuring WiFi access point..."); | |
/* You can remove the password parameter if you want the AP to be open. */ | |
boolean result = WiFi.softAP(ssid, password); | |
if(result==true) { | |
IPAddress myIP = WiFi.softAPIP(); | |
Serial.println("done!"); | |
Serial.println(""); | |
Serial.print("WiFi network name: "); | |
Serial.println(ssid); | |
Serial.print("WiFi network password: "); | |
Serial.println(password); | |
Serial.print("Host IP Address: "); | |
Serial.println(myIP); | |
Serial.println(""); | |
} | |
else { | |
Serial.println("error! Something went wrong..."); | |
} | |
} | |
void loop() { | |
Serial.printf("Number of connected devices (stations) = %d\n", WiFi.softAPgetStationNum()); | |
delay(3000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment