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 ipIPAddress gateway(0,0,0,0); //IP Address of your WiFi Router (Gateway)IPAddress subnet(255, 255, 255, 0); //Subnet maskAsyncWebServer 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 setupvoid loop() {}<!DOCTYPE HTML><html><head> <meta charset='UTF-8'></head><body> <img src="image.png" alt=" image goes here"></body></html>1 Answer1
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 furthermoremaybe 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 executeSPIFFS.begin(). And I see no counterpart to it in your code.At least one example of ESPAsyncWebServer I've seendoes callSPIFFS.begin()
I found that the filenamesare 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.
- 1This is it! Thanks for taking the time.Marr Madden– Marr Madden2020-11-16 02:49:03 +00:00CommentedNov 16, 2020 at 2:49
Explore related questions
See similar questions with these tags.