In this tutorial we will learn how to obtain the current version of the MicroPython firmware running on a Micro:bit board.
Introduction
In this tutorial we will learn how to obtain the current version of the MicroPython firmware running on a Micro:bit board.
The code shown below will be very simple but the information it provides is useful so we can know the version running on the board. This helps checking the functionalities available in the version we are using and troubleshooting firmware version specific bugs.
For this tutorial we are going to make use of the os module, which will provide the functionality we need to obtain the information.
The code
We will start our code by importing the already mentioned os module, so we can access the functionality we need.
import os
Then, we simply need to call the uname function of the os module. This function takes no arguments and returns some attributes identifying the system [1]. One of them, called version, contains the version of the MicroPython firmware running on the board.
So, we will directly print the values returned by this function call, as shown below.
print(os.uname())
The full code can be seen below.
import os print(os.uname())
Testing the code
To test the code, simply run the previous commands on your Micro:Bit board, using a tool of your choice. I’ll be using uPyCraft, a MicroPython IDE.
After running the code, you should get an output similar to figure 1. As can be seen, I’m running version 1.9.2 of MicroPython on my Micro:bit board.
Figure 1 – Obtaining MicroPython version on the Micro:bit board.
References
[1] https://microbit-micropython.readthedocs.io/en/latest/os.html#os.uname