The micro:bit has a register mapped into it's memory called the FICR (Factory Information Configuration Register) that stores information programmed in at manufacturing time. One of the items programmed in is a unique* serial number.
You can use this to identify the micro:bit in your program. Here's how to show the serial number on the display
from microbit import * import machine def get_serial_number(type=hex): NRF_FICR_BASE = 0x10000000 DEVICEID_INDEX = 25 # deviceid return type(machine.mem32[NRF_FICR_BASE + (DEVICEID_INDEX*4)]& 0xFFFFFFFF) # Scroll the serial number on the LED display display.scroll(get_serial_number())
NRF51 SDK header file with register map
* The serial is actually a 64-bit factory generated pseudo-random number etched into each processor. Only 32 bits are used here though (as that makes it consistent for all the micro:bit higher level languages to deal with), and still enables it to be unique for most practical applications. To put this into context, you'd need about 100,000 to 250,000 micro:bits in one place to expect a duplication.
Based on this idea https://gist.github.com/microbit-carlos/d3110c69ee30ee2c92feca1397105cb0
Keywords for search: name, rename, ID