[SOLVED] Simple WebServer doesn't work
Posted: Fri Feb 15, 2019 11:44 am
Hardware:
Board: ESP32 DEVKIT1
Core Installation version: 1.0.1-git this one
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Linux Mint 19.1 Mate
The following code returns a timeout and I don't know why. How can I fix it ?
This site can’t be reached 192.168.1.104 took too long to respond.
Code: Select all
#include <WiFi.h>
#include <WebServer.h>
#include <HTTPClient.h>
char* ssid = "ssid";
char* pass = "cocoscocos";
WebServer Server;
void rootPage() {
char content[] = "Hello, world !";
Server.send(200, "text/plain", content);
}
void setup () {
delay(1000);
Serial.begin(115200);
Serial.println();
Server.on("/", rootPage);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(300);
}
Serial.println("WiFi Connected: " + WiFi.localIP().toString());
Server.begin();
}
void loop() {
}
Code: Select all
13:43:16.721 ->
13:43:16.787 -> [D][WiFiGeneric.cpp:342] _eventCallback(): Event: 0 - WIFI_READY
13:43:16.821 -> [D][WiFiGeneric.cpp:342] _eventCallback(): Event: 2 - STA_START
13:43:17.749 -> [D][WiFiGeneric.cpp:342] _eventCallback(): Event: 4 - STA_CONNECTED
13:43:17.749 -> [D][WiFiGeneric.cpp:342] _eventCallback(): Event: 7 - STA_GOT_IP
13:43:17.749 -> [D][WiFiGeneric.cpp:385] _eventCallback(): STA IP: 192.168.1.104, MASK: 255.255.255.0, GW: 192.168.1.1
13:43:17.749 -> WiFi Connected: 192.168.1.104