Arduino Compatible SD card Shield (HCARDU0087)

Post Reply
admin
Site Admin
Posts: 725
Joined: Sun Aug 05, 2012 4:02 pm

Arduino Compatible SD card Shield (HCARDU0087)

Post by admin » Wed Nov 12, 2014 10:15 am

Image

Description:
This SD Card Shield is compatible with Arduino development boards that have the standard Arduino header layout. It can be directly plugged into and Arduino UNO, Leonardo, MEGA2560 or compatible motherboard and with the addition of an SD card add a huge data storage space to your Arduino project. The shield is also compatible with the standard Arduino SD card libraries that are supplied with the Arduino development environment allowing you to write sketches to read and write data to your SD card. It also has the advantage of a module in that no additional wiring is required - just plug it into your Arduino board and you're ready to go.

Order Yours Here.


Features:
Standard Arduino expansion board interface, shape, compatible with Arduino UNO, Leonardo, Mega 2560 and compatible motherboards
Built in level shifters make it safe to interface to bot 5V and 3.3V logic levels.
Communication interface is a standard SPI interface, which only supports SD / TF card SPI mode communication
Supports SD / SDHC or Micro SD / Micro SDHC with SD adaptor
Power supply is 4.5V ~ 5.5V, 3.3V voltage regulator circuit board
SPI Interface: MOSI, MISO, SCK pin these three signals are taken from the Arduino's ICSP interface making it compatible with a variety of Arduino boards..
Regulator circuit: LDO regulator output 3.3V
Chip Select Pin: CS pin is connected to the Arduino board D4 digital pin;


Schematic:
Image

Example Write Sketch:

Code: Select all

/* FILE:    SD_CARD_SHIELD_HCARDU0087_Write_Example
   DATE:    12/11/14
   VERSION: 0.1
   
REVISIONS:

12/11/14 Created version 0.1

This is an example of how to use the HobbyComponents SD card shield 
(HCARDU0087). This shield allows reading and writing of data to a standard 
SD card and is useful for applications such as data loggers where a large 
amount of data needs to be stored. The module works with the standard 
Arduino SD card library.

This example program will create a test file on the SD card called test.txt
If the file already exists it will first delete it and then create a new 
one.

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, 
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR 
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */

/* Include the standard SD card library */
#include <SD.h>

#define SD_CARD_CD_DIO 4 /* DIO pin used to control the shield CS pin */

File SDFileData;

/* Initialise serial and DIO */
void setup()
{
  Serial.begin(9600);
  /* DIO pin used for the CS function. */
  pinMode(4, OUTPUT);
}

/* Main program loop */
void loop()
{

  /* Initialise the SD card */
  if (!SD.begin(SD_CARD_CD_DIO)) 
  {
    /* If there was an error output this to the serial port and go no further */
    Serial.println("ERROR: SD card failed to initiliase");
    while(1);
  }else
  {
    Serial.println("SD Card OK");
  }
  
 
   /* Check if the text file already exists */
   while(SD.exists("test.txt"))
   {
     /* If so then delete it */
     Serial.println("test.txt already exists...DELETING");
     SD.remove("test.txt");
   }
 
  /* Create a new text file on the SD card */
  Serial.println("Creating test.txt");
  SDFileData = SD.open("test.txt", FILE_WRITE);
  
  /* If the file was created ok then add come content */
  if (SDFileData)
  {
    SDFileData.println("It worked !!!");
  
    /* Close the file */
    SDFileData.close();   
    
    Serial.println("done.");
  }else
  {
      Serial.println("Error writing to file !");
  }
  
  /* Do nothing */
  while (1);
}

Example Read Sketch:

Code: Select all

/* FILE:    D_Card_Shield_HCARDU0087_Read_Example.pde
   DATE:    12/11/14
   VERSION: 0.1

REVISIONS:

12/11/14 Created version 0.1
   
This is an example of how to use the Hobby Components SD card shield 
(HCARDU0087). This shield allows reading and writing of data to a standard 
SD card and is useful for applications such as data loggers where a large 
amount of data needs to be stored. The module works with the standard 
Arduino SD card library.

This example program will attempt to read a text file named text.txt and 
output its contents to the serial port. 

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, 
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR 
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */

/* Include the standard SD card library */
#include <SD.h>

#define SD_CARD_CD_DIO 4 /* DIO pin used to control the shields CS pin */

File SDFileData;

/* Initialise serial and DIO */
void setup()
{
  Serial.begin(9600);
  /* DIO pin uesd for the CS function. */
  pinMode(4, OUTPUT);
}

/* Main program loop */
void loop()
{

  /* Initiliase the SD card */
  if (!SD.begin(SD_CARD_CD_DIO)) 
  {
    /* If there was an error output this to the serial port and go no further */
    Serial.println("ERROR: SD card failed to initiliase");
    while(1);
  }else
  {
    Serial.println("SD Card OK");
  }
  
 
   /* Check if the text file exists */
   if(SD.exists("test.txt"))
   {
     Serial.println("test.txt exists, attempting to read file...");

     /* The file exists so open it */
     SDFileData = SD.open("test.txt");
     
     /* Sequentially read the data from the file and output it's
        contents to the UART */
     while (SDFileData.available())
     {
       Serial.write(SDFileData.read());
     }
     
     /* Close the file */
     SDFileData.close();  
   }
 
  
  /* Do nothing */
  while (1);
}

Post Reply