Data in Arduino UNO's EEPROM changes after 3-4 days randomly

Two observations

void ReadFromTransmitter()
{
  long total = 0;
  int cal_watt;

cal_watt is not initialised; as a result it might have whatever value. You have to make sure that all the if/else if/else in that function cater for every possibility. If it doesn't, the below gives a buffer overflow if cal_watt is greater than 999.

  sprintf(power, "%03d", cal_watt);

In your current code below is OK

char tx_status[3];
...
  strcpy(tx_status, "ON");

If you ever want to to copy "OFF" in tx_status, you have a buffer overflow again.

1 Like