Xinyuan-LilyGO / T-CAN485

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TF Card Read/Write Documentation

Rojasoterom opened this issue · comments

Hi, i have problems making TF Card works. I'm trying to use RS485 and SD but when i use SD.begin, RS485 data was not readed.

Lastly, i try the following program to use only TF card. But without connect to the card:

#include <SD.h>
#include <SPI.h>

File myFile;

void setup()
{
  Serial.begin(9600);
  Serial.print("Iniciando SD ...");
  if (!SD.begin(13)) {
    Serial.println("No se pudo inicializar");
    return;
  }
  Serial.println("inicializacion exitosa");

  myFile = SD.open("archivo.txt");//abrimos  el archivo 
  if (myFile) {
    Serial.println("archivo.txt:");
    while (myFile.available()) {
    	Serial.write(myFile.read());
    }
    myFile.close(); //cerramos el archivo
  } else {
    Serial.println("Error al abrir el archivo");
  }
}

void loop()
{
  
}

After few test, for me is works using mySD and the following begin:

  if (!SD.begin(13,15,2,14)) {            //T1:13,15,2,14  T2: 23,5,19,18 M5:4,23,19,18 uint8_t csPin, int8_t mosi, int8_t miso, int8_t sck
      Serial.println("initialization failed!");
      return;
    }
    Serial.println("initialization done.");