
Reference: RBD-1402
Banner
Allows MicroSD cards to be written and read
(edit with the Customer Reassurance module)
(edit with the Customer Reassurance module)
(edit with the Customer Reassurance module)
This MicroSD card module allows MicroSD cards to be written and read for applications that create or need access to large quantities of data.
SD cards are commonly used for applications such as temperature logging where the time and temperature are recorded over long periods of time. It can also be used to serve large amounts of data such as graphic images.
This MicroSD card module should be thought of as a raw card slot and operates at 3.3V which is the voltage the MicroSD card operates at. The data lines must be at 3.3V logic levels to prevent damage to the MicroSD card and so this module is best used with 3.3V MCUs. If used with a 5V MCU, external logic level shifters are required for the SPI bus lines to avoid damage.
The data lines have 10K pull-up resistors to 3.3V on the module.
The 3.3V current draw will depend on the card being used with the module. When inactive the card may draw 500uA. When reading the card, 15-30mA is common. Write operations take more current and some cards are reported to require up to 100mA for write operations so this should be taken into consideration for selecting the power source. The Arduino 3.3V power which is typically good for about 30-50mA will typically work OK for reading the card, but may be insufficient for write operations. If you experience writing issues, this is the first thing to check.
The module has a male header installed. The module can be inserted directly into a breadboard which is handy since the pin labeling is visible or female Dupont style jumpers can be used to make connections to it.
1×6 Header
In the example we are using here, we are using the Mega 2560 Pro with level shifters.
Insert a MicroSD card into the module and wire up 3.3V and ground and the SPI pins as follows:
The IDE example program SD/CardInfo is a good way to test the basic setup and card. A slightly pruned down version is shown below.
You may need to change this line of code to match the SPI chip select pin for your MCU: const int chipSelect = 53;
An example output of the program is shown below.
/* SD card test This example shows how use the utility libraries on which the' SD library is based in order to get info about your SD card. Very useful for testing a card when you're not sure whether its working or not. Connect 3.3V power and ground. Connect MOSI to MOSI - pin 11 on Uno, 51 on Mega 2560 Connect MISO to MISO - pin 12 on Uno, 50 on Mega 2560 Connect CLK to CLK - pin 13 on Uno, 52 on Mega 2560 Connect CS to SPI Chip select - Pin 10 on Uno, 53 on Mega 2560 */ // include the SD library: #include <SPI.h> #include <SD.h> // set up variables using the SD utility library functions: Sd2Card card; SdVolume volume; SdFile root; // change this to match your SD shield or module; const int chipSelect = 53; void setup() { Serial.begin(9600); } Serial.print("nInitializing SD card..."); // we'll use the initialization code from the utility libraries // since we're just testing if the card is working! if (!card.init(SPI_HALF_SPEED, chipSelect)) { Serial.println("initialization failed. Things to check:"); Serial.println("* is a card inserted?"); Serial.println("* is your wiring correct?"); Serial.println("* did you change the chipSelect pin to match your shield or module?"); while (1); } else { Serial.println("Wiring is correct and a card is present."); } // print the type of card Serial.println(); Serial.print("Card type: "); switch (card.type()) { case SD_CARD_TYPE_SD1: Serial.println("SD1"); break; case SD_CARD_TYPE_SD2: Serial.println("SD2"); break; case SD_CARD_TYPE_SDHC: Serial.println("SDHC"); break; default: Serial.println("Unknown"); } // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32 if (!volume.init(card)) { Serial.println("Could not find FAT16/FAT32 partition.nMake sure you've formatted the card"); while (1); } Serial.print("Clusters: "); Serial.println(volume.clusterCount()); Serial.print("Blocks x Cluster: "); Serial.println(volume.blocksPerCluster()); Serial.print("Total Blocks: "); Serial.println(volume.blocksPerCluster() * volume.clusterCount()); Serial.println(); // print the type and size of the first FAT-type volume uint32_t volumesize; Serial.print("Volume type is: FAT"); Serial.println(volume.fatType(), DEC); volumesize = volume.blocksPerCluster(); // clusters are collections of blocks volumesize *= volume.clusterCount(); // we'll have a lot of clusters volumesize /= 2; // SD card blocks are always 512 bytes (2 blocks are 1KB) Serial.print("Volume size (Kb): "); Serial.println(volumesize); Serial.print("Volume size (Mb): "); volumesize /= 1024; Serial.println(volumesize); Serial.print("Volume size (Gb): "); Serial.println((float)volumesize / 1024.0); Serial.println("nFiles found on the card (name, date and size in bytes): "); root.openRoot(volume); // list any files in the card with date and size root.ls(LS_R | LS_DATE | LS_SIZE); } void loop(void) { }
Specific References
Your review appreciation cannot be sent
Report comment
Report sent
Your report cannot be sent
Write your review
Review sent
Your review cannot be sent
Reference: RBD-1402
Reference: RBD-2552
Reference: RBD-2833
Reference: RBD-2293
Reference: RBD-1367
Reference: RBD-2306
Reference: RBD-2672
Reference: RBD-2564
Reference: RBD-2557
Reference: RBD-1635
Reference: RBD-1808
Reference: RBD-2307
Reference: RBD-0028
Reference: RBD-1573
Reference: RBD-0346
Reference: RBD-2065
Allows MicroSD cards to be written and read
check_circle
check_circle