Device identifiers

Serial number

All recent Particle devices have a serial number. This is printed on a sticker attached to the device, and is generally also on a sticker on the outside of the box.

The serial number is useful for onboarding a new device, but we do not recommend using the serial number as a unique identifier in your database. The reason is that the API to look up a device by its serial number is rate limited for security reasons. To avoid using this API, you need to list all devices in your product, which is not particularly efficient either.

To get the serial number from user firmware:

char serial[HAL_DEVICE_SERIAL_NUMBER_SIZE + 1] = {0};
int ret = hal_get_device_serial_number(serial, HAL_DEVICE_SERIAL_NUMBER_SIZE, nullptr);
if (ret == SYSTEM_ERROR_NONE) {
  // Success
}

HAL_DEVICE_SERIAL_NUMBER_SIZE is currently 15. Note that serial is not null terminated by hal_get_device_serial_number but is by the example code by making the buffer 1 byte larger and zero initializing it.

The serial number is available by the Particle cloud API get device information in the serial_number field.