SD Card Slot Module, SPI Serial Peripheral Interface

  • Was  RM6.50 
  • RM4.50

  • Product Code: sd card slot
  • Availability: In Stock

This SD Card module can make your SD application more easier and simple. It is easily interfaced as a peripheral to your Arduino sensor shield module. Through programming, you can read and write to the SD card using your Arduino Can be used for SD Card more easily, such as for MP3 Player, MCU/ARM system control.

Features

  • 3.3v / 5v power supply 
  • 3.3v / 5v I/0 operation level compatible
  • Support FAT 16 & FAT 32 format
  • Standard 0.1" x 6 pin headers breakout

 

Connect SD Card Module with Arduino 

In this example we connect an SD card to our Arduino, we will log analog readings to a file on the SD card.

Enter the following sketch in Arduino IDE then upload it. If you open your Arduino serial monitor you will be able to see the progress.

#include <SD.h> //SD library comes with Arduino IDE
const int chipSelect = 4;

void setup()
{
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
  Serial.print(“Initializing SD card…”);
  pinMode(10, OUTPUT);
 
  //iniot SD card
  if (!SD.begin(chipSelect))
  {
    Serial.println(“Card failed, or not present”);
    return;
  }
  Serial.println(“card initialized.”);
}
 
void loop()
{
  String dataString = “”;
 
  // read three sensors and append to the string
  for (int analogPin = 0; analogPin < 3; analogPin++)
  {
     int sensor = analogRead(analogPin);
     dataString += String(sensor);
     if (analogPin < 2)
     {
       dataString += “,”;
     }
   }
 
  // open the file.
  File dataFile = SD.open(“data.txt”, FILE_WRITE);
 
  // if the file is available, write to it:
  if (dataFile)
  {
     dataFile.println(dataString);
     dataFile.close();
  }
  // if the file isn’t open
  else
  {
     Serial.println(“error opening data.txt”);
  }
}

Libraries

The default Arduino library for SD card is huge! With the example read/write sketch, when compiled it’s 13690 Bytes which is half of the available flash space on an Arduino pro mini!

So if you are tight in sketch space, it’s a good idea to find a smaller library. Depends on the SD cards you have and the format you want to use, you have these options.

FAT32 Format (larger than 2GB card)

FAT16 Format (smaller than 2GB card)

I haven’t tested all of these libraries, so do your research and test them before using it.

Reference:

Write a review

Note: HTML is not translated!
    Bad           Good

 

Related Products

Tags: Storage, SD