Saving circular buffer in flash memory of esp32
-
aneeshp123
- Posts: 6
- Joined: Thu Jun 05, 2025 10:18 am
Saving circular buffer in flash memory of esp32
We are making a project where we are supposed to store sensor readings in a circular buffer of 1000 sensor readings in the flash memory. What should be the approach?
-
MicroController
- Posts: 2661
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Saving circular buffer in flash memory of esp32
Approach:
if (isBufferFull()) {
deleteOldestEntries();
}
appendNewEntry();
Options:
a) Use a file system and store the data in files - may be the easiest way but also the most inefficient.
b) Use the partitions and flash API to write directly to flash, rotating writes and erases in a dedicated partition of at least 2 pages.
Don't try and use the NVS API. It's not made for this scenario, and as others have already found out may work somewhat but clumsy at best.
if (isBufferFull()) {
deleteOldestEntries();
}
appendNewEntry();
Options:
a) Use a file system and store the data in files - may be the easiest way but also the most inefficient.
b) Use the partitions and flash API to write directly to flash, rotating writes and erases in a dedicated partition of at least 2 pages.
Don't try and use the NVS API. It's not made for this scenario, and as others have already found out may work somewhat but clumsy at best.
Who is online
Users browsing this forum: Applebot, Bytespider, PerplexityBot and 16 guests