SdFat difficulty

Im using a SD card as a database. Sd.h converts file names to CAPS and it can only hold a file name of 8 chars, this would be a drawback. So ive gone with SdFat.

The info on SdFat is far more indepth/complicated than the resources available on Sd.h.

Question: is there a resource on SdFat that lists the functions, their arguments, return values, and fundamentally how they work? In a similarly plain English (novice) way that Arduino docs describes Sd.h SD class and File class functions?

(Mainly parsing, data handling, file and directory control)

Thanks again Dave :)

Arduino docs Sd.h

Not that I have found. All the gory details can be found here.

SdFat/doc at master · greiman/SdFat · GitHub
Download html.zip and unzip it (put it in a new folder because there are a lot of files). Point your browser at index.html to get to the base. You will then get numerous pages of documentation that are mostly incomprehensible unless you already have a clue.

A second source is to go through the examples from the install of the SdFat library. There are limited comments so again it can be tough going to start.

I did a demo program to show how to timestamp files here. It has basic read/write and directory operations.

SD and SDFat are poorly documented and also quite unreliable.

I gave up on them years ago, as the RPi/linux file system is orders of magnitude better on both counts. If you are serious about data storage on SD in a small form factor module, choose something like the Pi Zero, Zero W, etc.

However, they are power hungry and not very useful for battery powered sensors or other low power/sleep mode projects.

I don't know your overall design, but just a thought: if the SD card is really acting as a database, would a single data file containing multiple records be an option instead of many individual files?

SdFat has a strange way of providing documentation. If you go into your libraries folder and find the SdFat library folder, in there you will find a Doc folder. Go into this Doc folder and first extract the html.zip file. This will overwrite the current base contents of that folder. Then click on SdFat.html to open the page in your browser. There you will find a description of how to use the library as well as details of all of the classes and functions.

Each time the library is updated, you will have to manually extract the html.zip file again which is a bit of an annoyance, but it doesn't happen very often.

Please note that the Adafruit fork of this library is ~50 commits ahead.

So does that mean the Adafruit version is "better" than Greiman's for normal use? Would there be any downside to using the Adafruit version?

You need to check the commits to answer that question.

Commits can be several things

  • fixes for bugs (good)
  • new features (mostly good)
  • change of API (depends)
    • parameters e.g. type and number,
    • behavior, including return values
  • ...

Every commit can introduce new bugs, or changes of behavior that do not match your specific needs.

For Adafruit it is important to have a library that works with the hardware they sell, so I expect the commits to be improvements / useful extensions over the original library.

Thanks Everybody.
The Arduino docs explanitions of programming are so well writen, they've been a huge help in my learning. I was hoping there would be an equivalent for SdFat.

Without knowing the exact input arguments, return values and behavior of a function/object, its very difficult to create reliable code.

Ive decided to stick with SdFat as i know the basics, but simply read in data one bit at a time in to buffers and deal with it low level arduino code.

At least then i know whats going on and full control over behavior.
Thanks again for all your help :)

(P.s to an earlier suggestion; It is a one file data base, but may extend to a file system in the future.)