Skip to content

WiFi Server

Ashwin Rajesh edited this page Sep 11, 2025 · 3 revisions

Requirement

Set up a wifi server to display the status of an LED. There should be a button to turn the LED on or off. this should be reflected on the web page, every time it is refreshed.

You can either connect your esp to your mobile hotspot, or you can configure your esp as an access point, and connect your laptop to it.

If you are connecting esp to hotspot, you can use the following init function:

void initWiFi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi ..");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

remember to change ssid and password to your hotspot details.

Clone this wiki locally