How to connect to the microbit as a serial device to read data.
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:
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.
The settings for the terminal connection are the same whether it’s a
Tera Term is an open source application that’s straight forward to use:
Open the correct COM port:
Change connection properties under
Connection > Serial...:
Realterm is an open source terminal application that’s a little more complicated than Tera Term. It gives more options, especially when logging.
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
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
print("hello") are exactly the same: they both output to
uart module exposes many useful functions such as
There’s more on the microbit python documentation.
Establishing a serial connection is useful when developing applications on the computer to interact with the microbit:
Published: December 23, 2016 Updated: December 23, 2016