SDFat usage on Particle Photon

I have been trying for a few days to get a MicroSD card to work with my Particle Photon. With no success. I am currently almost to the point of bashing my head through a wall or something… But that would be expensive to fix. So I will opt to post on here for help.

Anywho, I purchased a MicroSD shield and am using the First SPI configuration with the Pins as such:
SCK - A3
SS - A2
Gnd - Gnd (Obviously…)
VCC - 3.3v (I tried Vin As well.)

I am also using Particle.publish as a way to debug.

All that I get as published is:

I used the code from the code on Github:

#include "SdFat.h"

// Pick an SPI configuration.
// See SPI configuration section below (comments are for photon).
// Setup SPI configuration.
// Primary SPI with DMA
// SCK => A3, MISO => A4, MOSI => A5, SS => A2 (default)
SdFat sd;
const uint8_t chipSelect = SS;
// Secondary SPI with DMA
// SCK => D4, MISO => D3, MOSI => D2, SS => D1
SdFat sd(1);
const uint8_t chipSelect = D1;
// Primary SPI with Arduino SPI library style byte I/O.
// SCK => A3, MISO => A4, MOSI => A5, SS => A2 (default)
SdFatLibSpi sd;
const uint8_t chipSelect = SS;
// Software SPI.  Use any digital pins.
// MISO => D5, MOSI => D6, SCK => D7, SS => D0
SdFatSoftSpi<D5, D6, D7> sd;
const uint8_t chipSelect = D0;

File myFile;

void setup() {

  // Initialize SdFat or print a detailed error message and halt
  // Use half speed like the native library.
  // Change to SPI_FULL_SPEED for more performance.
  Particle.publish("print", "Starting");
  if (!sd.begin(chipSelect, SPI_FULL_SPEED)) {
  Particle.publish("print", "Fail");
  Particle.publish("print", "SD Card Works!!");

  // open the file for write at end like the "Native SD library"
  if (!"test.txt", O_RDWR | O_CREAT | O_AT_END)) {
    sd.errorHalt("opening test.txt for write failed");
  // if the file opened okay, write to it:
  myFile.println("testing 1, 2, 3.");
  myFile.printf("fileSize: %d\n", myFile.fileSize());
  // close the file:

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

  // read from the file until there's nothing else in it:
  int data;
  while ((data = >= 0) {
    Particle.publish("print", data);
  // close the file:
  Particle.publish("print", "Made it to the end");

void loop() {
  // nothing happens after setup

Thanks for the Help in advance!

What exact MicoSD shield is it?
What SD are you using?
Have you got a photo of your setup?

The SD Shield I am using is this one:

I am using a 32 gb MicroSD Card.

And as for a photo… I am in bed already. That will have to wait till morning.

How is that SD formatted?
Ext and NTFS are obviouls not supported via SdFat.

AFAICT this board requires a min. 4.5V supply for the voltage regulator which supplies the level shifter.
So you should definetly power the board off of Vin.

The SD card formatting is FAT.
I have switched it to the Vin with no luck.
I have had success with using the SD card with my Arduino Uno.

Image of Setup is here:

That looks fine, so I don’t know what else to suggest since I usually don’t use level shifting SD readers but go for the simple, straight forward ones as the Particle devices already are 3.3V based.
like this

While @rickkas7 often uses the level shifting ones and never had an issue I still can’t vouche for this specific board to properly work with 3.3V SPI levels.

If you are certain the wiring is as per the pin assignment in the code and the SD module is powered off Vin. Then if the same board works with Arduino, it suggests that the Photon has an issue.

Have you tested your SPI pins are working on the photon - install tinker and use a led with 330ohm resistor to GND?

Just looked at your code - the use of SPI_FULL_SPEED requires a weak pullup on the SPI bus lines (100K ohms) - I don’t see that on this board. You could try putting pull-up resistors on the MISO, MOSI pins of 10K to 3V3. Also, I would try SPI_HALF_SPEED.