A
Arduino•3w ago
ShutBaton

Help connecting XIAO to micro SD card

Hi! Could I have some help? I've never used SD/micro SD cards in Arduino and it isn't going very well. I've connected a Seeed XIAO nrf52840 sense with pogo pin headers (I am fairly certain the connection isn't the problem) to an Adafruit microSD BFF for QTPy/XIAO. I am trying to write some data logged from the onboard imu to a text file on the micro sd. I can't get it to initialise (I am using a 32GB Kingston micro SD that I formatted using the official sdcard.org formatter to FAT32) I've installed the adafruit fork of the SdFat library in arduino ide. Here's my code: (I've started afresh to just try to get it to initialise before I add everything else back in)
#include <SPI.h>
#include "SdFat.h"

const int chipSelect = 6;

SdFat SD;

void setup() {
Serial.begin(9600);
while (!Serial) {
delay(10);
}

Serial.println("attempting to init... ");

if (!SD.begin(chipSelect)) {
Serial.println("failed!");
while (1);
}
Serial.println("SUCCESS!");
}

void loop() {
}
#include <SPI.h>
#include "SdFat.h"

const int chipSelect = 6;

SdFat SD;

void setup() {
Serial.begin(9600);
while (!Serial) {
delay(10);
}

Serial.println("attempting to init... ");

if (!SD.begin(chipSelect)) {
Serial.println("failed!");
while (1);
}
Serial.println("SUCCESS!");
}

void loop() {
}
The boards are connected correctly, all connections are there electrically, the XIAO board is fully functional, and I am using the kingston micro sd I've attached as an image.
No description
5 Replies
AnonEngineering
AnonEngineering•3w ago
OP was directed here from #general-help , this is not a crosspost
ShutBaton
ShutBatonOP•3w ago
has anyone had trouble and found a solution to a similar problem? For future reference to others with this problem that stumble across this, it was the simplest solution absolutely possible. I have solved the problem. āŒ const int chipSelect = 6; āœ… const int chipSelect = D6; Why this is the solution? No clue. Absolutely no clue. I just started messing around and it worked. Not a single line of example code I have seen, even from the board's own examples themselves use this.
AnonEngineering
AnonEngineering•3w ago
nice find!
ShutBaton
ShutBatonOP•3w ago
Thanks šŸ™‚ I'm just happy I can finially finish my project lol
ZC123
ZC123•2w ago
i think i might know i think the label of the digital pin "d" smt is like different from the printed pin number or something oh wait i understand it now 6 refers to gpio 6 which is not the same pin as d6

Did you find this page helpful?