Hi there,
I'm doing a project at the moment on a teensy 3.2 which requires me to write GPS data from a GPS module out to an SD card. In my setup() I try to create a file on the SD card and then write some a fake GPS
string to it. I put some Serial.println() inside the procedures being called but they don't get printed out which makes me think that they are being ignored altogether.
#include <SD.h>
#include <SPI.h>
#define GPS_SERIAL Serial3
char lati[20];
char longdi[20];
char nmea[82] = "";
boolean gpsDone = false;
volatile int counter = 0;
int CS_PIN = 10;
File file;
char DUMP_FILE[] = "gpsDumpFile.txt";
void setup() {
Serial.begin(115200);
Serial3.begin(9600);
startSD();
createFile("gpsdumpingfile.txt");
writeToFile("$GNGGA,,,,,,0,00,99.99,,,,,,*56");
closeFile();
attachInterrupt(7, readGPS, RISING);
}
void startSD() {
Serial.println("I am here");
pinMode(CS_PIN, OUTPUT);
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}
}
int createFile(char filename[])
{
file = SD.open(filename, FILE_WRITE);
if (file)
{
Serial.println("File created successfully.");
return 1;
} else
{
Serial.println("Error while creating file.");
return 0;
}
}
int writeToFile(char text[])
{
if (file)
{
file.println(text);
Serial.println("Writing to file: ");
Serial.println(text);
return 1;
} else
{
Serial.println("Couldn't write to file");
return 0;
}
}
void closeFile()
{
if (file)
{
file.close();
Serial.println("File closed");
}
}
int openFile(char filename[])
{
file = SD.open(filename);
if (file)
{
Serial.println("File opened with success!");
return 1;
} else
{
Serial.println("Error opening file...");
return 0;
}
}
Any help would be greatly appreciated, and sorry if I've just made a super silly error! Its quite like me to do that...