microbit-uart drogue-device example

This example application runs out of the box on the BBC micro:bit v2.0. It provides a UART echo server that will echo characters you write to the micro:bit serial interface, and it will display ascii characters on the 5x5 LED display.

Prerequisites

Hardware

  • BBC micro:bit v2.0

  • USB to Serial cable

  • (Optional) edge connector to access pins - this is just for simplifying connecting to the serial pins

Connect the TX to P15 and RX to P14 on the micro:bit.

image::https://raw.githubusercontent.com/drogue-iot/drogue-device/main/examples/nrf52/microbit/uart/images/connector.jpg[microbit edge connector]

Software

To build and flash the example, you need to have rustup. In practice you can use whatever tool you want to flash the device, but this guide will assume that probe-run is used (cargo install probe-run).

Building

To build the firmware:

cargo build --release

Flashing

Flashing the firmware uses probe-run which auto-detects the probe connected to your device. The following command will build and flash the firmware and open the debugger console so you can see the console debug output.

cargo run --release

If you’re experiencing problems, try setting the VID:PID values to that of your probe (you can find that from lsusb once your board is powered).

cargo run --release -- --probe <VID>:<PID>

Using minicom program to talk to echo server

Once the firmware is running, you can connect the serial console. I’m using minicom for this, but there are lots of options. The most important thing is to use the following settings:

  • 115200 Baudrate

  • 8N1 (8 data bits, 1 stop bit)

  • No hardware flow control (default is ON for minicom, so remember to turn this off)

The command:

minicom -D /dev/ttyUSB0

Once connected, press the `A' button on the micro:bit to start the echo server, and you can start typing characters into the minicom terminal.

Watch the video for a demonstration:

Watch the video