Create mobile apps for iOS and Android connecting to the BBC micro:bit

Alex JonssonBlogs, Tutorials

BBC-Logo
Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+

microbitAs this March 2016 – the World became a wee bit better place; The British Broadcasting Corporation commenced its fabled launch of the Micro:bit single chip computer, with the ultimate goal to provide each school child aged 11-12 with their own computer that they can work, play with and program themselves. There is an extensive site available with more information and links to both simple on-line services and downloads for more sophisticated tools.

At 16MHz, its dual-core ARM Cortex M0 is perhaps not the most powerful microprocessor around, but enough to carry out sensor readings, send out strings of accentuator commands and other fairly sophisticated operations e.g. when using the 5×5 LED matrix display. At Evothings, we were asked by the consortium around the micro:bit if we would like to contribute with our technology, allowing for supporting mobile apps to be developed faster and easier using web technologies which are easy to learn for both kids, teachers and other adults too. We have focused on the communication over the Bluetooth Low Energy radio, and have created a few examples appropriate for the current “vanilla build of micro:bit build with ARM mbed firmware”. All these demos are released as Open Source under the Apache 2 license, and are hence free to use, modify, enhance and even sell for a profit if you’d like, without our consent or knowledge ☺ The code is fairly well-structured, and verbosely commented to ease usage, and to better understand which part does what in each example.

Pairing up

Here are some things you need to know about how to connect your micro:bit. First of all, a micro:bit is meant for operations in schools and other enviroments that need to be safe, and where it’s possible that there are a lot of micro:bits transmitting at the same time. As a precausion, a micro:bit will therefore whitelist any paired devices, so any device without a bond won’t be able to connect. Period. Also note that when device has no bonds, it won’t even bother advertising. Once it has created one or more bonds to other devices, it will advertise anonymously as “BBC micro:bit”. It also means that encryption is required at all times.

Pairing is only permitted in a special pairing mode, which you enter by holding down both buttons on each side of the LED screen (called A & B), and pressing the third button on the back “RESET” with your other fingers, or nose. The 5×5 LED screen will say “PAIRING MODE” and show a modern-art-looking pattern.

On Android, you’ll see the micro:now in settings> bluetooth> available_devices, whereas on iPhone you can’t pair via the OS settings and need to pair via an app instead, here an example using Samsung’s micro:bit app.

If you pair using the Samsung app, you need to copy the above mentioned pattern, so you know you’re pairing with the right micro:bit in a room full of others, each brandishing their own one. Follow the rest of the on-screen instructions to pair up your micro:bit and your phone.
Micro:bit now advertises as BBC micro:bit[xxxxx], where xxxxx is a five-letter friendly name.

Note; You can of course make your own firmware using ARM’s mbed framework with a looser security policy in place. This and other tools for embedded development can be found on BBCs official site for the Micro:bit.

Running some Evothings demo apps

In order to run these projects, you’ll need Evothings Studio. It contains an application called Workbench for your computer and an app called Evothings Viewer, which for your Android and iOS devices. Download from evothings.com/download (and the apps from your Apple iTunes or Google Play, just search for “evothings viewer”).

Note; these examples are already in Evothings Studio when you download, just copy them in the Workbench from the Examples’ tab to “My Apps” so you can edit and modify according to your own liking.

The first example is a kitchen sink demo, getting the available sensor data out. Note that turning everything on (known as xmas tree mode) makes all sensors share the data channel, and will run slower if say, only a few sensors were propagating data.

https://evothings.com/doc/examples/microbit-sensors.html

The second example runs the accelerometer sensor, in three dimensions (x,y,z) and plots the data across a timeline in red, green and blue.

https://evothings.com/doc/examples/microbit-accelerometer.html

The third example allows users to send text over Blueooth Low Energy to from the phone to the micro:bit, to be displayed on the 5×5 LED matrix.

https://evothings.com/doc/examples/microbit-led.html

We at Evothings take this opportunity to challenge you as a developer to create your own stunning application, either based on one of these examples or by combining any of the sensors of the micro:bit for the learning and pleasure of the micro:bit community.

There are also further plans to release the entire software stack of the micro:bit, its hardware and much of the supporting application frameworks to the community. Eventually, micro:bit technology will be released to the general public, and many players will offer similar hardware, accessories and supporting software during the latter part of 2016 and onwards.

Go ahead, make some apps!