micro:bit radio bluetooth bridge

We all know that the micro:bit is unable to use bluetooth or radio functionality at the same time. However...what would happen if we gave the sending micro:bit an extra external bluetooth interface?

Whilst watching a presentation by Martin O’Hanlon  at the PiWars Conference earlier today about creating a bluetooth based controller for a robot using BlueDot 2.0 I was reminded of an idea I had last year.

Basically the idea was about remote controlling a device that was connected to a micro:bit which in turn was accepted remote commands from another micro:bit over a radio link.

Yes..I know using micro:bit radio as remote control system has been covered in great depth but could it be adapted to allow any device to connect to the micro:bit over bluetooth and then remote control the remote micro:bit

Confused yet?...I was at first :)

The idea

We all know that the micro:bit is unable to use bluetooth or radio functionality at the same time. However...what would happen if we gave the sending micro:bit an extra external bluetooth interface?

Could we then use this external interface with the micro:bit to form a bridge allowing devices to connect and send commands via the sending micro:bit's radio link to another micro:bit (or collection of micro:bits) in the same radio group?

If we could then this opens up all sorts of possibilities for mischief. Imagine being able to control a fleet of micro:bit robots from one application running on your laptop.

The HC-05 bluetooth module was chosen to see if the idea had any merit. It was chosen due to being sat unused in the parts bin...it's entirely possible that other similar spec'd devices will also be fine to use.

The circuit below was adapted from a similar a circuit which used an arduino instead of a micro:bit:

The code for the sender micro:bit is shown below:


function sendOrder () {
    basic.showString(order)
    serial.writeLine("Got: " + order)
    if (order == "lef") {
        basic.showIcon(IconNames.Happy)
        radio.sendString("left")
    } else if (order == "righ") {
        basic.showIcon(IconNames.Sad)
        radio.sendString("right")
    }
    basic.clearScreen()
}
input.onButtonPressed(Button.A, function () {
    serial.writeLine("left")
    radio.sendString("left")
})
input.onButtonPressed(Button.B, function () {
    serial.writeLine("right")
    radio.sendString("right")
})
serial.onDataReceived(serial.delimiters(Delimiters.NewLine), function () {
    basic.showIcon(IconNames.Yes)
    order = serial.readLine()
    order = order.substr(0, order.length - 1)
    sendOrder()
})
let order = ""
radio.setGroup(1)
serial.redirect(
SerialPin.P0,
SerialPin.P1,
BaudRate.BaudRate9600
)
basic.pause(100)
serial.writeLine("mb connected :)")

I have not included any code for the receiving micro:bit. Any code you do write just needs to listen on the same radio group and react to any strings being transmitted.

This will be trivial for experienced micro:bit users but will also be a nice little learning opportunity for those new to micro:bit radio functionality.

Example

The video below shows a prototype build controlling a remote micro:bit plugged into a Valenta robot car.

The sending micro:bit relays commands, via the radio module, from the HC-05 which is connected serially.

The HC-05, in turn, receives simple strings over bluetooth...in this case from a Bluetooth terminal android app (App install at your own risk) running on a an old Fire tablet.