• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Using SD card with esp32

Q&A Forum › Category: ESP32 › Using SD card with esp32
0 Vote Up Vote Down
Richard Funnell asked 3 years ago

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
 

4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
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.
Regards,
Sara

0 Vote Up Vote Down
Richard Funnell answered 3 years ago

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.
Regards

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
 
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.
Regards,
Sara
 

0 Vote Up Vote Down
Richard Funnell answered 3 years ago

Thank you so much Sara, It makes more sense now..
 
Regards
 
Richard

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.