Developing Applications
for the BBC Microbit

The Story So Far

In Part 1 of my BBC micro:bit series, I explained the background of the BBC micro:bit, a remarkable programmable device which will inspire school children to get creative with coding and making things. I also shared a quick look at its architecture and main features.  In Part 2, I gave a guided tour of the micro:bit’s default Bluetooth® profile. In this final blog post, I’ll be examining ways in which you can create code for the micro:bit, and how you can write code for other devices which allow them to interact with the micro:bit over Bluetooth.

Take Your Pick

One of the things I think sets the micro:bit apart from other comparable devices for the education sector is the fact there’s a significant collection of tools and languages available to the budding programmer. The fact that this has been accomplished in such a short time is testimony to the level of support there is out there from all sorts of organisations and technical communities.

There are several development tools for the complete beginner and I’ll discuss them next. But there are also approaches to developing for micro:bit which, coupled with the fact that its runtime is open source, mean you can get in very deep and learn anything and everything about what makes this device tick. There’s a joke about timers in there somewhere. I’ll leave that one to you.

This means the barrier to entry for becoming a micro:bit developer is very low but the ceiling governing how much you can learn is very high. Want to know how multiplexing and persistance of vision is used to make the micro:bit 5 x 5 LED display work? It’s all there in the runtime code and it’s described in Lancaster University’s excellent documentation.

Development Tools for Beginners

The BBC provided a collection of online development tools for beginners. I’ll discuss them shortly. Since the BBC’s site was launched, Microsoft has been busy creating their own micro:bit development site and I’ve been working with them to provide comprehensive capabilities for developers who want to make use of Bluetooth on the micro:bit.

codethemicrobit.com

The new Microsoft site is www.codethemicrobit.com and, in my opinion, it is by far the best of the online micro:bit development tools for beginners and the best tool if you want full access to the micro:bit’s Bluetooth profile.

It provides a visual programming, drag-and-drop tool involving building application logic by arranging graphical programming blocks representing predefined, parameterised functions. And it’s very easy to use.

To use Bluetooth in your micro:bit application you first need to add the Bluetooth package to your project using the menu More/Add Package.

Figure 1 – Adding the Bluetooth Package to a codethemicrobit Project

Once this is done, you have a complete collection of Bluetooth related ‘blocks’ with which to build the Bluetooth capabilities of your application. Many are very simple and merely result in a given Bluetooth service being available at run-time. But there are also blocks which provide access to Bluetooth connect and disconnect events and the Bluetooth UART service can be used to transmit arbitrary data to a connected peer or to receive data from a peer device.

Figure 2 – The codethemicrobit Bluetooth Package

If you read part 2 of my micro:bit blog series you’ll probably spot that there are a few services missing from the list of blocks above. For historical reasons relating to the BBC requirements, the Device Information, DFU and Event services are currently included automatically as long as you use at least one of the other services from the Bluetooth blocks shown above. We still have some work to do and the aim is for all Bluetooth services to have their own blocks in the codethemicrobit.com Bluetooth package so that you have complete control over exactly what Bluetooth capabilities your micro:bit code has.

To illustrate the power of codethemicrobit.com, here’s an application which implements the micro:bit side of my Animal Vegetable Mineral guessing game which you can see on our micro:bit page or in YouTube. It took only 10 minutes to create.

Figure 3 – micro:bit Animal, Vegetable, Mineral Guessing Game

I think Microsoft’s codethemicrobit.com is just fantastic and the team behind it has done an amazing job. It’s easy and it’s flexible, most importantly, for Bluetooth developers there are only a few constraints regarding what you can or cannot do.

FEATURED DOWNLOAD

An Introduction to Bluetooth Low Energy Development

This self-study educational resource covers both theory and practice of Bluetooth Low Energy GAP and GATT application development. The guide will equip you with a solid understanding of key Bluetooth Low Energy concepts before guiding you through a series of software development projects that will allow you to put the theory into practice.

DOWNLOAD NOW

microbit.co.uk

The BBC’s online tools for the beginner are all available at www.microbit.co.uk . Two are from Microsoft and are called “Blocks” and “Touch Develop” (or “TD” for short). The third is from a company called Code Kingdom and I’m informed it sits on top of Microsoft’s TD APIs.

All three of these tools are suitable for beginners. Blocks is similar to Microsoft’s tool at codethemicrobit.com but does have a number of limitations, including with respect to Bluetooth.

Figure 4 – The Microsoft Block Editor

TD and the Code Kingdom editors use scripting but within what I can only describe as an intelligent user interface which guides and assists. They best way to get a feel for this is to give it a try.

Figure 5 – Touch Develop and the Code Kingdoms Editors Side by Side

Even with these three tools for beginners you can create Bluetooth applications. You are limited to a range of predefined use cases designed to be used in conjunction with the official micro:bit Android application from Samsung but you can still do some very cool things. These limitations were implemented to ensure things stay as simple as possible for the novice developer whilst introducing them to the world of wireless communications. There are other tools for those who want to do more and I’ll cover those shortly.

The Samsung Android application allows developers to write code and flash it over Bluetooth to their micro:bit all without touching a PC of any sort. You can code on your phone or tablet which is a fantastic capability. Microsoft’s Blocks’ editor seems particularly well suited for this. Here’s a video of me programming my micro:bit to be a music player Bluetooth remote control. Watch just how easy and gratifying this is.

Related Resources

Intro to Bluetooth Low Energy Coded PHY

Learn more about one of the key features introduced to Bluetooth — the LE…

Intro to Web Bluetooth

Web Bluetooth is an exciting new advancement in Bluetooth Low Energy development. Watch to…

Lessons and Growth in Bluetooth Angle of Arrival & Departure

Bluetooth 5.1 features Angle of Arrival (AoA) and Angle of Departure (AoD). See a…

Unlocking the Potential of the Smart Home

See how the Bluetooth Smart Home Subgroup is making intelligent and integrated smart home…

Inside Bluetooth Direction Finding and More

Watch Wiliot’s Steve Statler and the Bluetooth SIG’s Ken Kolderup discuss the newest Bluetooth…

Leveraging Sensors to Support Location Based Marketing

The world of location-based marketing is rising rapidly as advertisers are realizing the value…

How to Make Wearables Bluetooth Mesh Provisioners

Learn how to create applications for smartwatches and other platforms that can monitor and control nodes in a Bluetooth mesh network.

Creating Enterprise IoT Applications with Web Bluetooth

Watch the Bluetooth SIG’s Martin Woolley discuss how the web and Bluetooth have come…

2019 Bluetooth Market Update

Supported by updated forecasts from ABI Research and insights from several other analyst firms, the Bluetooth Market Update highlights the latest Bluetooth trends and forecasts.