Apparently there are many libraries to create a Web server on an ESP32 using the Arduino Core ; for instance :
- Wifi and its WifiServer class (included)
- WebServer (included)
- Esp32WebServer (Github)
Is there a best choice in view to upload files from a PC using SPIFFS ?
What exactly do you want to achieve?
If you want to store your HTML and CSS files on SPIFFS to build a web server, I recommend using the ESPAsyncWebServer library: https://github.com/me-no-dev/ESPAsyncWebServer
See Module 12, Unit 4 of the ESP32 course.
We upload the files to the ESP32 using a plugin for the Arduino IDE. See Module 12, Unit 3 of the ESP32 course.
Let me know if you need further help.
Thank you very much for your rapid response !
Here my scope is to build a little project around an ESP32 (Heltec Wifi Kit 32) to help in trekking activity (a gift for my son at Christmas and a good opportunity for me to learn the fantastic ESP32 world…). If you want, I can send you a report with the code, when finished (accept french text or need an english translation ?).
One functionnality consists in measuring the distance to a GPS route selected among some .gpx files stored in the extern 4MB SPI flash memory. Then I would like to implement an easy way to load such files, before a trek.
I effectively observe that the Arduino ESP32 Uploader pluggin enables it, by it’s not really easy using only a smartphone for instance. So I wondered if a good solution was not to implement a Web Server on the ESP32, enabling to upload files in flash memory using SPIFFS, so that only a navigator should be required on the client smartphone or PC.
In this optic, I noticed for instance a G6EJD’s project to upload files from a client (Code https://github.com/G6EJD/ESP32-8266-FIle-Upload, video https://www.youtube.com/watch?v=1OkEXeRbq_M) using the Pedro Albuquerque Esp32 Web Server (https://github.com/Pedroalbuquerque/ESP32WebServer). It works with an SD card but I suppose that I can be adapted to flash memory using SPIFFS library.
I also noticed and tested with success the David Paiva ftp server (https://github.com/nailbuster/esp8266FTPServer), using Filezilla on the client. A bit less simple for the client but acceptable.
And obviously I also tested with success your very clear and usefull project using the ESPAsyncWebServer and enabling to store the needed HTML and CSS codes required by the server in their classical files, in the flash memory.
So, my question : is there a best library (smallest compiled size, simplest .ino code…) to implement a web server which can upload files from the client ?
I hopped to be clear and sorry to be long for explaining my problem !
Now I understand what you want to do.
I’ve never tested those approaches, but the method of G6EJD seems to be exactly what you want to do, except for the microSD card. Writing and handling files in SPIFFS is very similar of handling files on the microSD card.
So, you can use his example and modify the parts that use the SD card to use SPIFFS instead. The functions are very similar. You can take a look at Module 12 Unit 3 that explores functions to handle files in SPIFFS as well as how to initialize SPIFFS.
Let me know if you need further help.
Once your project is finished, you can share it with us, if you want. I’ve learn french at school, but I’ve forgotten almost everything. So, English is preferable.
Thanks for your advices.
Finally I changed my opinion and opted for the ftp server of David Paiva : very simple finally to use it both for the programmer and the user with WinSCP or AndFTP for instance.
Just very little changes : Access Point mode and anonymous.
I wrote a little report about in english (.doc, 9p) : if you want, I can send you this document and the programs, but how ?
I just created a Github repository with these files : https://github.com/jlemaire06/ESP32-ftp
Best regards and many thanks again.
I’m glad you’ve made it work.
Thank you so much for sharing those files. Can we write a tutorial about that using your documents in a near future?
Obviously you can use these documents as your like ! As you can see, your tutorials have served me a lot here.
In the next days, I’ll try to improve the arduino sketch so that the wfi servers can be stopped (on button clic) and their resources released.
And add to the repository other small works (compass calibration, OLED displays with U8g2, etc.) : just need to write the reports in english…
On looking for a robust method to stop and then restart my frp server, I choose to use push buttons in an asynchronous mode (with interrupts). So I tried to write a little library in this way, with an embeded ISR for each push button plus an ISR for an alarm timer (to detect long press) :
Cf. https://github.com/jlemaire06/Esp32-async-multi-button-library for details.
Obviously, I tried to found a simpler solution with only one ISR for all the push buttons which implies to be able to obtain the GPIO number concerned by an action on a button, when entering in this ISR (cf. the last remark in the .doc).
Do you know a way to do this ? (simpler than storing and exploring the state of all the buttons, as realized in the in the Alarm-Siren library).