ESP32 SPIFFS Arduino - Save files with data onto your ESP32's Flash

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's video we will learn what spiffs is and how to use it properly and this came up right after the intro hello world my name is assalam meaning basic in the language hahaha today we'll be getting started with spiffs in the ESB 32 spiffs meaning spi flash file system and spi means serial peripheral interface in case you didn't know what space allows you to do is access the flash memory of the ESP 32 like you would do in a normal file system in your computer but simpler and more limited and this happens using SPI this means that you can read/write close and delete files in your flash memory of the ESP 32 space is especially useful for a few certain things like creating configuration files with settings using Jason for example saving data permanently saving HTML and CSS files to build a web server saving images figures and icons add much more this way whenever your project needs some certain data or settings that your ESP 32 can't forget when accidentally shuts off the last save data or settings will still be safe in the flash memory in this tutorial I will be showing you how to use spiffs to access the flash memory using arduino code meaning you will be able to create files with settings and save data permanently in the next video I will be showing you how to save HTML and CSS files to build a web server which can be extremely useful as well link to that video will be in the upper right corner on screen now now that we have learned a little bit more about spiffs let's put it to use let's open Arduino and include space dot H like so in case you can't include spiffs you have to download the needed libraries you can follow my introduction video in the upper right corner on screen now now let's move on to our setup and give it our serial again now before we can start using spits we always have to include the next lines you don't have to use an if statement here but you can with a serial print inside it just in case things go wrong and you want to get notified next we'll have to open up an existing file or create one we can do this with the next line now add in this if statement to check whether opening the file went wrong or not now that we are certain the file has opened we have to print a line into our txt file we do this like so and again like you can see I have added an if statement around the file print to make sure whether it succeeded or not like I said you don't actually need all these if statements just these lines of code would be enough after we added the sentence to the file we can simply close the file like so now that we added the line let's read it out and our void loop to open the file type in this narrative file has been opened let's read out the file however we have to insert this into a while loop to make sure it reads out a real line like so after this is done we will close the file back and add in a delay of a second now we can try to run our program and open up our serial monitor and as you can see we have written a file that contains subscribe to my channel real smooth air that's now delete this part of our code we need the code now we'll only read out the file and not write anything into the file anymore well Atari uploaded to the ESP 32 and after the code has been uploaded let's even disconnect the ESP tier 2 from the computer to make sure the power went off meaning the code now will only read out the file and not write anything into the file anymore the tree uploaded to the SBT - and after the code has been uploaded that's even disconnect ESP 32 from the from the computer to make sure the power went off and let's plug it back in and open up our serial monitor and as you can see this confirms the ESP 32 continues to read out the saved text file meaning the file has been saved to the flash memory now sometimes we do want to delete our file so let's do that now we can delete the code inside our avoid loop as well like so now back to our setup because we will only delete the file once and add in this line to get into our root and open the next file next we have to go inside a while loop again this is because she may have created multiple files now we want to print out the name of the file and open up the next file for the while loop to repeat the process this way we will be able to read out all files at once now since I know I already created only one file called subscribe top txt I will be adding this line to remove it now let's run again and open up the serial monitor and as you can see when we file that it's branded out is the subscribe dot txt file now we delete do move part from our code and run it again and as you can see this time there is no file to read out meaning the file has been deleted please consider checking out my patreon page as well that would be awesome dare I upload all of my code within that explanation with each video I have recreated this channel link for that down below or on screen now so that's it for today guys don't forget to subscribe and hit add a notification so you won't miss out on the next video and I'll see you all in the next one goodbye world
Info
Channel: Asali
Views: 35,819
Rating: undefined out of 5
Keywords: asali, ESP32, esp32 spi, esp32 spiffs, esp32 spiffs example, esp32 spiffs arduino, ESP32 Spiffs how to save files, Save file ESP32 SPIFFS, esp32 save data, ESP32 save file, esp32 save to flash, esp32 flash memory
Id: iGCU0ynkl_M
Channel Id: undefined
Length: 5min 54sec (354 seconds)
Published: Fri Sep 13 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.