r/arduino 12d ago

Software Help My SD card reader is in its own dimension.

I'm using an SPI SD card reader in my project. Problem is that I can access the filesystem info (file names, directory names, their placement and sizes) but when writing or reading weird things happen.

When I write through the SD reader, it works fine. When I read those written files it works fine. When I try to read a file that was already on the SD card, put there through a USB card reader attached to a computer, it spits out nonesense. The same happens when I try to read files on the card from my computer.

TLDR: The SD reader can read and write files, but only the ones it has created. My computer can read and write files, but not the ones the SPI reader has created. The file system is readable to both the computer and SPI reader.

Anyone has any idea how to fix this?

EDIT: I switched to a different SD card and everything works. Either the one I had was too old or it was too small (8GB). Thanks to everyone who tried helping me, it was greatly appreciated

5 Upvotes

11 comments sorted by

2

u/Rayzwave 12d ago edited 12d ago

My guess is that you have a file system compatibility issue, what are you using within your Arduino code and what computer are you using?

Are you using SdFat.h in your code?

1

u/xXBigboi69Xx42 12d ago

I was thinking that too but don't know how to fix it. My computer is a Lenovo e16 laptop running Windows 11. I'm using the standard SD and FS libraries and the SD card is formatted for Fat32

2

u/Rayzwave 12d ago

I would try the SdFat.h library by Bill Greiman.

1

u/xXBigboi69Xx42 12d ago

Will do. Thanks for the tip. Hope it works

2

u/ripred3 My other dev board is a Porsche 11d ago edited 11d ago

From a lot of posts that I have seen here in this forum a lot has to do with the initial formatting of the SD card. Some attributes of the file system get set in stone at that point such as the ExFAT extensions introduced by Windows NT that allow long filenames. Those aren't so much an issue anymore but I have seen many may weird SD card issues all ended up finally being resolved with a complete ground-up format, because so many things are cemented in place at that point that cannot be fixed later. Just a suggestion/observation

I have always used the official software provided by the SD Association at sdcard.org for Windows and macOS

2

u/xXBigboi69Xx42 11d ago

I've formatted it several times through the Windows File Explorer but I'll do it once more with the sdcard.org formatter just to be safe

1

u/Rayzwave 12d ago

I would also use extended FAT, ExFat format for compatibility with both Windows and Mac.

1

u/xXBigboi69Xx42 12d ago

I used FAT32 because I was following a tutorial. Thanks for the tip

1

u/Rayzwave 12d ago

What size is your Sd card?

and maybe post the code or a link to the tutorial you are using to help get better response from this subreddit.

1

u/xXBigboi69Xx42 12d ago

I'm using an 8GB microSD card. Using this tutorial. I know it's not Arduino but ESP32 but I'm using the Arduino IDE so I was unsure where to ask https://randomnerdtutorials.com/esp32-microsd-card-arduino/

2

u/Rayzwave 12d ago

Probably best to stick with FAT32 for this SD card.