fbpx

ESP8266 – WEB SERVER

Webserver is a program that provide files from web through http based on the user request.ESP8266 will act as web server and mobile or laptop act as client.in following example a web page is feeded in ep8266, client device can able to read the web page.

Program

  #include <ESP8266WiFi.h>
  #include <WiFiClient.h>
  #include <ESP8266WebServer.h>
  const char *Wifi_Name= "smart_config";
  const char *Password = "imake";
  ESP8266WebServer server(80);
 void handleRoot()  
  {
     /* Text To Display in html page */   
     server.send(200, "text/html", "<h1>You are connected</h1>"); 
  }
void setup()
 {
         Serial.begin(9600);
         /* You can remove the password parameter if you want the AP to be open.*/
         WiFi.softAP(Wifi_Name, Password);
         server.on("/", handleRoot);
         server.begin();
         delay(1000);
         Serial.println("HTTP server started");
         IPAddress myIP = WiFi.softAPIP();
         Serial.print("AP IP address: ");
         Serial.println(myIP);
 }
 void loop() 
 {
         server.handleClient();
 }
 

one uploaded, Open the arduino serial monitor to get the ip address of esp8266

In PC or Mobile connect to smart_config network

open the browser and enter to ip address printed in serial terminal.. Mostly default IP of ESP8266 is 192.168.4.1.

your browser will display like you are connected.

From esp8266 we can display the html pages. Below shows the example of advanced html content in esp. from webserver we can get the input perameter or configuration parameters for esp

14 comments on “ESP8266 – WEB SERVER

Leave a Reply

Your email address will not be published. Required fields are marked *