Page 1 of 1

NVS minimal data storage

Posted: Mon Jan 02, 2023 2:07 pm
by Coffeeye
Hello,

due to what I understood from doc's data storage is 32bytes long. Can I use NVS in v4.4 to store data for example 8bytes long to save storage size or its irrelevant due to 32bytes long value storage ?

happy new year!

Re: NVS minimal data storage

Posted: Tue Jan 03, 2023 1:45 am
by ESP_jakob
Hello,

In short: no, you cannot "only" use 8 bytes of data.

Each entry for integer types is 32 bytes long, because it contains the key (15 bytes + NULL), some additional meta data like e.g. the corresponding namespace, type, etc. and it also contains the data (8 bytes). Hence, every integer type entry uses 32 bytes, no matter what type.

If you use string or blob type entries, this is different, because the data is saved in the space adjacent to the entry in that case. Here you can indeed save data, but only multiples of 32 bytes. In other words, the size will in crease in 32-byte steps corresponding to the size of the data. For more information, please have a look at the NVS documentation: https://docs.espressif.com/projects/esp ... e-of-entry.

Best and happy new year, too,
Jakob