Does fragmented EEPROM use negatively affect program space?

Hi,
I am looking to store some variables into EEPROM, each variable it a float with 2 decimals which is not expected to get as high as 100.00. So I am expecting to work with 99.99 as my largest variable.
I will program accordingly to shutdown if that value is even close to being reached, it represents temperature measured on an LM35, and 100C would be far too hot and need dealing with long before.

So I plan to split the variable into two bytes, storing the decimals seperately and reconstruct the variable later.
I can work that all out, im aware the eeprom library has been updated to store more than one byte at a time, but i plan to stick with the approach above.

my question is:
I have 1024 bytes available on a 328p and 4096 on a 2560. Both of which I can use for this.
if I choose to store the variables in easy to remember locations and fragment the data,
for example, variable 1 goes toeeprom.put[10 and eeprom.put[11]
variable 2 goes to eeprom.put[20] and eeprom.put[21]
and I do this all the way up to 10 variables.
Does fragmenting the data like this cause any negative sideeffects? I will be reading the data back during setup() and then during the sketch using eeprom.put only if the variable measured is higher than the value in eeprom, creating a data logger for max temps.

This should reduce the amount of calls to eeprom.put, and as I see it epprom.put already makes this check anyway to avoid uneccesary eeprom writes.

Does anyone see a significant problem with this approach?

thanks in advance.

EEROM has absolutely NOTHING to do with FLASH or RAM. Totally separate devices.

1 Like

Where you write the data does not matter. What is important, is how many times you write to any single location.

1 Like

Right,
So im calling the temp measurement routine once per second. and will only write if the value is higher than stored.
It takes around 10 mins to reach the highest temp in theory. So that would be 600 writes on the first run, then until it went over that in the future it wouldnt write again .

Perhaps I will however hold the value in flash until ten mins have passed and then write it and save those initial 600 writes. or prepopulate the slots with something close to expected max to begin with.

maybe even just write it once at shutdown..... assuming shutdown happens as expected.

Well you have 100000 write cycles for any location.
So after you do the initial 600, if you then do 50 or less writes/day it should last about 5.5 years

since im only going to store the temp if it exceeds the value in eeprom, i dont expect it to be writing very often at all.

the code will be taking measures to turn off the heat generating electronics in the event that they get too hot . there is also a bimetallic in the mix to take drastic action if the code for somereason locks up.

so in short, I think 100k writes is plenty

The you are all set to go
Have a nice day!

thanks,

What kind of temperature sensor are you using? For many of them the thermal mass makes checking once a second meaningless.

im using an LM35.

You are right that they have quite some thermal mass, however they certainly do heat or cool enough in one second to have the value change. They are glued to an aluminium mass anyway which is what is being measured.

I may end up reading them less frequently, testing will show how frequently is worth while.

Thanks for the input

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.