
9.6.2018
The SD card can be used in many kinds of projects as the storage medium because of its quite large capacity. I will not discuss the cases when some kind of ready made solution is used. I will stick with the basic principles we have learned.
Imagine some simple project where the data from some sensor like the DS18B20 digital temperature sensor has to be stored. The output of this sensor are two bytes with temperature information. So I will just be writing 2 bytes to the card in some time intervals. The complexity of the software necessary to accomplish this task depends on whether I need other devices to read the data from the card. I so then I have to use some standard file system such as FAT32. In other case no file system is needed. Let's explore these two variants.
In case I do not need other devices (e.g. PC) to be able to read the data stored on the card then it is completely up to me to choose the format of the data.
Say that the device is continually storing data in regular time intervals until all the card's memory is full. After that I will transmit the stored data to PC via some interface - e.g. USB. The storing of the data can be done this way:
The principle here is similar to the previous mode. The question here is how to store the data. Shall I create directories? How big files shall I use? The fact is that FAT32 does not limit the size of the root directory so the files can be stored in the root. I will decide on the files size with respect to effectiveness of the space usage. The file size should be the whole number multiple of the cluster size. When these parameters are set then I know how large the root directory after the whole space is used will be. Because it is only my device that is writing data to the card I can simplify the way I will treat FAT32: