Hi,
I have been trying to make my argon work with Adafruit AdaLogger SD card and RTC to write something to an SD card but it still doesn’t work for some reason
I followed the script in this link example link
I am using an 32GB SD card
My code :
// This #include statement was automatically added by the Particle IDE.
#include <SdFat.h>
// The SD card CS pin on the Adafruit AdaLogger FeatherWing is D5.
const int SD_CHIP_SELECT = D5;
SdFat sd;
unsigned long lastTest = 0;
void tryMeFirst();
void setup() {
Serial.begin();
}
void loop() {
if (millis() - lastTest >= 10000) {
lastTest = millis();
tryMeFirst();
}
}
void tryMeFirst() {
File myFile;
// Initialize the library
if (!sd.begin(SD_CHIP_SELECT, SPI_FULL_SPEED)) {
Particle.publish("log","failed to open card");
return;
}
// open the file for write at end like the "Native SD library"
if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) {
Particle.publish("log","opening test.txt for write failed");
return;
}
// if the file opened okay, write to it:
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
myFile.printf("fileSize: %d\n", myFile.fileSize());
// close the file:
myFile.close();
Particle.publish("log","done.");
// re-open the file for reading:
if (!myFile.open("test.txt", O_READ)) {
Particle.publish("log","opening test.txt for read failed");
return;
}
Serial.println("test.txt content:");
// read from the file until there's nothing else in it:
int data;
while ((data = myFile.read()) >= 0) {
// Particle.publish("log",data);
}
// close the file:
myFile.close();
}