Help with SdFat Library

And did you get valid card information the serial output?

These following are the output from the sdcard.

C:\Users\test>particle serial monitor
Opening serial monitor for com port: "COM5"
Serial monitor opened successfully:

SdFat version: 1.0.15

Disabling SPI device on pin 0

Assuming the SD chip select pin is: 12
Edit SD_CHIP_SELECT to change the SD chip select pin.

type any character to start

init time: 35 ms

Card type: SDHC

Manufacturer ID: 0X0
Product: APPSD
Version: 0.0
Serial number: 0X3008012
Manufacturing date: 11/2012

cardSize: 15891.17 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000

SD Partition Table

Volume is FAT32
blocksPerCluster: 64
clusterCount: 484439
freeClusters: 484435
freeSpace: 15873.97 MB (MB = 1,000,000 bytes)
fatStartBlock: 15996
fatCount: 2
blocksPerFat: 3785
rootDirStart: 2
dataStartBlock: 23566
Data area is not aligned on flash erase boundaries!
Download and use formatter from!

Try using this SDFat library provided on GitHub,
This worked for me, I believe I had to change a few things in the library though.

Great to see it works! - you need to reformat the card as advised - it just makes debugging easier (based on my past experiences :slight_smile: )

So now you know the connections and card work - you can try the logger code, knowing thats is only related to the library being used (or perhaps how you are using it in your code)

Thanks @jphil for the suggestions.
@shanevanj formatted the sdcard using the formatter. What if the issue is related to the shield. Is there a chance the writing speed is not compatible for it? I am using SanDisk class 4 sdcard. Thanks for all the inputs.

If memory servers me correctly - you can try SPI_HALF_SPEED in the statement above

I’m not sure of that since F_CPU (used to calculate half of that) is not declared IIRC.
However, you can also use a numeric value for the clock speed (e.g. 8000000 for 8MHz).

However, you can also use a numeric value for the clock speed (e.g. 8000000 for 8MHz).

It worked! The SPI_FULL_SPEED can be configured using the spiconfig object. This is an example:

SPISettings my_spi_settings(10000000, MSBFIRST, SPI_MODE0);
SdCardLogHandler<2048> sdLogHandler(sd, SD_CHIP_SELECT, my_spi_settings, LOG_LEVEL_INFO, {

Thanks for the help and suggestions @ScruffR @shanevanj @jphil and @armor

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.