Hello,
I am new to Particle and using the Photon module.
I am connecting several pairs of photon devices and trying to store the “paired” device ID in non-volatile memory. I’ve had success using the EEPROM functions, get() and put() to store and read a 24 char string (the size of the device IDs), but the EEPROM data is lost upon power loss or reset. When I utilize cloud function below, I am returned a “1” which tells me that the EEPROM write worked correctly. I am using Particle Dev to check the “pairedID” string through a cloud variable.
Am I doing something wrong?
My code is very simple:
//setPairedCandle() is a cloud function
int setPairedCandle( String candleID )
{
String IDcheck;
EEPROM.put( 0, candleID ); //Store candleID into Flash memory
EEPROM.get( 0, IDcheck ); //Read candleID from Flash memory
if( (strcmp(candleID, IDcheck))==0 ) //If successful EEPROM write
{
EEPROM.get( 0, pairedID ); //Update the pairedID
return 1;
}
else
return 0; //Return 0 if unsuccessful
}
I am not partial to using the EEPROM functions, I just need a way to permanently store the device ID of the paired candle on the photons. Any help would be much appreciated!
Thanks,
-Joshua