Hello Everyone
I am a newbie to use the teensy board, so please forgive me if I ask some stupid questions.
im using teensy 3.5 and a micro-SD slot for external SDcard, SD.h library, and SPI.h.
I have tried to save data to both cards but it creates long delays while opening and closing the files on both boards.
I chose the external SDcard because it's more accessible, now I want to save the files to the internal card every 30 min,
i can't find anywhere how to transfer a whole file from external to the internal card
any suggestions?
here are the init and the saving function:
void LoggerClass::init()
{
Serial.print("Initializing internal SD card...");
see if the card is present and can be initialized:
if (!SD.begin(BUILTIN_SDCARD))
{
Serial.println("Internal SD card failed, or not present");
return;
}
Serial.println("Internal SD card initialized.");
Serial.print("Initializing external SD card...");
// see if the card is present and can be initialized:
pinMode(SD_CARD_CHIP_SELECT_PIN, OUTPUT);//Test
if (!sd_ext.begin(SD_CARD_CHIP_SELECT_PIN))
{
Serial.println("External SD card failed, or not present");
return;
}
Serial.println("External SD card initialized.");
}
void LoggerClass::Log(char *line)
{
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("log.csv", FILE_WRITE);
// if the file is available, write to it:
if (dataFile)
{
dataFile.println(line);
dataFile.close();
}
// if the file isn't open, pop up an error:
else
{
Serial.println("Error opening internal SD log file in Error!");
}
dataFile = sd_ext.open("log.csv", FILE_WRITE);
// if the file is available, write to it:
if (dataFile)
{
dataFile.println(line);
dataFile.close();
}
// if the file isn't open, pop up an error:
else
{
Serial.println("Error opening external SD log file in Cycle");
}
}
thank you.
I am a newbie to use the teensy board, so please forgive me if I ask some stupid questions.
im using teensy 3.5 and a micro-SD slot for external SDcard, SD.h library, and SPI.h.
I have tried to save data to both cards but it creates long delays while opening and closing the files on both boards.
I chose the external SDcard because it's more accessible, now I want to save the files to the internal card every 30 min,
i can't find anywhere how to transfer a whole file from external to the internal card
any suggestions?
here are the init and the saving function:
void LoggerClass::init()
{
Serial.print("Initializing internal SD card...");
see if the card is present and can be initialized:
if (!SD.begin(BUILTIN_SDCARD))
{
Serial.println("Internal SD card failed, or not present");
return;
}
Serial.println("Internal SD card initialized.");
Serial.print("Initializing external SD card...");
// see if the card is present and can be initialized:
pinMode(SD_CARD_CHIP_SELECT_PIN, OUTPUT);//Test
if (!sd_ext.begin(SD_CARD_CHIP_SELECT_PIN))
{
Serial.println("External SD card failed, or not present");
return;
}
Serial.println("External SD card initialized.");
}
void LoggerClass::Log(char *line)
{
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("log.csv", FILE_WRITE);
// if the file is available, write to it:
if (dataFile)
{
dataFile.println(line);
dataFile.close();
}
// if the file isn't open, pop up an error:
else
{
Serial.println("Error opening internal SD log file in Error!");
}
dataFile = sd_ext.open("log.csv", FILE_WRITE);
// if the file is available, write to it:
if (dataFile)
{
dataFile.println(line);
dataFile.close();
}
// if the file isn't open, pop up an error:
else
{
Serial.println("Error opening external SD log file in Cycle");
}
}
thank you.