A Web server is a program that uses HTTP (Hypertext Transfer Protocol) to serve the files that form Web pages to users, in response to their requests, which are forwarded by their computer’s HTTP clients. This tutorial “Simple WiFi server Program on ESP32” shows how to blink an LED via the web. Here we create a web server using ESP32. Then the ESP32 controller will show you an IP address. When you type the IP address in the browser. The browser sends a request to the web server for the connection. After the connection established, the web server will return a web page.
Simple WiFi server Program on ESP32
The first thing you need to do is include the wifi.h library

Set the LED pin as an output.

Connect to the WiFi network by entering your SSID and password. After connecting to the network, get an IP address of your WiFi shield(once connected). You can open the address on a web browser, to turn on and off the LED on pin 5.

The connection between the client and the web server is established using the HTTP protocol. The HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)and a content-type so the client knows what’s coming.

The content of the HTTP response follows the HTTP header.

If the client request was “GET /H”, it turns the LED on the client request was “GET /L”, it turns the LED off.
stop() disconnect from the server.

The content of the HTTP response displayed on the serial monitor.

Simple WiFi server Program on ESP32(1)

Liked this article! You'll love our video courses.
Checkout our comprehensive pre-recorded ESP32 based Video Course for Internet of Things
More details
Spread the love, share this