2

I can load spiff docs, but I get a 404. Wireless works, IP addressing works and I can load other examples successfully. This simple image load ino is giving me fits!

#include <WiFi.h>
#include <AsyncTCP.h>
#include <SPIFFS.h>
#include <ESPAsyncWebServer.h>
const char *ssid = "x";
const char *password =  "123456789";
IPAddress staticIP(10,0,0,1); //ESP static ip
IPAddress gateway(0,0,0,0);   //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0);  //Subnet mask

AsyncWebServer server(80);

void setup() {
  Serial.begin(115200);
  WiFi.softAP(ssid, password);

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

server.begin();

}//END setup

void loop() 
{
}
<!DOCTYPE HTML>
<html>
<head>
     <meta charset='UTF-8'>
</head>
<body>
     <img src="image.png" alt=" image goes here">
</body>
</html>
0

I don't have an ESP32 to test with. Though, I tried to make your code run on an ESP8266, but it's a bit of an effort to validate what is ultimately a wild guess on my part.

And that is: perhaps you have some uppercase letters in your filename such that "/image.png" does not match perfectly and furthermore maybe SPIFFS is case sensitive. That is, your file could be named Image.png or IMAGE.png and that might matter.

UPDATE:

In my exploring this on the ESP8266, I'd forgotten to execute SPIFFS.begin(). And I see no counterpart to it in your code. At least one example of ESPAsyncWebServer I've seen does call SPIFFS.begin()

I found that the filenames are case sensitive, again at least on the ESP8266; so that can be a source of problems.

Also checked that if the SPIFFS size is changed through menu selections, I did indeed need to reupload the SPIFFS image.

I know these are different systems; in fact the code I'm using to test doesn't compile for ESP32, but I suspect a lot of the code is shared, and so maybe the problems are as well.

1
  • 1
    This is it! Thanks for taking the time. Nov 16 '20 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.