Skip to content

Instantly share code, notes, and snippets.

@dmpop
Created November 10, 2017 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmpop/38ba4d13d4baaaefd5084e7efd659528 to your computer and use it in GitHub Desktop.
Save dmpop/38ba4d13d4baaaefd5084e7efd659528 to your computer and use it in GitHub Desktop.
/*
* 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