ESP32, SPIFFS, OTA Credentials File

Hi everybody, pretty new to all this, including being in a discussion forum. Also, I’m a French-speaking guy trying to be precise in English. A lot of challenges! So, I’m developing a program with an ESP32. What I’m looking to do is like a secret.h file: defining variables with credentials and more, but I don’t want that file to be Built with the Main code. I like this file to be uploadable OTA in the Spiffs file system; the main program gets the credentials info from that file. The goal is to be able to update the Spiffs file, not the program.
Do you have any idea? Thanks

See documentation. You can create a data/ folder within the PlatformIO project, put your credentials in there in some format, e.g., a simple credentials.txt, in which the first line could be the WiFi SSID and the second line the password. You would then trigger the PlatformIO tasks for build and upload filesystem. With the SPIFFS library you could then mount the SPIFFS partition, read the file and set them as your WiFi credentials, dynamically. Of course you could also use LittleFS or FatFS for this, in fact, LittleFS is the default.

Thank you for your time, I read the documentation, I’m using ElegantOTA does it make any difference?

It should make no difference. ElegantOTA also just uses the Update.h library of Arduino-ESP32 and is capable of updating both the firmware and filesystem parts. So it should be able to overwrite the filesystem and with it the credentials file without problems.

Just be careful that you don’t run into a sort of chicken-egg problem: When the device initially has no WiFi credentials, it cannot join an existing WiFi and presents its (ElegantOTA) update page. It would have to create its own WiFi.

Please check if you’re not re-writing your own version of WiFiManger.

Using WiFi manager for credentials will be the last function I will code, actually, I found it more productive to hard code them. Also, the .txt file is more for char* strings like SSL certificates from Web Sites. Those are very long and will need to be changed in a future time.