Created
November 10, 2017 16:15
-
-
Save dmpop/38ba4d13d4baaaefd5084e7efd659528 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
/* | |
* Hello world web server | |
* circuits4you.com | |
*/ | |
#include <ESP8266WiFi.h> | |
#include <WiFiClient.h> | |
#include <ESP8266WebServer.h> | |
//SSID and Password to your ESP Access Point | |
const char* ssid = "ESP8266"; | |
const char* password = "00000000"; | |
ESP8266WebServer server(80); //Server on port 80 | |
//============================================================== | |
// This rutine is exicuted when you open its IP in browser | |
//============================================================== | |
void handleRoot() { | |
server.send(200, "text/plain", "hello from esp8266!"); | |
} | |
//=============================================================== | |
// SETUP | |
//=============================================================== | |
void setup(void){ | |
Serial.begin(9600); | |
Serial.println(""); | |
WiFi.mode(WIFI_AP); //Only Access point | |
WiFi.softAP(ssid, password); //Start HOTspot removing password will disable security | |
IPAddress myIP = WiFi.softAPIP(); //Get IP address | |
Serial.print("HotSpt IP:"); | |
Serial.println(myIP); | |
server.on("/", handleRoot); //Which routine to handle at root location | |
server.begin(); //Start server | |
Serial.println("HTTP server started"); | |
} | |
//=============================================================== | |
// LOOP | |
//=============================================================== | |
void loop(void){ | |
server.handleClient(); //Handle client requests | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment