SdFat library doesn't work with Photon

Hi everyone,

I’m trying to work with a Photon and Micro SD card adapter.

I have tested all the libraries in the Web IDE (SdFat, sd-card-library, sd-card-library-photon-compat) with no success.

The failure always happens in the setup function during the initialization of the SD card.

Just to note, there is no HW issue with the adapter since it worked fine when I tested it with an Arduino Uno and the Arduino’s SD.h library.

SD module → Photon
VCC VIN
GND → GND
MISO → A4
MOSI → A5
SCK → A3
CS → A2

Does someone have an idea how to solve this?

(Please let me know if further information is required)

That’s not always a valid argument though.
Arduino UNO works on 5V signals while the Photon works with 3.3V.
Hence the 3.3V signals on the input side of the level shifter on that board may or may not be recognized as HIGH.

With a micro SD card holder without level shifting. In the past I did have success with the SdFat library tho.

1 Like

Do you think the level shifter causes the issue?
Can you recommend me on a micro SD card adapter without level shifting?

Second ScruffR comments that you need level shifting. I am also unsure that powering a 5V SD card reader off the ~4.8V output by the VIN pin would be sufficient.

I would simply use a SD card module that supports both 5V and 3.3V power and logic, ie I have had good success with https://www.adafruit.com/product/254

Did you succeed in working with your SD card module together with a Photon?
If yes, which library you used?

Yes, I have used SDFat Particle library mentioned by @rickkas7 above with the Adafruit SD module on Photon. I used hardware SPI similar to your setup, just connected to the 3.3 volt supply pin.

Not quite. SD cards do by default run on 3.3V so with Particle devices you would not need level shifting. But since most (legacy) Arduino boards run on 5V level shifting is required for these.
However some level shifted boards don’t play well with 3.3V signals, while others do.

The board shown here should work since ESP32 also runs on 3.3V

I had exactly the same problem using a level shifting SD adaptor. It worked fine with an Uno, but failed with the photon. As mentioned in this thread, I too was successful using the Adafruit SD adaptor. It is 3 V with no level shifters, and worked fine with the Photon / SD Fat. I have also just bypassed the level shifters on on the 5V SD board and that worked fine with the Photon as well.

1 Like