7

I'm new to Arduino and electronics. I want to make a project including SD data-logger, but I had a problem. I would appreciate if someone show me where I made a mistake.

Firstly, circuit was set up as in picture:

Hardware setup

I am using 8 Gb micro SDHC card with SD adapter. I formatted in FAT32. I can play audio files which are in appropriate format and read and the print contents of text files.

But when I want to create a new file, strange file is obtained in SD card as in pic:

Directory listing

So I reformat SD card. the code that is used while creating file is as this;

// open a new file and immediately close it:
Serial.println("Creating example.txt...");
myFile = SD.open("example.txt", FILE_WRITE);
myFile.close();

Somewhere I read SDHC card with more than 2 Gb capacity is not supported in Arduino and I bought 2 Gb SD micro with SD adaptor.

But in this case aurduino does not detect SD card. please someone help me.

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125
dursung
  • 71
  • 1
  • 1
  • 2

2 Answers2

1

I've had similar issues with large (> 1Gb) SD cards, I've had various different problems with different cards, some things that helped me debugging the problem:

  • make sure your wires are the same length and try to use short wires
  • make sure your power supply is sufficient, sd card readers can draw up to 150mA
  • format the card in either FAT16 or FAT32 and never use "quick erase", try to use official tools (like https://www.sdcard.org/downloads/formatter_4/index.html)
  • make sure if you're the correct BAUD rate (9600) to talk to your card
  • filename support is pretty old so keep them short and don't use spaces or special characters
  • make sure the SD card is not in "write lock" mode, there's a small switch on the side of some SD cards that can prohibit writing (but will allow reading)
RecycleRobot
  • 136
  • 2
1

I have faced this problem. Try

  • If you are using multiple devices with SPI communication ignore the others by keeping their slave select HIGH
  • Never forget file.close()
Jim
  • 151
  • 1
  • 8