Skip to content

Instantly share code, notes, and snippets.

@smetronic
Created December 16, 2017 12:26
Show Gist options
  • Save smetronic/da54976a568d15cb991094d0019e876a to your computer and use it in GitHub Desktop.
Save smetronic/da54976a568d15cb991094d0019e876a to your computer and use it in GitHub Desktop.
ATMega 328p: function to get Unique Id
#include <avr/boot.h>
void setup(void)
{
Serial.begin(9600);
Serial.println(GetUID());
}
void loop()
{
}
String GetUID() {
String uid = "";
#define SIGRD 5
#if defined(SIGRD) || defined(RSIG)
for (uint8_t i = 14; i < 24; i += 1) {
char buffer[1];
sprintf(buffer, "%x", boot_signature_byte_get(i));
uid += buffer;
}
#endif
return uid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment