11/*
2- ESP32 start counter example with Preferences library
2+ ESP32 startup counter example with Preferences library.
33
4- This simple example demonstrate using Preferences library to store how many times
5- was ESP32 module started. Preferences library is wrapper around Non-volatile
4+ This simple example demonstrates using the Preferences library to store how many times
5+ the ESP32 module has booted. The Preferences library is a wrapper around the Non-volatile
66 storage on ESP32 processor.
77
88 created for arduino-esp32 09 Feb 2017
@@ -17,29 +17,29 @@ void setup() {
1717 Serial.begin (115200 );
1818 Serial.println ();
1919
20- // Open Preferences with my-app namespace. Each application module, library, etc.
21- // has to use namespace name to prevent key name collisions. We will open storage in
20+ // Open Preferences with my-app namespace. Each application module, library, etc
21+ // has to use a namespace name to prevent key name collisions. We will open storage in
2222 // RW-mode (second parameter has to be false).
23- // Note: Namespace name is limited to 15 chars
23+ // Note: Namespace name is limited to 15 chars.
2424 preferences.begin (" my-app" , false );
2525
26- // Remove all preferences under opened namespace
26+ // Remove all preferences under the opened namespace
2727 // preferences.clear();
2828
2929 // Or remove the counter key only
3030 // preferences.remove("counter");
3131
32- // Get a counter value, if key is not exist return default value 0
33- // Note: Key name is limited to 15 chars too
32+ // Get the counter value, if the key does not exist, return a default value of 0
33+ // Note: Key name is limited to 15 chars.
3434 unsigned int counter = preferences.getUInt (" counter" , 0 );
3535
36- // Increase counter
36+ // Increase counter by 1
3737 counter++;
3838
39- // Print counter to a Serial
39+ // Print the counter to Serial Monitor
4040 Serial.printf (" Current counter value: %u\n " , counter);
4141
42- // Store counter to the Preferences
42+ // Store the counter to the Preferences
4343 preferences.putUInt (" counter" , counter);
4444
4545 // Close the Preferences
@@ -53,4 +53,4 @@ void setup() {
5353 ESP.restart ();
5454}
5555
56- void loop () {}
56+ void loop () {}
0 commit comments