ESP32 - PlatformIO - Server Erro HTML

MicheliBarcello
Posts: 6
Joined: Tue Apr 05, 2022 5:28 pm

ESP32 - PlatformIO - Server Erro HTML

Postby MicheliBarcello » Thu Jun 15, 2023 9:08 pm

Good Afternoon Guys, How are you?
I have an error when I try to run my programming, I saw several tutorials and they all work, but mine is not working, could someone help me to identify the problem?

Follow my .cpp programming

Code: Select all

#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <FS.h>
#include <SPIFFS.h>

AsyncWebServer server(80);

const char* ssid = "Michelii";
const char* password = "Barcello";

void conectarWiFi() {
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Conectando ao Wi-Fi...");
  }
  Serial.print("Endereço IP: ");
  Serial.println(WiFi.localIP());
  Serial.println("Conexão Wi-Fi estabelecida");
}

void setup() {

  Serial.begin(115200);
  conectarWiFi();

  if(!SPIFFS.begin(true)){
    Serial.println("Ocorreu um erro ao montar SPIFFS");
    return;
  }

  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/index.html");

  });

  server.begin();
}

void loop() {
  delay(1000);
  Serial.println("Teste");
}
Here's a photo of the error

Code: Select all

<html>
<head>
  <meta charset='utf-8'/>
</head>
<body>
  <h1>
    ESP32
  </h1>          
  <p>
    Hello my friends!
  </p>          
</body>
<html>
Here's a photo of the error
Image

Image

Image

username
Posts: 536
Joined: Thu May 03, 2018 1:18 pm

Re: ESP32 - PlatformIO - Server Erro HTML

Postby username » Wed Jun 21, 2023 4:37 pm

did you upload the files in the data folder using the following commands ?

#1) pio run --target erase
#2) pio run -t uploadfs

number 2 will upload the files in the data folder. Then re-flash the board and try it.

Who is online

Users browsing this forum: No registered users and 339 guests