Free shipping within Canada on orders over $150

micro:bit as a Bluetooth Low Energy gestural controller

We're finding more and more to do with the micro:bit. Not merely did Craig upgrade his Christmas Tree decorations to be micro:bit-powered and NeoPixel-driven, but we also discovered how to use a micro:bit as a BLE gestural controller. Best of all, it doesn't need much extra hardware beyond a micro:bit go kit and a BLE-capable computer (like a Raspberry Pi Zero W or Raspberry Pi 3). You can also use the same micro:bit code with Bitty Software's “bitty blue” app for iOS or Android.

The micro:bit has a bunch of sensors built in — accelerometer, compass, temperature, buttons, digital and analogue I/O, plus the 5×5 LED display — and they can be read and set over BLE.

To start, you'll need to download and install the Bitty Blue firmware hex file onto your micro:bit over USB. The download file is here— — and choose the “no pairing required” version. Once the program is on your micro:bit, it will ask you to draw a circle by tilting the micro:bit to calibrate the magnetometer.

Next, you'll need to associate the micro:bit with your Raspberry Pi. Open a terminal and type bluetoothctl, then enter the following commands. I've added some comments following # signs; you don't have to type those:

scan on  # start looking for new devices
  Discovery started
  [CHG] Controller B8:27:EB:0E:C8:6B Discovering: yes  # ← your BLE adapter address
  [NEW] Device D5:9F:24:AE:0C:EC BBC micro:bit [zozug] # ← your micro:bit BLE address
connect D5:9F:24:AE:0C:EC                              # use your micro:bit BLE address
  Attempting to connect to D5:9F:24:AE:0C:EC
  [CHG] Device D5:9F:24:AE:0C:EC Connected: yes
  Connection successful


Now install python-bluezero so you can talk to your micro:bit:

sudo pip3 install bluezero


Then you can run a little program like this to scroll messages on your micro:bit's LEDs:

#!/usr/bin/env python3
# encoding: utf-8

from bluezero import microbit
# important: change adapter_addr and device_addr to the values you got above
ubit = microbit.Microbit(adapter_addr='B8:27:EB:0E:C8:6B',
my_text = 'Hello, world'

while my_text is not '':
    ubit.text = my_text
    my_text = input('Enter message: ')



(For more examples, please see Barry Byford's RPi <-> micro:bit Workshop, from which this blog post is derived.)

I'm working on getting all the buttons on the SparkFun gamer:bit board to work with bluezero. Then it will be a real game controller!

Stewart Russell
Stewart Russell


mostly harmless

Leave a comment

Comments will be approved before showing up.