I've been trying to set up an access point combined with a web server using the ESP8266WiFi libraries for Arduino. I am using an ESP8266 Huzzah module with NodeMCU firmware installed (newest master).
Setting up an AP using softAP works fine, I can also assert a PSK to it and choose which channel to use (I've chosen the one with the least traffic, in this case ch 11). The problem is when trying to access the web server from a connected device, it always ends up with a timeout exception. The ESP's IP is in this case 192.168.4.1 and the port is 80.
I've tried connecting the ESP to another AP (Home router) in STA mode and I am successfully able to connect to the ESP through the given IP Address.
To sum it all up:
This is how I set the web server up, together with AP:
In Setup:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
[...]
ESP8266WebServer server(80);
[...]
Serial.print("Setting soft-AP ... ");
WiFi.disconnect(true);
WiFi.mode(WIFI_AP);
delay(100);
boolean result = WiFi.softAP("TestAP", "0123456789", 11); // This does of course return true, and the access point shows up on my device
if(result == true)
{
Serial.println("Access Point Ready");
Serial.println(WiFi.softAPIP()); // Prints 192.168.4.1
}
else
{
Serial.println("Access Point Failed!");
}
[...]
server.on("/", [](){
server.send(200, "text/html", webPage);
delay(1000);
});
[...]
server.begin();
In Loop:
server.handleClient();
Has anyone else done this before and had it work? What am I actually doing wrong here?
Ok, so it seems that I figured it out partly...
All the time, I was using my smartphone to connect to the ESP AP and trying to access the web server. I tried connecting from my computer and by all the stupidness in this world, it works.
Why I can not connect via the phone is a mystery to me, maybe someone can tell me what is going on here...