Micro SD TF Card Memory Module [S059]



https://www.youtube.com/watch?v=Sn58KLbRQpA


*GitHubhttps://github.com/rdiot/rdiot-s059.git


* Specs

Features:

Support Micro SD Card, Micro SDHC card (high-speed card)

The level conversion circuit board that can interface level is 5V or 3.3V

Communication interface is a standard SPI interface

Control Interface: A total of six pins (GND, VCC, MISO, MOSI, SCK, CS), GND to ground,

VCC is the power supply, MISO, MOSI, SCK is the SPI bus, CS is the chip select signal pin;

3.3V regulator circuit: LDO regulator output 3.3V as level converter chip, Micro SD card supply;

Level conversion circuit: Micro SD card into the direction of signals into 3.3V, MicroSD card toward the direction of the control interface MISO signal is also converted to 3.3V, general AVR microcontroller system can read the signal;

Micro SD card connector: yes since the bomb deck for easy card insertion and removal.

Positioning holes: 4 M2 screws positioning hole diameter of 2.2mm, easy to install positioning, to achieve inter-module combination;


Specifications:

Power supply:4.5V - 5.5V, 3.3V voltage regulator circuit board

Positioning holes: 4 M2 screws positioning hole diameter of 2.2mm

Control Interface: GND, VCC, MISO, MOSI, SCK, CS

Size:45 x 28mm

Net weight:6g


* Contents

- Connect

CS   ----- D4

SCK  ----- D13

MOSI ----- D11

MISO ----- D12

VCC  ----- 5V

GND  ----- GND

 

- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

#include <SPI.h>

#include <SD.h> // include the SD library


LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004


File myFile;


void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");


  delay(1000);

  lcd.clear();


  lcd.setCursor(0,0);

  lcd.print("S059:microSD Adapter");


  lcd.setCursor(0,1);

  lcd.print("Initializing SD Card");


  if (!SD.begin(4)) {

    lcd.setCursor(0,1);

    lcd.print("Initialize Failed   ");

    return;

  }


  lcd.setCursor(0,1);

  lcd.print("Initialization done");


  myFile = SD.open("test5.txt", FILE_WRITE);


  // if the file opened okay, write to it:

  if (myFile) {


    lcd.setCursor(0,1);

    lcd.print("Writing to test.txt ");

    myFile.println("text");

    

    // close the file:

    myFile.close();

    lcd.setCursor(0,2);

    lcd.print("writing done.");

  } else {


    lcd.setCursor(0,2);

    lcd.print("error opening test.txt");

  }


  // re-open the file for reading:

  myFile = SD.open("test5.txt");

  if (myFile) {

    lcd.setCursor(0,3);

    lcd.print("Read test.txt:");


    // read from the file until there's nothing else in it:

    while (myFile.available()) {

      lcd.write(myFile.read());


    } 

    // close the file:

    myFile.close();

  } else {

    // if the file didn't open, print an error:

    lcd.setCursor(0,2);

    lcd.print("error opening test.txt");

  }


}

Posted by RDIoT
|