Your micro:bit's name — try this in #MakeCode
I’m re-visiting the micro:bit after a couple of years absence, for some new projects. Some notes and explorations on this to come. But here’s one about each device’s unique name you can try in MakeCode.
Each micro:bit has a unique serial number set at manufacture which can be displayed as a five character name. You can display it by:
- in a new project, swap into JavaScript editor view and type
let myName = control.deviceName()
myName
is going to be the variable where we can access the micro:bit’s name.
- now swap back to blocks view and you’ll see a
myName
variable being set—you can display it as you would with any text, such as in ashow string
block.
You’ll need to download your code to a real micro:bit, then take a look at the result, which will be five characters, for example gozut — yours will be different.
What’s the use? Say you’re using several micro:bits to measure temperature and sending their data over Bluetooth. By including the name in the data, you can distingush each micro:bit’s values.