Microbit: Get Start Micropython in BBC Microbit

If you been reading our blog, we may have come across a topic which is comparing Python vs MicroPython. The difference had been discussed, so excited to know more on micropython. Hence, in today article, we will introduce Micropython and its platform. Let discuss here.

monty-python cartoo
monty-python cartoo

What Is MicroPython?

Micropython logo
Micropython logo
  • Python code is first compiled to a byte-code and then fed to an interpreter, which is a large C program. A popular aspect of Python is the interactive interpreter mode or read-evaluate-print-loop (REPL), a way to interact with Python via a command-line interactive prompt to test out concepts before committing the code to a .py file.
  • MicroPython is a software implementation of a programming language largely compatible with Python 3, written in C, that is optimized to run on a microcontroller.
  • MicroPython is a full Python compiler and runtime that runs on the microcontroller’s hardware. The user is presented with an interactive prompt (the REPL) to execute supported commands immediately.
  • MicroPython firmware can also be built and ran without the compiler because the virtual machine can run pre-compiled (.mpy) programs.
  • MicroPython runs entirely on the micro:bit itself – no need for a compiler.
  • MicroPython comes with lots of exclusive features: a powerful music programming language, a speech synthesiser, built-in images and music, a local file system and a large range of ways to connect to attached devices: I2C, NeoPixel, SPI and UART.

MicroPython in BBC Microbit

other python platform
other python platform
  • Commonly use editor for micropython development:
  • The editors described above combine this file with your code to generate the file you copy onto the device.
  • When you write your Python application, both the web hosted editor and the offline editor Mu create a modified .hex file for you to copy to the microbit. This modified file contains
    • An identical copy of the base MicroPython .hex code file;
    • A small header which marks a region as a MicroPython script (followed by the length of the script in bytes);
  • As a result, Mu and the uflash command are able to retrieve your Python code from .hex files (even if you forgot to save your source code).
  • When you flash (i.e. copy) a .hex file into the microbit it reboots. MicroPython looks for your script in a special memory address. If it finds a script it’ll attempt to run it.
code in mu
code with mu

Finally, the hex code transfer to microbit using uflash can be decoded by uflush command if you have not save your original code. There is couple of features that uflash support.

Take care and stay healthy.

Leave a Reply

Your email address will not be published. Required fields are marked *




Enter Captcha Here :