Retrieving system properties with code
Now, let us see some Micro:bit-specific MicroPython code. This code is only run on MicroPython running on the Micro:bit. It won’t run on the standard Python 3 interpreter. Let’s see the properties of our Micro:bit device as follows:
# micro:bit specific MicroPython code import machine print("Unique ID : " + str(machine.unique_id())) print(str(machine.freq()/1000000) + " MHz")
The program prints the unique ID and the frequency of our Micro:bit board. The following is the output:
>>> %Run -c $EDITOR_CONTENT Unique ID : b'$\xd1\xb4[\xe2a?\xd5' 64.0 MHz
This is how we can fetch and display system properties.