Exceed EEPROM writes

Hi all

I have been working on a project for a while now, I am using an arduino Mega2560 and using EEPROM location 111 to 2200 (not all of them, however in that range) recently I revived the following msg through the serial monitor

Exceeded maximum number of writes

I understand that the EEPROM has a limited number of writes that can be completed before it becomes unusable. However I would have thought that once this occurs no more writes would be able? It seems that I can consistently write to the EEPROM 99 times before getting this msg no matter what locations I write to. I made the following sketch to see where it was happening and it will write 100% of the time from 1 to 99 then on 100 give the error. I have tried from 2000 and got to 2099 before getting the error too.

#include <EEPROMex.h>
#include <EEPROMVar.h>

  int x = 1;
  int DEBUG = true;


void setup() {
  Serial.begin(9600);
  while(DEBUG == true) DebugEEPROM();
}

void loop() {
  if(x == 110){
    Serial.print("In Main loop");
    x = 1;
  }  
}

 void DebugEEPROM(){
   delay(250);   
   EEPROM.write(x, 3);
   Serial.print("EEPROM.write("); Serial.print(x); Serial.println(", 3)");  
   x++;
   if(x == 110) DEBUG = false;
 }

I was wondering is this normal behaviour once the EEPROM max number of writes have occured?

If you actually wear out your EEPROM then you get cells that won't 'stick' at what you wrote. You can keep on writing forever but the cells wear out and don't stay on.

So what does the msg I receive mean?

You are using EEPROMex which lets you set the maximum number of writes you can do before it will not write more.

https://github.com/thijse/Arduino-EEPROMEx/blob/master/EEPROMex.cpp#L324

And here you can see the default max writes set to 100:

https://github.com/thijse/Arduino-EEPROMEx/blob/master/EEPROMex.cpp#L40

Is there a feature of EEPROMex that you need? Would be less overhead to simply use the EEPROM.h unless you want to use these restrictions.

In EEPROM.h you can use EEPROM.get() & EEPROM.put() and they use an update method which will not overwrite anything that hasn't changed, and can read/write larger values than a single byte.

Just aside, if you reached whatever arbitrary write limit is currently set - it's a good heads-up to check that you are writing to EEPROM when really necessary.

I love EEPROMex.

Sorry for the late reply. Thanx a heap pYro_65 :)

Is there a feature of EEPROMex that you need?

I use the EEPROM.writeBit(x, y, z) feature to write 8 binary bits to one EEPROM location.

lastchancename

Just aside, if you reached whatever arbitrary write limit is currently set - it's a good heads-up to check that you are writing to EEPROM when really necessary.

I am not going over the write limit due to unnecessary writes I use a flag system to only allow one write at a time such as

if(EEPROM.read(x) != y) flag = true;
if(save == true && flag == true){
  EEPROM.write(x, y);
  flag = false;
}

Although yes I do agree this could be a good check to make sure that you are not overwriting to the EEPROM. Does _writeCounts ever get reset back to 0? I can not find that it does. Or is there a way to reset it to 0? For instance once a new day is detected using a RTC? The reason I ask is that if not than this is not really a useful tool except for debugging after which one would have to set it really high on a project that runs for an extended period of time.