Hi there, I really need help.
I'm using DoIt ESP32 devkit V1 wifi + BLE board with Arduino IDE
Problem
- I'm trying to connect esp32 to my wifi network in station mode and it connecting and also provides the ip address but when I'm trying to open to the the ip in browser it's showing 404 error when I'm in same network.I have tried to use other browser but it didn't help.
serial monitor result.
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13160
load:0x40080400,len:3036
entry 0x400805e4
Connecting to : TirthaWAP
.
WiFi connected..!
Got IP: 192.168.0.178
HTTP server started
browser result
- But when I'm connecting esp32 to my mobile hotspot It's serving the webpage and it's working fine.
here is my Code.
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include "index.h"
/*Put your SSID & Password*/
const char* ssid = "TirthaWAP"; // Enter SSID here
const char* password = "tirtha098"; //Enter Password here
AsyncWebServer server(80);
uint8_t LED1pin = 2;
bool LED1status = LOW;
uint8_t LED2pin = 5;
bool LED2status = LOW;
void Connect_STATION() {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.print("Connecting to : ");
Serial.println(ssid);
//connect to your local wi-fi network
WiFi.begin(ssid, password);
//check wi-fi is connected to wi-fi network
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected..!");
Serial.print("Got IP: ");
Serial.println(WiFi.localIP());
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
delay(100);
}
void setup() {
Serial.begin(115200);
Connect_STATION();
pinMode(LED1pin, OUTPUT);
pinMode(LED2pin, OUTPUT);
server.on("/", handle_OnConnect);
server.on("/led1", HTTP_GET, handle_led1on);
// server.on("/led1", handle_led1off);
server.on("/led2", HTTP_GET, handle_led2on);
server.onNotFound([](AsyncWebServerRequest* request) {
request->send(404);
});
server.begin();
Serial.println("HTTP server started");
}
void loop() {
// server.handleClient();
if (LED1status) {
digitalWrite(LED1pin, HIGH);
} else {
digitalWrite(LED1pin, LOW);
}
if (LED2status) {
digitalWrite(LED2pin, HIGH);
} else {
digitalWrite(LED2pin, LOW);
}
}
void handle_OnConnect(AsyncWebServerRequest* request) {
Serial.println("GPIO4 Status: OFF | GPIO5 Status: OFF");
request->send_P(200, "text/html", index_html, processor);
}
void handle_led1on(AsyncWebServerRequest* request) {
String ledreq = "";
if (request->hasParam("state")) {
ledreq = request->getParam("state")->value();
}
Serial.println("led request" + ledreq);
if (ledreq == "ON") {
LED1status = HIGH;
Serial.println("GPIO4 Status: ON");
} else if (ledreq = "OFF") {
LED1status = LOW;
Serial.println("GPIO4 Status: OFF");
}
request->redirect("/");
}
void handle_led2on(AsyncWebServerRequest* request) {
String ledreq = "";
if (request->hasParam("state")) {
ledreq = request->getParam("state")->value();
}
if (ledreq == "ON") {
LED2status = HIGH;
Serial.println("GPIO5 Status: ON");
} else if (ledreq = "OFF") {
LED2status = LOW;
Serial.println("GPIO5 Status: OFF");
}
request->redirect("/");
}
String processor(const String& var) {
//Serial.println(var);
if (var == "BUTTON_TYPE") {
String buttons = "";
if (LED1status) {
buttons += btn1off;
} else {
buttons += btn1on;
}
if (LED2status) {
buttons += btn2off;
} else {
buttons += btn2on;
}
return buttons;
} else if (var == "SERVER_TITLE") {
return "ESP32 Devkit v1";
}
return String();
}
This problem is only on station mode
I tried to check my wifi router clients but it also showing up the esp32 there.
It's puzzeling me up that it connected and served the page for the first time in that network but from the next day the issue showed up and I didn't even changed the code. it's really confusing.


