NodeMCU as WiFi Access Point, Arduino program

Upload the following program to your NodeMCU.

#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>

const char index_html[] PROGMEM = R"rawliteral(
  <!DOCTYPE HTML><html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
      <H3>
       WELCOME TO ESP8266 WEB SERVER
     </H3>
  </body>
  
  </html>
  )rawliteral";

String header;

const char *APSSID = "ESP8266-WEB-SERVER";
const char *APPSK = "123456789";

AsyncWebServer server(80);
AsyncClient Client;
AsyncWebServerRequest request(&server, &Client);

void setup() {

  Serial.begin(115200);

  WiFi.softAP(APSSID, APPSK);
  IPAddress IP = WiFi.softAPIP();

  Serial.println(IP);

  server.on("/", HTTP_GET, [=](AsyncWebServerRequest *request) {
    request -> send_P(200, "text/html", index_html);
    Serial.println(IP);
  });
  
  server.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
}

Connect your Android device to NodeMCU through WiFi. Launch a web browser in the Android device and open 192.168.4.1. Following message will be displayed in the web browser.

0 0 vote
Article Rating

Published by

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
X