-1

I am working with an Arduino chip, with which I want to be able to change some parameters by sending it messages onto the serial port. For some reason I do a software reset of the Arduino program every 24 hours.

So I was thinking of saving these parameters into the EEPROM.

I have two questions :

  • If I want to write a variable into EEPROM which has the same value as the one already saved, am I sure that the writing process will not use a cycle using EEPROM.put ? I know there are 100 000 cycles for each bit so I want to be sure.
  • The parameters I want to change have an initial value which are assigned at the beginning of the program. How can I be sure that the Arduino will not rewrite those initial values onto the EEPROM after the daily reboot if they have later been changed by the user ?

Thank you. :)

1 Answers1

1

You can add addition boolean variable called for example initialized. This variable will be saved on EEPROM and you can check it, to be shure that your program variables have been initialized or not. There is pseudocode of your potential program:

byte initialized = EEPROM.read(INITIALIZED_ADDRESS);
if(initialized == 0){
    //write default values another variables to EEPROM
    EEPROM.write(INITIALIZED_ADDRESS, 1);
}

//your program

This program will write initial values to EEPROM only for first time. And you have not to rewrite them again after reboot.

Jan Černý
  • 1,268
  • 2
  • 17
  • 31