Primeiro, inclua a biblioteca NVS do ESP32 usando:
init_nvs.cpp
#include <nvs.h>Globalmente, declare
nvs_handle_declaration.cpp
nvs_handle_t myNVS = 0;Então você pode
init_nvs_function.cpp
void InitNVS() {
esp_err_t err;
if((err = nvs_open("MyLabel", NVS_READWRITE, &myNVS)) != ESP_OK) {
Serial.printf("Failed to open NVS: %s\r\n", esp_err_to_name(err));
return;
}
}Você pode escolher MyLabel arbitrariamente, contanto que a string não seja muito longa. Minha recomendação é escolher um identificador único para sua aplicação.
Check out similar posts by category:
ESP8266/ESP32
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow