Need help with Preferences.h
Posted: Tue Jun 08, 2021 8:47 pm
/*
Using this page as a guide https://randomnerdtutorials.com/esp32-s ... eferences/
the following code prints the following to the serial monitor:
data saved
5
5
why does it not print?
hello
world
*/
#include <Preferences.h>
Preferences preferences;
const char* line1 = "hello";
const char* line2 = "world";
//String line1 = "hello"; // this produces same results
//String line2 = "world"; // this produces same results
void setup() {
Serial.begin(115200);
Serial.println();
preferences.begin("any_name_here", false);
preferences.putString("line1", line1);
preferences.putString("line2", line2);
Serial.println("data saved ");
Serial.println(preferences.putString("line1", line1));
Serial.println(preferences.putString("line2", line2));
preferences.end();
}
void loop() {
}
As always, any and all help appreciated
Using this page as a guide https://randomnerdtutorials.com/esp32-s ... eferences/
the following code prints the following to the serial monitor:
data saved
5
5
why does it not print?
hello
world
*/
#include <Preferences.h>
Preferences preferences;
const char* line1 = "hello";
const char* line2 = "world";
//String line1 = "hello"; // this produces same results
//String line2 = "world"; // this produces same results
void setup() {
Serial.begin(115200);
Serial.println();
preferences.begin("any_name_here", false);
preferences.putString("line1", line1);
preferences.putString("line2", line2);
Serial.println("data saved ");
Serial.println(preferences.putString("line1", line1));
Serial.println(preferences.putString("line2", line2));
preferences.end();
}
void loop() {
}
As always, any and all help appreciated