How to initialize NVS on ESP32

First, include the ESP32 NVS library using:

#include <nvs.h>

Globally, declare

nvs_handle_t myNVS = 0;

Then you can

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));

You can choose¬†MyLabel arbitrarily, as long as the string isn’t too long. My recommendation is to choose a unique identifier for your application.