Summary of SD card logger library with log rotation that fits on ATmega8
This library enables SD card data logging on ATmega microcontrollers, specifically optimized for the ATmega8 due to its small footprint. It utilizes the Petit FAT File System Module to support FAT16 formatted SD and microSD cards. The system features automatic log rotation, where data is written sequentially across pre-defined files of a set size (max 2^16 bytes). When a file reaches capacity, the logger moves to the next file or loops back to the first, managing positions in 512-byte blocks.
Parts used in the SD Card Data Logger:
- ATmega8 microcontroller
- SD card or microSD card
- Petit FAT File System Module by ChaN
- Python helper script
- Predefined empty files
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.
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.
For more detail: SD card logger library with log rotation that fits on ATmega8
- Can this library run on an ATmega8?
Yes, it has a small footprint designed to fit on an ATmega8. - What file system format is required for the SD card?
The card must be formatted with FAT16. - Does the project support log rotation?
Yes, the library features automatic log rotation when files are filled. - How does the logger handle full files?
It skips to the next file or returns to the first one if it is the last. - What is the maximum file dimension allowed?
The file dimension cannot exceed 2^16 bytes because a uint16_t variable stores this information. - What limits the number of files in the system?
The maximum number of files is limited to 256 because a uint8_t variable is used. - How can I create the necessary empty files?
You can use the provided Python helper included in the code. - Does the Petit module support seeking to any position?
No, seek operations are limited to block dimensions, typically 512 bytes.

