microSD board, help getting it to work with BORON

Hi fellow developers,

I could use your help… I am trying to connect a microSD card (bought on Amazon) to a BORON using the SdFat library and the examples but have not been able to make it work. MY board connection is as Follows:

microSD > BORON
VCC - 3.3 V
SCK - A3
CS - A3

I also tried reversing the MISO/MOSI pins but no luck. I am using the following script that I found to test:

// This #include statement was automatically added by the Particle IDE.
#include <SdFat.h>

// Primary SPI with DMA
// SCK => A3, MISO => A4, MOSI => A5, SS => A2 (default)
SdFat sd;
const uint8_t chipSelect = A2;

const unsigned long TEST_INTERVAL_MS = 10000;
unsigned long lastTest = 0;

void tryMeFirst();

void setup() {

void loop() {
	if (millis() - lastTest >= TEST_INTERVAL_MS) {
		lastTest = millis();

void tryMeFirst() {
	File myFile;

	// Initialize the library
	if (!sd.begin(chipSelect, SPI_FULL_SPEED)) {
		Serial.println("failed to open card");

	// open the file for write at end like the "Native SD library"
	if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) {
		Serial.println("opening test.txt for write failed");
	// 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:

	// re-open the file for reading:
	if (!myFile.open("test.txt", O_READ)) {
		Serial.println("opening test.txt for read failed");
	Serial.println("test.txt content:");

	// read from the file until there's nothing else in it:
	int data;
	while ((data = myFile.read()) >= 0) {
	// close the file:

In all tests, I get " failed to open card " Can someone help me?


@okrauth ,

I have been building a solution with a microSD reader and the Boron and have achieved good results.

Here are a few things you may want to take a look at:

  • The SDFat library will assume that you are using the standard SPI pins. It sounds like you have the flexibility so I would suggest you use them: A5: Chip Select, D13: Clock, D12: MOSI, D11: MISO
  • It sounds like you have tried a couple different options but remember this, the Boron is the Master and the microSd card is the slave (please note that modern /preferred terminology is controller and peripheral ) so MISO will connect the Boron data out to the MISO data in on the mciroSD card.
  • You can initialize the library using this code:
#include <SdFat.h>                                 // MicroSD card library

#define CS_PIN SS

SdFat SD;

  • Then, when you need to write, you can call
    if (!SD.begin(CS_PIN, SD_SCK_MHZ(50))) {
        return 0;                                        // MicroSD card is required for disconnected operations

This is what worked for me. I hope this helps.



I bought these same units 2 years ago for a project with a photon and never got them to work. I ended up going with a pololu unit and it solved all my problems. The explanation given to me is that the units from Amazon are converting 5v to the 3v3 that the sd card uses, since particle boards are 3v3, this doesn’t work and I needed to switch to a non level shifted one.

Here is the one that worked for me: Pololu - Breakout Board for microSD Card

Thanks Chip,

I managed to get the board to work. I also needed to supply the board 5V power so I connected USBV pin to the board and it now writes and reads. Awesome.

Thanks again


1 Like


Glad to hear you got it working. Just a note as I don’t know the specifics of your board: The Boron is not 5V tolerant so make sure your board is not sending 5V back on the MOSI pin.



Oh… thanks for that heads up… I just checked and the unit is sending 3.3v…

1 Like


I have another question. I am writing a Log file with Temp sensor measurements. How would one manage the size of the log file to avoid running out of space on the card? I;ve been thinking of generating multiple log files based on their size and then delete the first log file and so on (log_1.txt, log_2.txt). I am curious if there is an easier way. Thanks for your help I really appreciated it.


Well, there is a function for this - sdCardCapacity() in SdInfo.h but it would take a HUGE number of temperature measurements to fill a modern microSd card.

Any idea about how much data you are intending to write? Could you just buy a big card and put this issue to rest?



I will have a look at that function. What I am building will be deployed in a remote area in northern Canada, it might be months for someone to retrieve the SD card but more importantly they will only retrieve the card if there was an incident so I need to recycle the log file until it is need it.


@okrauth ,

I see. If your temperature logging is a consistent rate and format, then your approach of breaking the file up by serial (labeled with counter “m”) makes sense. One way to manage space would be:

  1. You could set up a counter and put “n” datapoints in a file and then close the file and start the next. These files should then be about the same known size.
  2. You could have a third counter “o” for the number of files based on how many of your files the card can hold.
  3. Once you reach your limit for “o” you would delete the oldest serialized file before you create the next.

Just an idea and requires some assumptions but perhaps this could help.


1 Like

Most people don’t know this, but if you are using a standard microSD card, you do not need a controller board. The SD card has a built in 3.3V SPI interface, so if you have a spare micro-to-SD card adapter, (I have dozens of them), you can solder wires to the adapter, connect it to the Boron’s standard SPI pins, and use the standard SDFat library. Viola!

Thanks. Good to know.