I have a console that I plan to use to monitor my devices, and I am developing a “Host” class/library that will added to device firmware to generate and publish data to that console.
One key thing I need is a way to identify the device. Each device has multiple identities:
Serial Number
Device ID
Device Name
I would prefer to use the Serial Number because it can not change and it is not “private information”.
Is it possible to obtain the device’s Serial Number (displayed on the Particle Console) via firmware?
Can you please add a brief example of how to get the serial number for any future searchers who land here and would like the answer without having to search further. Thanks
I've never done this before but I was intrigued so I decided to go ahead and search the docs..
This is what I found:
// EXAMPLE USAGE
void setup()
{
// Make sure your Serial Terminal app is closed before powering your device
Serial.begin(9600);
// Wait for a USB serial connection for up to 30 seconds
waitFor(Serial.isConnected, 30000);
String myID = System.deviceID();
// Prints out the device ID over Serial
Log.info("deviceID=%s", myID.c_str());
}
void loop() {}
Hi Gustavo,
Thanks for your interest. I have the deviceID which is a long hex string. What I'm having trouble with is the Serial number, which looks like base 64 encoded, e.g. B40HVN004CTLAEP. The serial number is printed on the outside of the device so it's easy to see but seems to be hard to retrieve programmatically.
The console has it so it must be coming from somewhere but maybe not visible to the firmware.
Thanks,
Rainer
original post
> | [gusgonnet](https://community.particle.io/u/gusgonnet) Level 3 | Champion November 10 |
> - | - |
RainerR:
Can you please add a brief example of how to get the serial number
Hi Rainer,
I’ve never done this before but I was intrigued so I decided to go ahead and search the docs…
This is what I found:
// EXAMPLE USAGE
void setup()
{
// Make sure your Serial Terminal app is closed before powering your device
Serial.begin(9600);
// Wait for a USB serial connection for up to 30 seconds
waitFor(Serial.isConnected, 30000);
String myID = System.deviceID();
// Prints out the device ID over Serial
Log.info("deviceID=%s", myID.c_str());
}
void loop() {}