ESP32 Tutorial 40 - Reading and writing to Micro SD Card | SunFounder's ESP32 IoT Learning kit

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hi. welcome to a video tutorial from Robojax  in this video we are going to learn how to   read and write information to micro SD card  using esp32 and esp32 extension board from SunFounder let's get started with us esp32  starter kit from SunFounder this is the best   esp32 learning kit from SunFounder it has this  esp32 microcontroller which has built-in Wi-Fi   and Bluetooth this board can do everything  Arduino Uno can do or many other Arduinos   can do plus extra more features because we  have Wi-Fi and Bluetooth the possibilities   are endless you can get connected to the cloud  or do the control or read information or values   via your mobile device or your desktop  or over the cloud from a far location it comes with a camera extension kit where  you can stream the video over Wi-Fi either   through the cloud or to your network and  also it comes with micro SD card where you   can save images on the micro SD card or you can  write from the device any information log the   information on the device and read it back  you can power the board using this included   18650 lithium battery and it has built-in  charger where you can connect micro USB   and charge the battery the kit comes with 320  pieces of component that you can learn tons of projects if you purchase a Sounders esp32  learning kit it comes with this extension   board a battery and a my esp32 and also there is a  charge circuitry where it will charge the battery VI so you don't have to worry about charging it  and power this device up and your micro and your   32 will be ready and also we can attach camera  here so in this video we are just uh reading   and writing file into the micro SD card and in  the upcoming videos we are going to use it for   example taking photo saving it playing music from  this micro SD card and perhaps you would use it   for data logging temperature pressure whatever  you want the first thing we should know that the   capacity for the micro SD Card cannot exceed 32  GB so this is the maximum you can use 1 2 8 4 16   whatever value you have but cannot be over 32 gab  because we are formatting it with fat 32 let me   connect it to my computer and show you and here it  has been opened that's my micro SD card let's see   the formatting right click and select property  if you have older Windows click on more option   you will see it like this and click properties and  here it shows file system fat 32 if for any reason   this is not file fat 32 right click and select  format or from the long menu select format and   here make sure from the this list fat 32 and quick  format is selected click Start and accept this warning the formatting is now completed come to this page docs.sunFounder.com  scroll down until you see esp32 then click on   esp32 starter kit main on the left side  click on For Arduino users and then scroll   down to 7.4 SD card write and read this  is the documentation page for today's   lesson we're going to use esp32 board and  esp32 extension board just this board with esp32 and here is the code for today's lesson we're going to install we we're going  to use sdmmc library for this and there is some explanation I'm opening Arduino IDE let's open our project by clicking  on file open on the left side click on   downloads then SP sp32 starter kit  main on the right side double click   to open it double click on C double  click on codes and scroll down to 7.4 SD read write double click to open the  folder select the file click open to open it when we installed ESP 32 this Library have been  already installed inside the setup we are defining   the serial monitor with 115,200 this is just  checking that if SD card MMC begin not it's not   true which means it has failed then it will print  this and it will return so we will stay on this   screen and then we have this portion which opens  this file for/ test.txt this is creating a new   file this file says right and this is the name and  we are creating a handle called file of type file   this and here we say if the file not which is true  if the handle has not been created for any reason   then we print this on the screen so the file can  be created automatically and this line we say file   print Ln so in the file in this uh object that we  created using print Ln we print our text inside   that file and this is also printing it on the  screen so this is printing it in the file this is   printing it on the screen else if it cannot write  it then it will print this text on the screen and   then file. close will close the file so that was  the first thing after that we again sdmm open this   means root directory open the root directory and  create a handle called root of type file and then   here we check if this was not successful we print  an error else this will print on the screen that   files found in the root directory and this while  is from here to here it will run continuously as   long as this portion is true now let's see what  it says root open next file this will check if   the next file exists the result will be true and  will be stored in here uh a new uh handle will   be created new object called file of type file so  this is true if it can see there is a file then it   will print a space print the file name file. name  will get us the file name and then this will print   a tab with a space and it will print the file size  and it will close it then it will go to the next   file next file and so forth until all the files  are done and this will be false and the loop will exit now let's see how we can select the es32  board we can click here under the select board   and type here esp32 D as soon as you type Dev you  will see Dev board you can select it and click   okay so the board have been selected now we have  to select the port the other way to select the   board is Click On Tools board es32 and select  the esp32 dev module now we have to select the   port if I click here it shows two port and I don't  know which one belongs to my device sometimes you   will see you will not see the number properly  so the best way to be sure the right click on   the start menu go to the device manager and you  will see here the ports if I click on this Arrow   it will show me the ports and is USB serial  ch340 one the other is USB serial device and   here now it's connected if I disconnect this one  of them disappear the one that disappeared is my board so six stays and it disappeared if I connect it so it is my comport ch340 now it is my  comport and I can select it or I can click   on tool port and here you will see it you can  select whichever you want ours is com8 now we   have successfully selected the board and the  port and this is very important it must be done first now make sure the board is  connected everything is ready let's   insert the formatted micro SD card  to the slot and click to upload the code now everything is done serial monitor here  everything is ready if the serial monitor is   not open click here and open it and make sure  that the bit rate for the serial monitor is   115,200 it must match this number otherwise  you will not be able to read the text now   we press reset so the MicroSD card or the  esp32 restarts and the serial monitor is   already open let's press this button so  these are normal information from esp32   and here file right success UC F and then  file found system volume zero and one file   found and that is called test.txt and it has 17  characters now I'm inserting MicroSD Cod to read it so let's double click to open  it and here is the test.txt file   let's double click to open it and  the text that we wrote is in here again and here let's create another  file test two and let's change the text test two for Robojax upload the code this was now let's reset the esp32 and  here uh when it runs it found the   test with 17 and test two with 20 this  is our latest and that was a previous one
Info
Channel: Robojax
Views: 1,984
Rating: undefined out of 5
Keywords: robojax, sun, founder, sunfounder, course, tutorial, kit, learn, learning, step by step, esp32, arduino, iot, micro, sd, microSD, card, read, write, use, log, how to, format, SD_MMC
Id: IoK1KvO2EwI
Channel Id: undefined
Length: 13min 12sec (792 seconds)
Published: Thu Dec 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.