From ArduinoInfo
Revision as of 18:30, 5 February 2019 by TerryKing (talk | contribs) (Text replacement - "</div>" to "")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


(This Module is available here: CLICK) See the SCHEMATIC DIAGRAM here:
The SHIELD version is available here: CLICK


SD Cards work only at 3.3V and both the power and I/O levels must be accommodated. The module shown here uses FETs for level shifting and a 3.3V regulator for power when operating from 5.0V . A switch allows the module to be used with Arduinos / YourduinoRoboRED or Minis etc. running at 3.3V. We have tested the YourDuinoRoboRED with it's power jumper set to 3.3V and the SD card module set at 3.3V and it works well.

This module also has a MicroSD socket on the back side, and we have tested 2Gb and 4Gb MicroSD cards plugged in there. They worked OK with the SdFAT library. These cards are formatted FAT32 and SD/HC.

NOTE: It is recommended to format SD cards to be used, with Panasonic's formatter, available here: The SdFAT Library also includes a sketch that can format cards well.

NOTE: There are many variables in getting SD cards to work well with Arduino. Some SD cards work fine, some do not. See ABOUT DIFFERENT SD CARDS below. If you have good or bad experiences with different modules or shields, or SD cards, please email and we will try to incorporate your learning here.

ITEAD-SD-5-3v3-500.jpgUSE WITH ARDUINO/YourDuino 328 or UNO versions:

The Arduino hardware pages on the official site shows the following pin names:
10 (SS) "Slave Select"
11 (MOSI) "Master Out Slave In"
12 (MISO) "Master In Slave Out"
13 (SCK) "System Clock"

To clarify this: to connect this module you must connect:
(Arduino Pin) - Module Pin
10 (SS) to CS
11 (MOSI) to DI
12 (MISO) to DO
13 (SCK) to CLK
and G to GND and + to 5V
AND.. Switch the switch to 5V for any Arduino running on 5V.

USE WITH ARDUINO/YourDuino MEGA versions:

The Arduino hardware page for Arduino Megas shows this pinout, so needed connections are:
50 (MISO) to DO
51 (MOSI) to DI
52 (SCK) to CLK
53 (SS) to CS
and G to GND and + to 5V
AND.. Switch the switch to 5V for any Arduino running on 5V.

These Mega pins support SPI communication using the SPI library. The SPI pins are also broken out on the ICSP header, which is physically compatible with the Uno, Duemilanove and Diecimila.


To Test your module and test some SD cards, start with the SdFAT library, which has many test and troubleshooting software sketches in it's Examples folder. After you have copied the SdFAT folder to your libraries folder, load the QuickStart sketch as shown on the right. If you can't see this, you don't have the SdFAT library copied into your libraries folder.

Get the SdFAT Library (latest one at top) HERE:
SdFAT is a large but fully-featured library:
SdFAT is an Arduino library that supports FAT16 and FAT32 file systems on standard and high capacity SD cards. SdFat Now supports long file names.
SdFat supports file creation, deletion, read, write, and truncation. SdFat supports access to subdirectories, creation, and deletion of subdirectories. Use of SdFat is illustrated by a large number of examples in the SdFAT/examples directory. SdFAT now supports Arduino 1.X

TEST your SD Card Module or shield:

Check: Your connections as above: Caution: they are not in exact sequence order. Be sure.
Upload QuickStart to your Arduino/YourDuino.
Start Serial Monitor.
Follow the instructions. You need to put your cursor in the box at the top of the Serial Monitor to be able to type things to run the program.

You should see this on the Serial Monitor Screen:
SD chip select is the key hardware option.
Common values are:
Arduino Ethernet shield, pin 4
Sparkfun SD shield, pin 8
Adafruit SD shields and modules, pin 10
The default chip select pin number is pin 10

Enter the chip select pin number: 10 [YOU ENTER THIS. 10 for our module. ]

---------------------( COPY )--------------------------
Card successfully initialized.
Card size: 4089 MB (MB = 1,000,000 bytes) [This is a 4Gb SD/HC card]
Volume is FAT32, Cluster size (bytes): 32768

Files found (name date time size):
MISC/ 2012-04-26 22:10:40
DCIM/ 2012-04-26 22:10:40
152_PANA/ 2012-04-26 23:36:40
P1520541.JPG 2012-04-26 23:36:42 2941193
P1520542.JPG 2012-05-02 03:41:14 3053950
P1520575.JPG 2012-05-21 15:05:24 3653436

Success! Type any character to restart.
-----------------( END COPY )----------------------


Some SD cards work fine, some do not. You may have to try a few..
Most cards have good SPI read performance but cards vary widely in SPI write performance. Write performance is limited by how efficiently the card manages internal erase/remapping operations. The Arduino cannot optimize writes to reduce erase operations because of its limited RAM.

SanDisk cards generally have good write performance. They seem to have more internal RAM buffering than other cards and therefore can limit the number of flash erase operations that the Arduino forces due to its limited RAM.
Some Dane-Elec cards have a write speed that is only 20% as fast as a good SanDisk card.

NOTE: QuickStart runs SD cards at 1/2 the maximum possible speed. We have not been able to get any cards to run at Maximum speed.


If you have things working OK and need to minimize the size of the library loaded on the Arduino with your application you can:

Get the "TinyFAT" Arduino Software Library here:
You can find the latest version of the library at
The library supports FAT16 formatted SD cards up to 2GB in size. 4GB FAT16 formatted SD cards might work, but is untested. Long filenames are not supported. Keep your filenames compliant with the old 8.3 standard. The SD card should be connected to the SPI-pins on your Arduino. Pin connections are available in the documentation in the download.
NOTE: This library worked well with a 1GB SD card that was formatted FAT16. This library will NOT work with larger cards that are formatted FAT32.

Get the smaller fat16lib Here:
NOTE: Were unable to get this library to work with the 1Gb FAT16 card that worked with TinyFAT.

The Arduino FAT16 Library is a minimal implementation of the FAT16 file system on standard SD flash cards. The class implementing the library, Fat16, supports read, write and file creation.
Fat16 is derived from the Arduino Print base class so files can be written using print() and println().
Fat16 only allows access to files in the root directory and only supports short 8.3 file names.