EEPROM.H Apparently working but not saving data on Uno R3 WAVGAT

Hello,

I am using an Arduino Uno Rev R 3 by Wavgat.

Initially, I tested all functions never powering off the board and they worked. Then, when I turned off the board, I noticed that the EEPROM never stored any data at any address.

For example, I cut and pasted from examples I read on this forum the simple code below that writes a a float (I assigned the 35.00 to the float variable) and I used EEPROM.write() to store this number, starting from address 0 when buttonPin is high.
Then, function EEPROM.get() retrieves the stored value and displays it in serial monitor.
If I never turn off the board I see EEPROM.get() working perfectly.

If I power off the board, turn off a switch that causes buttonPin to become low so the EEPROM.write() code is bypassed, EEPROM.get() return 0.00 value as nothing was stored.
i obviously used also EEPROM.put() and nothing changes.

Am I am doing anything wrong?

Am I using a poor quality board simulating an EEPROM with a volatile memory ?

Is there any special setting in some configuration file I must customize to permanently store data in EEPROM?

Below, the test code compiled with Arduino 1.8.19 hourly build (other builds behaved equally to this):

//Test EEPROM

#include<EEPROM.h>
float y =00.00;
int pressButton=0;

void setup() {

Serial.begin(9600);

float x = 35.00;
const int buttonPin=3;
pinMode(buttonPin, INPUT);
delay(50);

pressButton=digitalRead(buttonPin);
if(pressButton==HIGH){
Serial.println(pressButton);
byte ptr;
ptr = (byte
)&x; //ptr holds beginning address of 4-byte memory space containing value of x
for (int i = 0, address = 0; i < 4; i++, address++, ptr++)
{
EEPROM.write(address, *ptr);
delay(50);
}
}
}

void loop() {
y=(EEPROM.get(0,y));
Serial.println(y);
delay(1000);

}

When using EEPROM.get(), it's advisable to use EEPROM.put() as well. You might have swapped the byte order while writing the way you do.

I would start simple by just storing a single byte variable (e.g. char); does that work?

Please copy to the forum the marks that you have in the central chip of your board. Is it atmega328 or any analog such as LGT8P328 or similar?
Or show the clear photo of the chip.

Did you installed a special package by Wavgat in Arduino IDE?

I used also EEPROM.put(). Same result. It works before powering off. Information is lost when powering on again.

I also used a simple code to store only the value "1" as INT in address 0 and same outcome. It appears that the memory is volatile.

Hi. No special package.

Initially, I thought it was fault of other libraries conflicting with EEPROM.h so I tested the board without any peripherals and loading only EEPROM.h. The problem did not disappear.

I compile after selecting Arduino Uno and AVRISP MKII.
Uploads from PC to board are at 57600bps. This limitation suddenly appeared after that I updated Arduino from an older release to the most recent available. This happened to other people too. Somewhere, I read that the solution was setting the upload speed at 57600 in the file "boards' (path: C:\Program Files (x86)\Arduino\hardware\arduino\avr). The trick worked to an extent because uploads work again but the communication between board and Serial Monitor degraded to 2400bps but only on certain boards such this one.

The central chip says: Wavgat AVGA328P AU 1918.

I did also with EEPROM.put. I tested int, long, float. I tested using 1 byte to 4 bytes, depending on the type of variable. All same results and the code apparently writes and retrieves till the board is on.

In the next days I will try the same code some other board such a Mega or a DUE but different manufacturer and I will see what happens.

This is not a AVR atmega328p what is installed in original Uno.

This is a different chip, not fully compatible with arduino AVR toolchain.
You must install a special package to support it, otherwise you will constantly encounter a weird behaviour.. Ask seller for link to software for the chip.

In general, it’s worth considering whether to buy another board - even with the use of the package from manufacturer, many arduino sketches will work incorrect on this board

By the way, this chip does not have EEPROM, it uses emulation in program memory, so the standard arduino EEPROM.h library does not work

I used this sketch to write 12.34 into EEPROM:

#include<EEPROM.h>
void setup()
{
  float y = 12.34;
  EEPROM.put(0, y);
}
void loop() {}

I can use this sketch to read and display the 12.34, even after unplugging and re-plugging the board.

#include<EEPROM.h>

void setup()
{
  Serial.begin(115200);
  delay(200);
  while (!Serial) {}

  float x;
  EEPROM.get(0, x);
  Serial.println(x);
}

void loop() {}

I suspect you are accidentally overwriting the data. Maybe the button pin is not acting as you expect. Try separate sketches, one with .put() and one with .get() to prove the EEPROM is behaving as expected.

Hello John,

Thank you. I tested your code. Result: 0.00 as in my code!

I think that the solution was shown by one other member, who identified one chip and said that that type of chip does not contain any EEPROM. It just simulates it to maintain compatibility so when the board is turned off, the stored information is lost.
Lesson learnt: I will check the chip codes before buying cards....
Cheers,
Marco

Solution correct. I will use an original AVR atmega328p. Problem solved.

That is weird. The AVGA328P is supposed to store 'EEPROM' data in FLASH so it should still be there after a power cycle.

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