Say I publish at the rate of every 5 seconds, then I use the Particle.function to change the publish rate to 30 seconds. However, if I power cycle the Particle Electron, the program starts publishing at 5 seconds interval again. Is there a way to “store” a variable value in the Particle Electron?
The best method to store persistent parameters is to use EEPROM. Retained RAM is another approach but be aware that you need to keep power on the VBAT pin otherwise a power cycle will wipe it. If you search the forum EEPROM or Retained RAM you will find many examples - @shanevanj has provided one such to the reference documents.