Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By RaspBerry-Picker
#90507
flisterfive wrote:opening "%appdata%\local\arduino15\staging\packages\" and for each error downloading given in the arduino IDE, i downloaded the ZIP file manually, and copy to the above directory, after the fifth zip was copied. all was fine.


Hi flisterfive,

download wich zip from where? From the ESP32-repository?

Found the local folder (linux) but did found the .zip for preferences.h regarding to esp8266 via google...

Code: Select all~/.arduino15/staging/packages# ls
esp32-1.0.4.zip             mkspiffs-0.2.3-arduino-esp32-linux64.tar.gz            x86_64-linux-gnu.mkspiffs-7fefeac.1563313032.tar.gz
esp8266-2.7.4.zip           python3-via-env.tar.gz                                 x86_64-linux-gnu.xtensa-lx106-elf-b40a506.1563313032.tar.gz
esptool-2.6.1-linux.tar.gz  x86_64-linux-gnu.mklittlefs-fe5bb56.1578453304.tar.gz  xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
User avatar
By RIN67630
#90764 It is not difficult to perform the same magic with the classical EEPROM library.

You will be using a quick and dirty method called 'type punning' copying the memory block of a structure into an array of chars, saving this array to EEPROM, reading later the array back and copying back the memory block of the array into the same structure to restore the data:

First define your data in a structure:
Code: Select allstruct persistance {      // you may include as many data of any type in that structure
  long  Runtime;
  float Whout ;
  float Ahout ; 
} persistance;

char persistance_punning[sizeof(persistance)];   // char array as a copy of the structure


Code: Select all    // write Persistance to  EEPROM (Adress = 100...)
    memcpy(persistance_punning, &persistance, sizeof(persistance));
    for ( int i = 0; i < sizeof(persistance); ++i ) EEPROM.write ( i + 100,  persistance_punning[i] );


Code: Select all    // read Persistance from EEPROM (Adress = 100...)
    for ( int i = 0; i < sizeof(persistance); ++i ) persistance_punning[i] = EEPROM.read ( i + 100 );
    memcpy(&persistance, persistance_punning, sizeof(persistance));   


enjoy!
User avatar
By Pablo2048
#90773 Hi,
this is very ineffective - just use EEPROM.put and EEPROM.get templates for reading and storing the whole structure. Or (even better) use the memory address with this https://github.com/esp8266/Arduino/blob ... PROM.h#L66 and reinterpret the cast as structure pointer (because we all know, that the EEPROM in the ESP8266 is mirrored in RAM...). Don't forget to EEPROM.commit() changes...
User avatar
By gmag11
#92443 I normally use filesystem (SPIFFS or better LittleFS). I create a structure with all data I need to save and dump to a file.

Code: Select allFile configFile = SPIFFS.open (CONFIG_FILE, "w");
configFile.write ((uint8_t*)&persistent_data, sizeof (persistent_data));
configFile.flush();
configFile.close();


Loading data is similar:
Code: Select allFile configFile = SPIFFS.open (CONFIG_FILE, "r");
configFile.readBytes((uint8_t*)&persistent_data, sizeof (persistent_data));
configFile.close();


This may be run on both ESP32 and ESP8266. Preferences library is cleaner anyway. Would be nice that it was included in ESP8266 core