Hotspot (Access Point) using NodeMCU

In this post, we shall discuss how to provide Hotspot (Access Point) using NodeMCU. In many applications, NodeMCU is to be configured as Hotspot.
Access Point (AP) Mode is primarily used to configure NodeMCU as Web Serer. NodeMcu supports WEP, WPA/WPA2. Security standard required can be decided. Steps to configure NodeMCU as an access point is explained in step by step.

Step 1:

Set the Hotspot SSID and password.

1
2
const char* ssid = "";
const char* password = "";

Step 2:

Change the mode of NodeMCU to Access Point Mode.

1
WiFi.mode(WIFI_AP);

Step 3:

1
2
3
4
//To start the hotspot without security use,
WiFi.softAP(ssid,password);
//To start the hotspot with security use,
WiFi.softAP(ssid);

PROGRAM:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Header Files
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
 
//Hotspot Name and Password
const char* ssid = "ESPWebServer";
const char* password = "12345678";
 
ESP8266WebServer server(80); //Server on port 80
 
void handleRoot() {
  server.send(200, "text/plain", "Thank You for using www.mybtechprojects.tech");
}
 
void setup(void){
  Serial.begin(9600);
  Serial.println("");
 
  //Start NodeMCU in ACCESS POINT Mode
  WiFi.mode(WIFI_AP);           
 
  //Start Hotspot wiith the specified SSID and Password with password
  WiFi.softAP(ssid,password);
 
  //Start Hotspot wiith the specified SSID and Password without password
  //WiFi.softAP(ssid);
 
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("HotSpt IP:");
  Serial.println(myIP);
 
  //If requested on this url execute this function
  //server.on("Requested url",Function); 
  server.on("/", handleRoot);      
 
  server.begin();                 
  Serial.println("HTTP server started");
}
 
void loop(void){
  server.handleClient();          
}
Thank you
SHARE THIS!!!

Gowtham S

Gowtham is a programming enthusiast. His field of interest includes Arduino, NodeMCU, Raspberry Pi, and Python. To know more about him visit https://mybtechprojects.tech/about-us/.

2 Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.