Difference between revisions of "Micro SD(TF) Storage Board"

From CQRobot-Wiki
Jump to: navigation, search
Line 101: Line 101:
  
 
Connect according to the wiring diagram, upload the code, and after power on, open the serial monitor and set the baud rate to 9600, as shown in the figure below.
 
Connect according to the wiring diagram, upload the code, and after power on, open the serial monitor and set the baud rate to 9600, as shown in the figure below.
 +
{|-
 
|[[File:TF-Card_Slot-5.jpg |left|850px]]
 
|[[File:TF-Card_Slot-5.jpg |left|850px]]
 +
|}
 
Set in the code, we create a TEST.txt file in the TF (Micro-SD) card, and write "Hello, world!" in the file, then read the content in the TEST.txt file and display it on the monitor.
 
Set in the code, we create a TEST.txt file in the TF (Micro-SD) card, and write "Hello, world!" in the file, then read the content in the TEST.txt file and display it on the monitor.

Revision as of 06:43, 10 August 2020

TF Card Read-Write Module

Introduction

TF card is the most commonly used storage element of interactive media equipment. CQRobot Micro SD(TF) Storage Board card read-write module adopts SPI communication method and can be used to read or write data to TF card. When we use it, we only need to insert the TF card on the module, connect the module to the single chip, and we can read and write the TF card through the single chip code.

At the same time, in order to facilitate fixing the module on other equipment, the module comes with two positioning holes with a diameter of 3mm.

Features

  • Micro SD card slot
  • Supports SDIO and SPI interfaces
  • 2.54mm pitch pinheaders

Product Size

TF-Card Slot-2.jpg

Interface Definition

TF-Card Slot-3.jpg

Connection Diagram

TF-Card Slot-4.jpg

Specifications

  • Working Voltage : DC 3.3V
  • Working Current : about 10mA
  • Maximum Power : 0.1W
  • Operating Temperature Range : -25 to 70 Degrees Celsius
  • Pin Header Type : 2.54mm pitch 9Pin single row pin header
  • Product Size : 23 mm * 34 mm * 8 mm
  • Card Slot Type : Self-ejection TF (Micro-SD) card Slot socket

Demo for Arduino

Note: Before uploading the code, the corresponding library file must be placed in the library file folder where the Arduino IDE is installed.


  1. include <SPI.h>
  2. include <SD.h>

File myFile;

void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) {

// wait for serial port to connect. Needed for Leonardo only

} Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work. pinMode(10, OUTPUT); if (!SD.begin(4)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. myFile = SD.open("test.txt", FILE_WRITE); // if the file opened okay, write to it: if (myFile) { Serial.print("Writing to test.txt..."); myFile.println("Hello,world!"); // close the file: myFile.close(); Serial.println("done."); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } // re-open the file for reading: myFile = SD.open("test.txt"); if (myFile) { Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { Serial.write(myFile.read()); } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } }

void loop() { // nothing happens after setup }


Test Methods and Results

Connect according to the wiring diagram, upload the code, and after power on, open the serial monitor and set the baud rate to 9600, as shown in the figure below.

TF-Card Slot-5.jpg

Set in the code, we create a TEST.txt file in the TF (Micro-SD) card, and write "Hello, world!" in the file, then read the content in the TEST.txt file and display it on the monitor.