Page 1 of 2

EEPROM example code not working properly

Posted: 27 Jul 2022 17:57
by graham
I am trying to write to the EEPROM to save data during power cycles. Just to test our that the EEPROM works properly, I used the example code on https://z-uno.z-wave.me/Reference/EEPROM/. Nothing gets stored in the EEPROM, just 0's. In addition I have tried to use EEPROM.write to write directly to a specific memory address and the entire memory is filled instead of just one memory location. Furthermore, when I cycle power nothing is saved. Any help would be appreciated. I am using a Z-uno2 rev.6

Code: Select all

#include "EEPROM.h"

BYTE some_data[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee}; 
BYTE read_data[5];

void setup() {
  Serial.begin();
}

void loop() {
    byte i;
    word res;
    dword addr = 0x0;
    
    Serial.println("Reading 128 Bytes one by one from EEPROM...");
    for (i = 0; i < 128; i++) {
        Serial.print(EEPROM.read(addr + i),HEX);
        if (((i % 0x10) == 0) && (i != 0))
          Serial.println();
        else
          Serial.print(' ');
    }

    Serial.println();

    Serial.println("Reading buffer from EEPROM...");
    res = EEPROM.get(addr, &read_data, sizeof(read_data));
    Serial.print("Read ");
    Serial.print(res);
    Serial.println(" Bytes");

    // write data to a specific address
    res = EEPROM.put(addr, &some_data, sizeof(some_data));
    
    delay(5000); // don't write to much in the EEPROM not to kill it
}

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 10:05
by amatilda
Hello.

Can you show the console output?

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 15:52
by graham
hi, here is the console output...

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 19:15
by joergm6
Which software version do you use? With larger v 3.0.7 an EEPROM problem was fixed.

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 19:27
by graham
Hi,
I am using Arduino IDE v 1.8.19, not sure if that is what you are asking for.

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 19:49
by joergm6
no, the Z-uno2 version in "Boards Manager" ... https://z-uno.z-wave.me/arduino-install/

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 20:10
by amatilda
on v 3.0.9 it works fine so maybe you should update the software - probably this will fix the problem

Re: EEPROM example code not working properly

Posted: 28 Jul 2022 21:26
by graham
That fixed it! I wasn't using the Beta board, that was my issue.

Re: EEPROM example code not working properly

Posted: 22 Aug 2022 17:35
by 7Cv0Nu6Q
It would be really helpful to mention this serious EEPROM issue here: https://z-uno.z-wave.me/arduino-install/
I spent a whole day trying to get config channels to work - always got completely wrong values from the EEPROM.
With 3.0.9 everything now works like a charm - this information could have saved me (and potentially many others) a lot of time and nerves!

Re: EEPROM example code not working properly

Posted: 22 Aug 2022 23:39
by PoltoS
The first rule in all debugging is "upgrade to the latest version" :)

Indeed, we have not made 3.0.9 public. I;ll make sure it become public by the next week. Sorry for the inconvenience