Problem with preference.h when using S3 v0.2 chip

gylim78
Posts: 1
Joined: Mon May 20, 2024 7:02 am

Problem with preference.h when using S3 v0.2 chip

Postby gylim78 » Mon May 20, 2024 8:14 am

Hi All,

I am having a problem after my new shipment of S3 chips that came are now ver 0.2.

I have a feature in my code that will basically enter into AP mode and serve up a webpage that will allow a user to change configuration settings. This basically uses the preferences.h and webserver.h library.

However, when I “save” the settings, it does not actually save and when it reads it again, it is still the old value.

The interesting thing is that when I use the same code on an earlier board which is V0.1 of the S3 chip, it works without any problem.

The other thing that I have found is that here is some conflict between the webserver library and the preference.h library because when I remove the routine of going through the webserver, then it will work.

So if I do something like this in the setup routine, it will work.
  1. String ssid = "IZEEM_2G";
  2. String ssid = "12345678";
  3. StoreData("ssid",ssid);
  4. StoreData("wifi_password",wifi_password);
  5.  
  6. void StoreData(const char* key, const String val) {
  7.   Serial.print("Storing : ");
  8.   Serial.println(val);
  9.   preferences.begin(MEM_ID,false);
  10.   size_t tmp = preferences.putString(key, val);
  11.   Serial.println(tmp);
  12.   preferences.end();
  13. }
But when I use the webserver to get the value, this code does not save the value.
  1. void APconfig::handleSubmit(){
  2.   String response_success="<h1>Success</h1>";
  3.   response_success +="<h2>Set the device to the correct ID and reboot</h2>";
  4.  
  5.   String response_error="<h1>Error</h1>";
  6.   response_error +="<h2><a href='/config'>Go back</a>to try again";
  7.  
  8.   String ssid = String(server.arg("ssid"));
  9.   String wifi_password = String(server.arg("wifi_password"));
  10.  
  11.   StoreData("ssid",ssid);
  12.   StoreData("wifi_password",wifi_password);
  13.  
  14.   server.send(200, "text/html", response_success);
  15. }
The output on the serial monitor shows the correct length of the string from the code
size_t tmp = preferences.putString(key, val);
Serial.println(tmp);

So I get something like this from the Serial monitor
IZEEM_2G
12345678
Storing : IZEEM_2G
8
Storing : 12345678
8

So it looks like the data was "saved" correctly. But when I reset the board, it will still read the old value that was previously saved.

Does anyone have any idea or have had the same issue?

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Problem with preference.h when using S3 v0.2 chip

Postby lbernstone » Tue May 21, 2024 4:23 pm

By version do you mean the new chips are ESP32-S3-WROOM-2, or they are a different ECO version (which you would only see in the chip info). WROOM-2 uses OPI flash, so make sure to select the correct flash speed for your chip in the board options.

Who is online

Users browsing this forum: No registered users and 53 guests