Connect an SPI SD Card to Your Arduino - connection and coding

  Рет қаралды 10,425

Bytes N Bits

Bytes N Bits

Күн бұрын

Пікірлер: 25
@donaldkormos5529
@donaldkormos5529 8 ай бұрын
Thanks for video!! Order couple SD modules and try experimenting soon. Cheers ...
@BytesNBits
@BytesNBits 8 ай бұрын
Have fun!
@distortion_tech_lab
@distortion_tech_lab 4 ай бұрын
Darn. Should have watched this video before I ordered my level shifters 🤣 this works how I expected mine to work.
@BytesNBits
@BytesNBits 4 ай бұрын
These ones are really good and very easy to get working in both directions.
@jumbo999614
@jumbo999614 2 ай бұрын
How to use SD card if ESP32 is used? I able to draw graphic and touch function but I can't get SD card to work. I found this tutorial ->kzbin.info/www/bejne/kJ6whaVugaqUZ6M Is this only way to fix the problem? I'm not good with soldering. I don't want to fry my ESP32 and TFT.
@BytesNBits
@BytesNBits 2 ай бұрын
You can buy ESP32 models with the SD card slot built in. Otherwise you'll need to write a card adapter in to your circuit.
@josegarcia-sv2sh
@josegarcia-sv2sh Жыл бұрын
do you have the code for this example? thanks...
@BytesNBits
@BytesNBits Жыл бұрын
Here's the code from the tutorial. It might be that your compiler is complaining about there being an empty function in the loop function. Try adding something in there. #include "SPI.h" #include "SD.h" #define SD_CLK 13 #define SD_MISO 12 #define SD_MOSI 11 #define SD_CS 6 void setup() { Serial.begin(115200); // avoid chip select contention pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH); if (!SD.begin(SD_CS)) { Serial.println("SD Card initialization failed!"); while(true){ ; } } else { Serial.println("SD Card OK!"); } // check if directory / folder exists and create if (!SD.exists("/data")){ SD.mkdir("/data"); } // create folder for next data run int folderCounter = 1; String baseFolder = "/data/run"; while(SD.exists(baseFolder + folderCounter)){ folderCounter ++; } String runFolder = baseFolder + folderCounter; Serial.println("Folder for this run = " + runFolder); SD.mkdir(runFolder); runFolder = runFolder + "/"; // check if file exists and delete if (SD.exists(runFolder + "my_file.txt")){ SD.remove(runFolder + "my_file.txt"); } // create new file File myFile = SD.open(runFolder + "my_file.txt", FILE_WRITE); Serial.println("Created new file"); // put some text in the file myFile.print("This was created on run "); myFile.println(folderCounter); Serial.print("First line of text added to file on run"); Serial.println(folderCounter); // close file myFile.close(); // open file for reading myFile = SD.open(runFolder + "my_file.txt", FILE_READ); // output file contents to serial monitor char nextChar; byte nextByte; while(myFile.available()){ nextChar = myFile.read(); Serial.write(nextChar); } // close file myFile.close(); } void loop() { }
@e-twinningproject4693
@e-twinningproject4693 Жыл бұрын
hi sir, how can i display movie using tft 2.8
@BytesNBits
@BytesNBits Жыл бұрын
Hi. With an arduino you're not going to be able. It hasn't the processing power or memory to do it. Most microcontrollers (Pi Pico, ESP32, etc) would really struggle with this task and give only a couple of frames per second (if that!).
@boacmihnea5463
@boacmihnea5463 9 ай бұрын
Hello, thank you for the tutorial. I have the following questions: is there a limit on the capacity of the SD card? I'm asking because I'm having trouble using a 16 Gb SD card. Can't find anywhere the specs of the SD part of this hardware. Thank you.
@BytesNBits
@BytesNBits 9 ай бұрын
FAT32 should be fine up to 32GB but as you mention the board itself might be limiting you. Individual files should be less than 4GB if you're hitting issues with large files.
@boacmihnea5463
@boacmihnea5463 9 ай бұрын
Thank you! 👍
@waynehawkins654
@waynehawkins654 11 ай бұрын
Excellent. Thank you for the video, well explained. Question? If I was storing a large amount of data, say a data logger (Date\Time and Sample). EG 2023-10-28T23:00:00 100.1 And this was 1000s of sample values. How can I loop each line fast and read that line based on a index or line number on the file. That is not read the whole file and then loop, but somehow read a line directed on the SD card and return only that line. This way I don't have to store something that could be 4GB in size. EG - read line 10,009 and get what this line is?
@BytesNBits
@BytesNBits 11 ай бұрын
I guess there are a couple of routes. I have seen some SD card libraries that seem to allow random access to files. Have a look at mySD - github.com/nhatuan84/esp32-micro-sdcard/tree/master The other option is to break the data stream up into manageable chunks e.g. 100 samples per file and then save these with numeric file names, e.g. 1.txt, 2.txt. You'll then be able to pick out a block of 100 samples by filename. You might have to be careful about the number of files allowed in any folder, especially when you get to many thousands. You'd then need to use folders. e.g. folder 0000 contains data files 0-999, folder 0001 files 1000-1999, etc. You can then have 1000 folders of 1000 files. Hope this helps.
@waynehawkins654
@waynehawkins654 11 ай бұрын
@@BytesNBits Thank you for this. Will look into the mySD option. But a good idea to do lots of files, seen this before and explains why people have done things this way.
@BytesNBits
@BytesNBits 11 ай бұрын
@@waynehawkins654 No problem. Hope you get it working 😃
@umutkayacan7659
@umutkayacan7659 3 жыл бұрын
Nice video!
@BytesNBits
@BytesNBits 3 жыл бұрын
Thanks!
@josegarcia-sv2sh
@josegarcia-sv2sh Жыл бұрын
I copied that code on video and I got some erros: C:\Users\pc\AppData\Local\Temp\cc6WS8wb.ltrans0.ltrans.o: In function `main': C:\Users\pc\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:46: undefined reference to `loop' collect2.exe: error: ld returned 1 exit status Se encontraron varias bibliotecas para "SD.h" Usado: C:\Users\pc\Documents\Arduino\libraries\SD No utilizado: C:\Users\pc\AppData\Local\Arduino15\libraries\SD exit status 1 Compilation error: exit status 1
@jumbo999614
@jumbo999614 2 ай бұрын
I always have similar problem. It is because of unmatched "{ " or "}" probably your loop is inside setup().
@cansatmessi2.0
@cansatmessi2.0 Жыл бұрын
hi, do you know how can i connect two arduinos to the same sd card without having problems with the MOSI pin?
@BytesNBits
@BytesNBits Жыл бұрын
Hi. You need to isolate the output pins from each Arduino when it's not driving the SPI bus. Have a look at tri state buffers which will let you disconnect from the sd card, or have a play with setting the Arduino pins to their weak pull up state when not in use - not sure how this will affect the spi library code.
@oussimakh2330
@oussimakh2330 2 жыл бұрын
Hello how are you , I am trying to make a project with arduino Leonardo and 3.5 TFT LCD the project i want make it as timer controller of cocking food can you help me please
@BytesNBits
@BytesNBits 2 жыл бұрын
The Leonardo should work very much the same as the Uno in the video. You just need to make sure you connect to the right pins and adjust the software setup accordingly.
小天使和小丑太会演了!#小丑#天使#家庭#搞笑
00:25
家庭搞笑日记
Рет қаралды 35 МЛН
规则,在门里生存,出来~死亡
00:33
落魄的王子
Рет қаралды 26 МЛН
Using SD Cards with Arduino - Record Servo Motor Movements
31:53
DroneBot Workshop
Рет қаралды 199 М.
ESP-NOW - Peer to Peer ESP32 Network
43:02
DroneBot Workshop
Рет қаралды 363 М.
EEPROM Memory - Store Anything - Arduino101
13:16
Electronoobs
Рет қаралды 106 М.
Understanding Arduino Interrupts | Hardware, Pin Change & Timer Interrupts
48:17
MBR & GPT hard drives. What does it mean and which to choose?
10:43
Basic animation in your SPI LCD touchscreen
41:04
Bytes N Bits
Рет қаралды 22 М.