[SOLVED] Simple WebServer doesn't work

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

[SOLVED] Simple WebServer doesn't work

Postby GeorgeFlorian1 » 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
Last edited by GeorgeFlorian1 on Wed Mar 13, 2019 2:03 pm, edited 2 times in total.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Simple WebServer doesn't work

Postby fly135 » Fri Feb 15, 2019 4:26 pm

Maybe you need to wait until the wifi is connected before you start the server.

John A

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: Simple WebServer doesn't work

Postby boarchuz » Fri Feb 15, 2019 8:54 pm

In loop:

server.handleClient();

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: Simple WebServer doesn't work

Postby GeorgeFlorian1 » Thu Feb 21, 2019 10:56 am

boarchuz wrote:
Fri Feb 15, 2019 8:54 pm
In loop:

server.handleClient();
This fixed it. Thanks !

Who is online

Users browsing this forum: No registered users and 56 guests