Created
December 16, 2017 12:26
-
-
Save smetronic/da54976a568d15cb991094d0019e876a to your computer and use it in GitHub Desktop.
ATMega 328p: function to get Unique Id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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