Happy Friday, I am trying to record microphone data from a Max4466 onto an Adafruit ADA254 break out board. After a few hours reading post, Chat GPT, and documentation I finally had code that wasn't failing. However, I am still not creating any files on the 32GB SD card. I am using SdFat 1.1.0 which should be supported on the monitor one Tsom. Here is how I have it wired.
And here is the code I am using.
#include "Particle.h"
#include "SdFat.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
constexpr int CS_PIN = D2; // moved CS to D2
SdFat SD;
SdFile testFile;
void setup() {
Serial.begin(9600);
waitFor(Serial.isConnected, 10*1000);
Serial.print("Init SD… ");
// try hardware SPI on D4–D6, CS on D2
if (!SD.begin(CS_PIN, SD_SCK_MHZ(10))) {
Serial.println("❌ failed");
return;
}
Serial.println("✅ OK");
// write a little file
if (!testFile.open("test.txt", O_WRITE | O_CREAT | O_TRUNC)) {
Serial.println("❌ open for write failed");
return;
}
testFile.println("hello microSD");
testFile.close();
Serial.println("✅ wrote file");
// read it back
if (!testFile.open("test.txt", O_READ)) {
Serial.println("❌ open for read failed");
return;
}
Serial.print("Contents: ");
while (testFile.available()) {
Serial.write(testFile.read());
}
Serial.println();
testFile.close();
}
void loop() {
// nothing else
}```
Any suggestions?