I am facing an issue with the esp8266 AP server. The server created is unable to provide the IP adress after I give the password through any device. What should I do?
Show us some code?
The .ino file
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include "AP_Server_Header.h"
/* Put IP Address details */
IPAddress local_ip(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
ESP8266WebServer server(80);
void setup() {
Serial.begin(115200);
WiFi.softAP(MY_SSID, PASSWORD);
WiFi.softAPConfig(local_ip, gateway, subnet);
delay(100);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
The header file....
#ifndef AP_SERVER_HEADER_H
#define AP_SERVER_HEADER_H
const char* MY_SSID = "SWMS-2022"; // Enter SSID here
const char* PASSWORD = "12345678"; //Enter Password here
#endif
your code works OK on my WeMos D1 ESP8266 device
when I run the code the serial monitor displays
HTTP server started
I can then connect to SSID SWMS-2022 and open web page 192.168.1.1 which displays
Not found: /
Thank you for your response.
That means there is no issue with my code.
But then what might be the probable reason for this to not work on my nodeMCU ESP8266?
does the serial monitor display "HTTP server started"?
does the WiFi SSID SWMS-2022 appear?
if using windows open Command Prompt and run "ipconfig/all"
what IP address etc is displayed
Yes, the serial monitor displays 'HTTP server Started' and the ssid is visible but as soon as I enter the password, it shows 'Obtaining IP address' under the SSID and gets stuck....
Then, even if I try to open 192.168.1.1, it says 'This site can't be reached' on the website.. and that is obvious as the computer is not being connected to the nodeMCU.
added some checks to see if things are working
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* MY_SSID = "SWMS-2022"; // Enter SSID here
const char* PASSWORD = "12345678"; //Enter Password here
/* Put IP Address details */
IPAddress local_ip(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
ESP8266WebServer server(80);
void setup() {
while(!Serial);
Serial.begin(115200);
delay(1000);
Serial.println();
Serial.print("Setting soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(local_ip, gateway, subnet) ? " Ready" : " Failed!");
Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP(MY_SSID, PASSWORD) ? " Ready" : " Failed!");
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP());
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
loaded it onto a LoLin NodeMCU V3 - serial monitor displays
Setting soft-AP configuration ... Ready
Setting soft-AP ... Ready
Soft-AP IP address = 192.168.1.1
HTTP server started
the SSID SWMS-2022 appears and Windows connects OK
can access wb page 192.168.1.1 OK
if I run ipconfig/all I get
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) Wi-Fi 6 AX200 160MHz
Physical Address. . . . . . . . . : 34-C9-3D-E7-2F-66
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::9cba:11a3:8faf:e540%11(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.1.100(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : 16 March 2022 12:30:56
Lease Expires . . . . . . . . . . : 17 March 2022 00:31:04
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DHCPv6 IAID . . . . . . . . . . . : 288672061
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-6F-C5-BE-00-4E-01-AA-DF-8C
DNS Servers . . . . . . . . . . . : 192.168.1.1
NetBIOS over Tcpip. . . . . . . . : Enabled
note that inittially I had set the Tools>Board to "NodeMCU 0.9 (ESP-12 module)" and the program would not start
when I set it to "NodeMCU 1.0 (ESP-12E module)" it works OK
also loaded AP+webserver code from http://42bots.com on NodeMCU - - web page works OK except LED which does not exist
Thanks a ton horace!!!
It finally worked.... Thank you so much.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.