Serial over USB

The microbit has a USB serial interface allowing serial communication over USB. The ‘REPL’ feautre in mu is a serial connection to the microbit.

To access this interface, the mbed serial drivers must be installed:

Once installed, plugging in the microbit will cause a COM port to appear on the the host computer:

Device Manager

This indicates the microbit is attached to COM port 5.

With this, it’s possible to connect to the microbit with a terminal application. The microbit can take instructions over the terminal. It can communicate with microbit flashed with a PXT-based or Python-based hex file.

Terminal Applications

The settings for the terminal connection are the same whether it’s a pxtor python hex:

Tera Term

Tera Term is an open source application that’s straight forward to use:

Open the correct COM port:

Tera Term open com port

Change connection properties under Connection > Serial...:

Tera Term change serial options

Realterm

Realterm is an open source terminal application that’s a little more complicated than Tera Term. It gives more options, especially when logging.

Realterm

Note about Serial UART & Python

This example, and many others on this website, connects to a python microbit over USB. It uses the 115200 baud rate by default. It also tends to use print() instead of uart.write().

It’s possible to use the uart module to read and write data, change the baud rate, and use the physical pins as opposed using USB.

It’s important to note uart.write("hello") and print("hello") are exactly the same: they both output to stdout.

However the uart module exposes many useful functions such as uart.readall() and uart.any()

There’s more on the microbit python documentation.

Going Further

Establishing a serial connection is useful when developing applications on the computer to interact with the microbit:

Share On
Facebook Twitter Google Plus

Published: December 23, 2016 Updated: December 23, 2016

Serial over USB

How to connect to the microbit as a serial device to read data.

Jez Dean
Teacher