1

I am trying log my sensor data (1 byte each) on my Arduino Uno Eeprom. I have an ATmega328 on it, so it should allow me to write up to 1Kb on it, however I've tried the Eeprom write command and it does not seem to write to more than 100 locations on it (the first 100 bytes!)

I am using the Eepromex library.

Any thoughts on what's causing this?

Edit:

These are the excerpts from my code related to Eeprom logging:

int addr1 = 0;
int addr2 = 256; 


  // Store Data in EEPROM

  EEPROM.write(addr1,FinalMoisture[0]);

    delay(5);

  EEPROM.write(addr2,FinalMoisture[1]); 

    delay(5);
  // advance index pointer to the next location.  There are 256 bytes assigned for each sensor in the EEPROM, so go back to 0 when we hit 255/511.

  addr1 = addr1 + 1;

  if (addr1 == 255)
    addr1 = 0;

  //same for addr 2 :

   addr2 = addr2 + 1;

  if (addr2 == 511)
    addr2 = 256;

  // delay until next measurement (msec)
 Sleepy::loseSomeTime(30000); 

PS: As mentioned earlier I've included the EepromEx library. Each sensor stores only first 50 locations. Also, I've noticed that if I run a single loop instead of storing data in two locations, I can write 100 straight entries. In any case it seems that the write function is limited to 100?

Could this be a setting in the library? How to disable/modify it? I tried looking at the info on the lib author's postings but didn't help.

  • 1
    Are you sure it is failing to write, or could it be failing to read? can you post the code? Does the stock eeprom library have the same issue? – BrettAM Feb 9 '15 at 21:17
  • When the simple eeprom write and read commands didnt work beyond 50 locations in my sensor logger code, I tried using the standard samples from the Arduino Website and same thing... ...Tried pasting the code in here but the formatting screws it up (never done this before!) – Ameya Feb 9 '15 at 21:31
  • @Ameya, you can edit your question, and add the code there. – Gerben Feb 10 '15 at 11:32
  • @Gerben thank you for the suggestion. Please find the code included in the original question. – Ameya Feb 12 '15 at 19:33
  • Try using no library. eeprom_read_byte((const uint8_t *)addr1,FinalMoisture[0]); – Gerben Feb 12 '15 at 20:33
2

Looking at the library at https://github.com/thijse/Arduino-EEPROMEx/blob/master/EEPROMex.cpp it seems they limit the number of writes to 100:

EEPROMClassEx::EEPROMClassEx()
  :  _allowedWrites(100)
{
}

There seems to be a way of changing that:

/**
 * Set global maximum of allowed writes
 */
void EEPROMClassEx::setMaxAllowedWrites(int allowedWrites) {
#ifdef _EEPROMEX_DEBUG
    _allowedWrites = allowedWrites;
#endif          
}
  • Perused the source there... the '100 write limit' should ONLY be enforced when the _EEPROMEX_DEBUG macro is defined. Sounds like the copy of the library OP is using has the debug macro defined, thus limiting usage. – lornix May 23 '16 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.