SDFat Not Working w/ Mesh Classic Adapter

@whg

So I use a uSD card on my board for my photon & electron devices with the SDFat library. I connect it with the standard SPI (not SPI1) pins. Everything works fine with my Electrons and Photons on the given board (and has for a long time) - they can use the SD card fine. The SD Card holder is soldered on the board with very short traces to the Particle device pins, and no other external components.

However, using an Argon via the Classic Adapter, the sd.begin() call fails, with error code: 0x20, 0x00 (with normal SPI), or 0x20, 0xFF (with SoftwareSpi). This is using the bench example from the SDFat library (using version 1.0.16).

Has anyone else successfully used an SD card with the Classic Adapter, especially with SDFat? Is there anything specific I should try or check for on the hardware level? I don’t have a ton of low-level experience with SPI or SD Cards, so while I could mess around, I’m sure someone may have some specific suggestions.

Are you using SdFat library v1.0.16?

Yes, though I tried it with the same result for previous versions (I had updated the headers to support Mesh). Sorry, thought I had put that in there.

I don’t own a Classic Adapter, but the docs do provide a possible reason for your issue - at least for HW SPI.
https://docs.particle.io/datasheets/accessories/mesh-accessories/#pin-map-1

As you can see the Photon HW SPI pins are A3, A4, A5 and they are mapped to the Argon pins with exactly these name too, but on the Argon these are not the SPI pins. These are separate pins called SCK, MI, MO.

1 Like

Ah that must be it, thanks. Not sure how I missed that while poring over those pinouts.

@rickkas7, I think the documentation above should be updated, specifically in Note 3 on the Pin Map, which implies that those are the only pins not connected to anything. Note 3 should also include:

  • MI
  • MO
  • SCK

I could put in a PR if that’s helpful, but not sure what the standard process is.

I’ll give it a go with Software SPI on the correct pins and that should probably work.

I had pinged Rick already and I think he’s doing it as we “speak” :wink:

This is the translation table

#define SCK         D13
#define MISO        D11
#define MOSI        D12
1 Like

I have it working with:

// SD chip select pin
const uint8_t chipSelect = A2;

SdFatSoftSpi<A4, A5, A3> sd;
1 Like

Hi, I am beginner. Can you please provide full code and wiring diagram for interfacing Argon or Xenon to Classic SD Adapter.



Based on this source i can connect SD card Adapter straight to Xenon or Argon pins because logic and power works on 3.3v.

@justicefreed_amper solution code gives error :

sdcard.ino:32:1: ‘SdFatSoftSpi’ does not name a type

Thanks.

The author of SDFat has deprecated the functionality for Soft SPI (because it does not work very well). Thus it is no longer available.

I only had tried to use it to interface with legacy equipment. Since this is not what you are trying to do, my post is not intended for your use case.

Instead, simply use Pins 11-13 (Chip select on pin 14) for the standard SPI bus, or Pins 2-4 (chip select on pin 5) for SPI1 (the secondary spi bus). Connect the spi pins based on your sd adapter’s datasheet.

Using defaults for SPI (Pins 11-14):

SdFat sd;

const uint8_t   chipSelect                  = SS;  // SPI chipSelect pin - SS is default

// in setup()
sd.begin(chipSelect, SPI_FULL_SPEED);
1 Like