Advertisement
Jaturapad

lab-Go-Internet2

Sep 1st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. #include <ESP8266WebServer.h>
  3.  
  4. const char* ssid = "OBEC27";  // Access point name
  5. const char* password = "12345678";  // Access point password
  6. ESP8266WebServer server(80);
  7.  
  8.  
  9. void setup() {
  10.   Serial.begin(9600);
  11.  
  12.   // Connect to WiFi network
  13.   Serial.println();
  14.   Serial.print("Connecting to ");
  15.   Serial.println(ssid);
  16.  
  17.   WiFi.begin(ssid, password);
  18.  
  19.   while (WiFi.status() != WL_CONNECTED) {
  20.     delay(500);
  21.     Serial.print(".");
  22.   }
  23.   Serial.println("");
  24.   Serial.println("WiFi connected");
  25.  
  26.   // Print the IP address
  27.   Serial.println(WiFi.localIP());
  28.   server.on("/", displayHomePage);
  29.   server.begin();
  30.   Serial.println("HTTP server started!");
  31. }
  32.  
  33. void loop() {
  34.   server.handleClient();
  35.   }
  36. void displayHomePage(){
  37.   server.send(200, "text/html", "<h1>Hello. Welcome to my Home</h1>");
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement