Your microbit’s friendly name

:: microbit

Each micro:bit has a unique serial number, built in at manufacture. This number also translates to a friendly five-character name, which is a bit easier for people to recognize; here’s how to find it out.

One of the many brilliant things about the micro:bit is that (using Microsoft’s MakeCode pxt blocks language) there is a library to send and receive messages over the bluetooth radio. You can construct custom messages to send, for example, the information from micro:bit sensors.

An example of using this would be to have several micro:bits relaying data to a central micro:bit which can log the data. But how to distinguish one micro:bit from another? Fortunately each board has a unique serial number built into it.

Here’s what a data packet received from such a system might look like:

{"t":245575,"s":-347021444,"n":"button A"}

In this case:

  • t is a timestamp,
  • n is an indication of which button is pressed on the sending micro:bit,
  • and s is the unique serial number of the sending micro:bit.

A friendly five-character name would be easier to read than -347021444. This script puts the name into a variable and displays on the micro:bit leds.

The JavaScript equivalent is:

let myName = ""
myName = control.deviceName()
basic.showString(myName)

The popup documentation for this is:

Using this function, you’ll see a friendly name such as zevog instead of the serial number.