Storing x and y in ESP32 memory, how?

How can I permanently store the numerical value of x and y in the ESP32 memory? Does it have to be there even if the ESP32 is turned off / on? Alternatively, how to reset, delete and print the value. Thank you very much.

I use the wifimanager library from Tzuga.

We really need more context in order to answer the question

How frequently do you need to save x and y ?

One way to save values to be used after the ESP32 is turned off then on again would be to use SPIFFS. A Google search will find many explanations and examples

This will be the setting for specifying the points in the image, such as 145 and 550. That's it. Basically, it will be the initial setting that will be used all the time. Therefore, I wondered if the EEPROM is whether this is not an easier way when wifimanager stores the ssid and password wifi also in the EEPROM.

How frequently will you be storing the values ?

Do not use EEPROM if you want to save the values frequently

Only 1x

If you really mean once and only once, then take the easy option and use EEPROM

Or do you not know a nice example for saving and retrieving values from SPIFFS? Maybe it will be ideal. I want to save the data from the form.

There are examples in the IDE, but to save just 2 values then EEPROM is so much easier

I would say yes, it does have to be there even if the esp is turned off and on. Otherwise it cannot be described as "permanent". Perhaps I am missing the point of your question?

Does anyone have a ready-made function for reading and writing json values to a file? It would help a lot. I have found this so far: SPIFFS read write json

Why the sudden need to use JSON ?

Do you want to save more than just x and y ?

I liked SPIFFS. I can store more things there, which I have permanently stored in the IDE script (URL address where to send data) and others. JSON is multi-data, so reading and writing could be easier within a single file.

Using SPIFFS and JSON still sounds line a complicated way to do what you want

Consider putting the data to be saved in a struct, then you can save and load it with a single EEPROM.put() or EEPROM.get()

why not just hardcode the values?

or do you want to be able to download them after the program is written/programmed?

If one wants to save a user name and password into a ESP32 use the Non-volatile storage library. It's what the NV RAM partition is designed for.

Through SPIFFS I will create a file to which I can upload anything. However, if I reload the IDE code, the SPIFFS file will be deleted and the data will be lost. Is there a way to keep the stored data?

Are you sure about that ?

1 Like

don't believe that's true.
in fact, you may need to encode a version into the file so that if you change the code there's a way to handle an older file format.