{"id":79,"date":"2026-02-26T12:37:51","date_gmt":"2026-02-26T11:37:51","guid":{"rendered":"https:\/\/elrebo.de\/?p=79"},"modified":"2026-02-26T12:39:46","modified_gmt":"2026-02-26T11:39:46","slug":"generic_nvsflash","status":"publish","type":"post","link":"https:\/\/www.elrebo.de\/index.php\/2026\/02\/26\/generic_nvsflash\/","title":{"rendered":"generic_nvsflash"},"content":{"rendered":"\n<p id=\"block-0cfb8a78-7f9c-4098-b4fe-b30608000cbc\">An ESP-IDF component for&nbsp;<a href=\"https:\/\/elrebo.de\/index.php\/2026\/02\/20\/physical-computing\/\">Physical Computing<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-4b033aba-2a31-4956-b5d1-36a5f063d6a0\">Purpose<\/h2>\n\n\n\n<p id=\"block-d1d08013-14c7-41d6-bc31-31fd7f00b092\">Read and write data in non-volatile flash storage on ESP32 systems.<\/p>\n\n\n\n<p>This data is still available after the device is restarted.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-c0ec4b6c-cd95-4697-b800-d5a8e2dcf602\">How it is done<\/h2>\n\n\n\n<p id=\"block-f813434c-ae67-4bed-8e0b-5e80c7f0b3e2\">You need to include&nbsp;<code>generic_nvsflash.hpp<\/code>.<\/p>\n\n\n\n<p id=\"block-f813434c-ae67-4bed-8e0b-5e80c7f0b3e2\">Then you define an instance of class&nbsp;<code>GenericNvsFlash<\/code>.<\/p>\n\n\n\n<p>In the constructor of the class you state the namespace to use and whether you want to read and write or only to read the values from NVS flash.<\/p>\n\n\n\n<p>Now you can use the setter and getter methods of the class to set or get the values of stored keys. <\/p>\n\n\n\n<p>With method <code>EraseKey<\/code> you can delete keys from the namespace.<\/p>\n\n\n\n<p>Changes to key values are uncommitted until the instance ist deleted. In the destructor the changes are committed to the namespace.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-c316dbcb-c3c9-4a23-a3c7-d4fd1e0eb867\">Where to find it<\/h2>\n\n\n\n<p id=\"block-cc2afcf8-a2c3-4f6c-842a-a2443cfb1062\"><code>generic_nvsflash<\/code>\u00a0is published on the ESP Registry at\u00a0<a href=\"https:\/\/components.espressif.com\/components\/elrebo-de\/generic_nvsflash\">https:\/\/components.espressif.com\/components\/elrebo-de\/generic_nvsflash<\/a>.<\/p>\n\n\n\n<p id=\"block-2ecaabd6-5bb7-4287-bcc4-985ff1c232d5\">The source code can be found at&nbsp;<a href=\"https:\/\/github.com\/elrebo-de\/generic_nvsflash\">https:\/\/github.com\/elrebo-de\/generic_nvsflash<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-cf4dee0e-a35e-4163-9fb2-e2fc7ece1f67\">How to use it<\/h2>\n\n\n\n<p id=\"block-931617c6-8adf-4eb4-85d7-1ac4f0d6a9ed\">As an ESP-IDF component&nbsp;<code>generic_nvsflash<\/code>&nbsp;must be included into idf_component.yml as a dependency. As usual this can be done by executing this command:<\/p>\n\n\n\n<p id=\"block-37ac3466-38c9-435c-9301-59bc3384f2e1\"><code>idf.py add-dependency \"elrebo-de\/generic_nvsflash^1.0.11\"<\/code><\/p>\n\n\n\n<p id=\"block-c35797fb-de02-421b-aecd-512cb88904a4\">In CMakeLists.txt&nbsp;<code>\"elrebo-de__generic_nvsflash\"<\/code>&nbsp;has to be added as a requirement.<\/p>\n\n\n\n<p id=\"block-e64a7152-e2b3-46ce-bc41-7ca22badb118\">Now you can include&nbsp;<code>generic_nvsflash.hpp<\/code>&nbsp;and use the GenericNvsFlash class in your program.<\/p>\n\n\n\n<p>With this code snippet the value of a parameter is stored in an NVS namespace:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"114\" src=\"https:\/\/elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-12.32.36-1024x114.png\" alt=\"\" class=\"wp-image-125\" srcset=\"https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-12.32.36-1024x114.png 1024w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-12.32.36-300x33.png 300w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-12.32.36-768x86.png 768w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-12.32.36.png 1472w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>An ESP-IDF component for&nbsp;Physical Computing Purpose Read and write data in non-volatile flash storage on ESP32 systems. This data is still available after the device is restarted. How it is done You need to include&nbsp;generic_nvsflash.hpp. Then you define an instance of class&nbsp;GenericNvsFlash. In the constructor of the class you state the namespace to use and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":126,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oss"],"_links":{"self":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":4,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions\/128"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/media\/126"}],"wp:attachment":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}