MicroSD Card Adapter With Level Shifters (HCMODU0074)

Modules for interfacing including USB to serial and SD adaptors.
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

MicroSD Card Adapter With Level Shifters (HCMODU0074)

Post by admin » Fri Nov 07, 2014 12:35 pm

Image

Description:
A microSD card reader and writer with included 3.3V regulator and level shifters making safe to interface with most 5V and 3.3V microcontrollers, including the Arduino Uno, Leonardo, Mega, Due, etc. The module uses an SPI interface for communication and is also compatible with the standard Arduino SD card library built into the Arduno IDE.

Features:
Supports: Micro SD Card, Micro SDHC (high-speed card)
Interface level: 5V or 3.3V
Power supply: 4.5V ~ 5.5V, 3.3V voltage regulator circuit board
Communication interface: Standard SPI
Control Interface: A total of six pins, GND, VCC, MISO, MOSI, SCK, CS
3.3V regulator circuit: LDO regulator output 3.3V
Level conversion circuit
Positioning holes: 4 x M2 screw holes for easy positioning. Hole diameter is 2.2mm

Pinout:

1....CS (Chip Select)
2....SCK
3....MOSI
4....MISO
5....VCC
6....GND


Image



Schematic:
Image



Arduino Example Write Sketch:

Code: Select all

/* FILE:    microSD_Card_Module_HCMODU0074_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 module 
(HCMODU0074). This module 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.

MODULE.....UNO/NANO
CS.........Arduino DIO 4
SCK........Arduino DIO 13
MOSI.......Arduino DIO 11
MISO.......Arduino DIO 12
VCC........+5V
GND........GND

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 modules CS pin */

File SDFileData;

/* Initialise serial and DIO */
void setup()
{
  Serial.begin(9600);
  /* DIO pin used for the modules CS function. Note that if you use a different 
     pin DIO 4 should still be configured as an output otherwise the SPI interface 
     may lock up.*/
  pinMode(4, OUTPUT);
}

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

  /* Initialise the microSD 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 microSD 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);
}

Arduino Example Read Sketch:

Code: Select all

/* FILE:    microSD_Card_Module_HCMODU0074_Read_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 Hobby Components SD card module 
(HCMODU0074). 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. 

MODULE.....UNO/NANO
CS.........Arduino DIO 4
SCK........Arduino DIO 13
MOSI.......Arduino DIO 11
MISO.......Arduino DIO 12
VCC........+5V
GND........GND

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 used for the modules CS function. Note that if you use a different 
     pin DIO 4 should still be configured as an output otherwise the SPI interface 
     may lock up.*/
  pinMode(4, OUTPUT);
}

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

  /* Initiliase the microSD 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

Return to “Adaptor”