Description:
A microSD card reader module with built in 3.3V level shifter which allows safe interfacing to any microSD cards that support an SPI interface. This module has primarily been designed to work with our RAMPS compatible 3D printer shield (See HC3DPR0002 in our shop). The module will directly interface with the AUX-3 connector on the RAMPS shield.
Although designed for this purpose in mind, this module will work fine with any microcontoller with 5V tolerant DIO that supports a hardware or software SPI interface (see example Arduino sketch below)
PINOUT:
1...VCC
2...N/A
3...MISO
4...MOSI
5...SCK
6...CS
7...N/A
8...N/A
26/02/2015 Please note: We are currently chipping an alternative SD ramps version with a slightly different connector. However pinout is in the same order. Please see diagram below for more information:
Example Arduino Sketch:
Code: Select all
/* FILE: ARD_SDRAMPS_MICROSD_MODULE_HCMODU0041_READ_EXAMPLE
DATE: 11/10/13
VERSION: 0.1
REVISIONS:
11/10/13 Created version 0.1
This is an example of how to use the HobbyComponents SDramps microSD card
reader module (HCMODU0041). This module allows reading and writing of data
to a standard microSD card and is useful for applications such as 3D printers,
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.
PINOUT:
Module UNO/NANO
PIN 1: VCC ---> +5V
PIN 2: N/A ---> N/A
PIN 3: MISO ---> D12
PIN 4: MOSI ---> D11
PIN 5: SCLK ---> D13
PIN 6: CS ---> D4
PIN 7: GND ---> GND
PIN 8: N/A ---> N/A
PIN 9: N/A ---> N/A
PIN 10: N/A ---> N/A
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 for the purpose of premoting or selling 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 CS function. Note that even if you are not driving this
function from your Arduino board, you must still configure this as an output
otherwise the SD library functions will not work. */
pinMode(10, 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);
}