SD card logger library with log rotation that fits on ATmega8

This library implements an SD card Data Logger that runs on ATmega.
It has a small footprint, so it can be loaded on an ATmega8, leaving space for user code.
It supports SD and microSD cards formatted with FAT16.
It also features log rotation.SD card logger library with log rotation that fits on ATmega8The ‚ÄúPetit FAT File System Module‚ÄĚ by¬†ChaN ( it is used to write on SD card. I‚Äôve used the Petit library because i would like to build a small footprint logger. Even if it has a few limitations, those can be¬†circumvented.
We had to format the card we would like to use with FAT16, and then load it with a predefined number of empty files of a know dimension. Once we have files on the card, we can write on those files.
You can create empty files by using the python helper provided in code.
Firmware side we will setup the file dimension, and file number. File dimension, can not be greater than 2^16 bytes because a uint16_t type variable it is used to store this information, also max number of files it is limited to 256, becayse a uint8_t variable it is used.
Given the number of files used by the logger and every file size, we just have to record the last written position and the file number we are using to implements the log rotation. When a file is filled up with logged data, it skips to the next one, if the file is the last one, we go back to first.
Note that¬†Petit FAT File System Module¬†write files using blocks, so the ‚Äúseek to position‚ÄĚ can be used only on the block¬†dimension. Typically a block is¬†512 bytes.Schematic SD card logger library with log rotation that fits on ATmega8
For more detail: SD card logger library with log rotation that fits on ATmega8

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top