Hi, I am using the webserver esp32, In module 4.1 (Inputs), it is writing and reading the data to the Spiffs file. Is there a way of saving the data and reading it back using the SD Card. I have been through the module about saving data to the sd card but it only reads and displays it and have got that working BUT I don’t know if it is possible to send the data in the Input module (4.1) and read it back to fill in the html form.
any help would be grateful
Yes, you can read and write to the SD card.
What do you want to save on the SD card? The values from the form? It is possible.
I recommend starting by writing a function that saves data to the microSD card. Then, call that function after getting the values from the form. If you have multiple variables, it may be easier to save each variable on a different file.
About the other part. Do you want to fill the form with values saved on the microSD card? I think the best way is to start your code by reading the microSD card and saving the information on the corresponding variables. Then, use placeholders on the HTML to add those values fo the HTML form.
The WiFiManager example on the eBook uses a form and saves and reads values from a file in SPIFFS. It can be easily modified to use SD card instead of SPIFFS. I think if you take a look at that example, it may help you get a better idea of how to structure your code in that section.
I hope this helps.
Hi, Sara, thank you for your reply, Using 4.1 – Web Server with Input Fields
(HTML Form) I want to save the Input from the html form to the SD Card instead of the SPIFFS file.
To save the data if a power cut. (Which I get a lot of, where I am living).
So looking at the Wi-fi manager and looking at the 4.1 program both are using SPIFFS, would I be right in saying that if I changed the 4.1 program to load the SD card and change all references that call for SPIFFS to SD it would work?
I am really trying to understand this and I really thank you for your time.
Not all references, just the references that are reading/writing the data from the form.
The functions to read/write from SPIFFS and SD card are similar. I think this example for the SD card will help: https://github.com/espressif/arduino-esp32/blob/master/libraries/SD/examples/SD_Test/SD_Test.ino
I hope this helps.