Hi folks,
I just installed a Qwiic EEPROM - 512Kbit, is working fine, I am able to store and read data back from it, my question is:
How to set ip up, so it will remember variable values after rebooting?
The way it is right now, if I reboot the microcontroller, it will clear the old data and store new data. I dont want that.
I am using the Arduino MKR1010
Any hint or advice will be much appreciated.
Thank you
It sounds like the code you’re using now is erasing the EEPROM at startup.
You need to change the code to not do that and also construct your code so that it doesn’t overwrite data you want to save.
Thanks Chris for your reply.
But that’s where I am having problem. Is there something like the EEPROM arduino EEPROM.update for the Qwiic EEPROM ?
Their example says:
" Update the particular EEPROM cell.
these values will remain there when the board is
turned off.
***/
EEPROM.update(address, val);"
There’s no library function that does that as far as I’m aware of, you’d need to implement that function in your own code somehow. What you’re looking for is some sort of simple file system that keeps track of what memory locations contain data and which ones are free to use so you don’t overwrite existing data. (unless it’s something you DO want to update.)
Our example code is just a simple demonstration that gets you up and running, if you need more functionality outside the examples, you’re going to need to write that code on your own. Unfortunately we don’t offer code support, but other forum users may be able to help with that.
You might look into setting aside specific locations in the EEPROM for variables you know are going to be updated and write directly to those when needed. For other data, you probably want to set aside ranges of locations for those and then keep track of which ones are in use in another range. (Kind of like the [file allocation table does in the FAT file system.)
I’ve not tried either of these libraries, but they may give you some ideas on what needs done.
- [https://github.com/charlesbaynham/OSFS](https://github.com/charlesbaynham/OSFS)
- [https://github.com/nuskunetworks/arduin ... ile_system](https://github.com/nuskunetworks/arduino_simple_file_system)](https://en.wikipedia.org/wiki/File_Allocation_Table)
Hi,
I wrote an Arduino library to read and write to the Qwiic EEPROM similar to the standard C file functions. It makes for an easy way to store binary data, text and strings in the EEProm. It also supports appending to the already existing data in the EEProm, so you don’t have to overwrite data each time. It might be what you’re looking for.
It’s available on github: [fourstix/Sparkfun Qwiic EEProm Arduino Library](GitHub - fourstix/Sparkfun_Qwiic_EEProm_Arduino_Library: This is an Arduino library written for the Sparkfun Qwiic EEProm)