Bluetooth implementation on the micro:bit
The micro:bit processor has an on-board Bluetooth transceiver. This is combined with a PCB trace aerial and other minor components alongside a software stack that gives the micro:bit a certified and credible Bluetooth capability.
Bluetooth software stack
Using Bluetooth, you can connect to other devices and send and receive data from and to the micro:bit.
BBC micro:bit Bluetooth Profile
The micro:bit supports Bluetooth via a single, custom-developed, BBC micro:bit profile. This profile allows it to communicate with other BLE capable devices.
A pre-compiled hex file is available to download for V2 that enables all Bluetooth services.
The source for this can be found in the [microbit-v2-samples]https://github.com/lancaster-university/microbit-v2-samples/tree/master/source/samples repository.
The BBC micro:bit V1 Bluetooth profile is defined in the DAL
You can flash one of two pre-compiled Hex files to the micro:bit V1 that enable bluetooth services. As Bluetooth is memory intensive, these are supplied as either ‘without Magnetometer Service’ or ‘without DFU Service’:
The DAL contains the C++ source for the BLE service files
There are also some example programs in the microbit-samples repository:
The micro:bit has a V2Bluetooth 5.0/V1Bluetooth 4.1 stack with Bluetooth Low Energy (BLE) and supports the V1GAP Peripheral Role and V2 GAP Peripheral and Central device roles.
It operates in the ISM (Industrial Scientific Medical) band, as per all Bluetooth devices. This starts at 2.4GHz and ends at 2.41GHz. BLE divides the frequency band into 50 x 2MHz bands of which 40 are used. These are called channels and numbered 0 to 39. Channels 37, 38 and 39 are used for “advertising”.
When devices are connected, they use the other channels in a particular sequence controlled by a feature called adaptive frequency hopping. This helps reduce the impact of congestion from other radio users.
Data transfer rates will only be a few hundred Kilobytes per second at best, and throughput depends on how your application uses the Bluetooth features. Throughput depends on the proportion of system protocol overheads to application data. Lots of small packets containing - for example - temperature data would have a lower data transfer rate than using the UART service.
There are some useful advanced configuration options in the micro:bit runtime code
It would be possible for anyone with the appropriate knowledge to define and implement other Bluetooth profiles.
We are seeking collaborators to help us define the new profile elements that expose some of the V2 features.
Martin Woolley’s Bluetooth Blog has a range of information on using Bluetooth with micro:bit
BittySoftware has a range of Bluetooth enabled software for the micro:bit
Original micro:bit “Out of the Box” experience, including some of the attributes in the Bluetooth Profile
Full profile with the display unused. If you want to write to the display over bluetooth then you should use this file instead of the ‘Out of the Box’ hex, which uses the display.
Bluetooth and the micro:bit software
The processor also has several non-bluetooth, proprietary modes of operation upon which the micro:bit radio protocol is based. This protocol works only between micro:bits and is defined as ‘Micro:bit Radio’ in the DAL and ‘radio’ in MakeCode, MicroPython, and Mbed C++.
- Android App facilitates pairing and flashing programs to the micro:bit
- iOS Appfaciliates pairing and flashing programs to the micro:bit
- Swift Playgrounds contains a Playground Book available in the Swift app and a micro:bit Swift API to develop further resources
- Scratch supports using a range of micro:bit Bluetooth services via the Scratch Link software and a custom built pairing .hex