Programming firmware with specific constants based on Photon Device ID

I have 14 (and growing) photons used to test out sensors. Each sensor is independently calibrated and the calibration results is six constants that are unique to each Photon. When I flash a device, I have to either maintain a program file for each board, or I have to copy/paste the correct values into the program before compiling it.

I’m hoping to use something like a #ifdef DEVICE_ID directive to check a file and load the correct values for the specific Photon. That way I can maintain one file with the Photon’s device IDs and the specific calibration settings they need.

The Photons have internet while I flash them, but are deployed to remote areas without any internet or cellphone access so they will sleep most of the time.

Anyone have any pointers to get me started?


I know this could definitely be achieved with a Bash script and perhaps by saving the settings to a .csv file for easy manipulation and storage.


You can use an array where the Photon would extract the value from a specific position based on it’s index.


I have a similar situation, I think. The last part of my calibration step is writing my calibration constants to EEPROM. During setup() I just read the constants I need from EEPROM. This way I have a single firmware for all my photons. I’m not sure you need to mess with the DEVICE_ID unless I am misunderstanding what you are doing. And if you have different sensors on each photon you can create a memory map so each sensor gets a specific location in EEPROM and the library can be updated to read the appropriate constants.

Good thoughts. I actually ended up doing that. :smile: