#include <Preferences.h>
Preferences preferences;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
preferences.begin("my-app", false);
unsigned int counter = preferences.getUInt("counter", 0);
counter++;
// Print the counter to Serial Monitor
Serial.printf("Current counter value: %u\n", counter);
// Store the counter to the Preferences
preferences.putUInt("counter", counter);
// Close the Preferences
preferences.end();
// Wait 10 seconds
Serial.println("Restarting in 10 seconds...");
delay(10000);
// Restart ESP
ESP.restart();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}