Sunday, 23 April 2017

Bitty Data Logger 2.3

A new release of Bitty Data Logger from Bitty Software is now available for both Android and iOS. Check Google Play and the Apple App Store for the update.

This release aims to streamline the process of using the app for Bloodhound Race for the Line competition participants (see Key data may now be uploaded direct to the Bloodhound leader board after data has been collected.

Changes in this release are:

1. Data logging projects may now be designated as type 'Bloodhound Race for the Line' or 'Other'

2. Results from Bloodhound projects (rocket car races) may be uploaded directly to the Bloodhound Leader Board

3. Minimum and maximum acceleration in X, Y and Z directions are now recorded in results

4. Certain types of data in results may now be edited to correct mistakes prior to upload or posting to the Bloodhound Leader Board

It is recommended that you uninstall Bitty Data Logger and then install the new release from the application store.

That's it


Thursday, 20 April 2017

Making the micro:bit accelerometer available over Bluetooth

Here's a very simple C/C++ application, created using the mbed web IDE.

The project was created in the mbed IDE with the following parameters:

Platform="BBC micro:bit", Template="An example of how to use the micro:bit DAL's abstract....." and Project Name=-"microbit-ble-accelerometer"

All it does is establish event handlers for Bluetooth connect and disconnect events and adds the Bluetooth accelerometer service so that an application like micro:bit Blue or Bitty Data Logger can receive accelerometer data over Bluetooth.

#include "MicroBit.h"

MicroBit uBit;

void onConnected(MicroBitEvent)

void onDisconnected(MicroBitEvent)

int main()
    // Initialise the micro:bit runtime.

    // Insert your code here!
    uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected);
    uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected);

    new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);

    // If main exits, there may still be other fibers running or registered event handlers etc.
    // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then
    // sit in the idle task forever, in a power efficient sleep.

I also set MICROBIT_BLE_OPEN to 1 in microbit-dal/inc/core/MicroBitConfig.h so that pairing is not required. Much easier for testing purposes.

#define MICROBIT_BLE_OPEN                       1

After compiling to produce a hex file, copy the hex file onto your micro:bit. An application like nRF Connect on a smartphone or tablet should see a Bluetooth service with UUID which starts 0xe95d0753-. This is the accelerometer service. Enabling notifications on the first characteristic (Accelerometer Data) will result in its value updating when you move the micro:bit.

The project has been published here:

Tuesday, 7 February 2017

Pairing a BBC micro:bit with a Raspberry Pi using BlueZ

A Raspberry Pi 3 has Bluetooth low energy built in and a Raspberry Pi 2 can have a Bluetooth USB dongle plugged into it to give it Bluetooth capabilities. BlueZ, the Bluetooth stack for Linux needs then to be installed. Once done, you have a Bluetooth enabled Raspberry Pi.

But what about your BBC micro:bit? Well, the easiest way to use your Pi with your micro:bit is to install a hex file whose settings do not require it to be paired to another device before it can be used. PXT lets you pick whether or not pairing is required and if so, whether you want to use "passkey pairing", where you enter a 6 digit number displayed by the micro:bit or "just works" pairing, where all you need to do is initiate the pairing process, and the rest happens by magic.

If you opt to use passkey pairing, it's possible to have BlueZ pair your micro:bit with your raspberry Pi. After that, any communication with the micro:bit from the Pi will use that pairing information and where necessary, data will be encrypted.

Here's an example of me pairing my Raspberry Pi with my micro:bit using BlueZ from a Linux terminal session:

pi@raspberrypi:~ $ sudo hciconfig hci0 down
pi@raspberrypi:~ $ sudo hciconfig hci0 up
pi@raspberrypi:~ $ sudo bluetoothctl
[NEW] Controller B8:27:EB:C5:E9:31 raspberrypi [default]
[NEW] Device D0:F5:DF:C0:AE:95 BBC micro:bit
[NEW] Device 90:03:B7:C9:9C:D8 Flower power 9CD8
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:C5:E9:31 Discovering: yes
[CHG] Device D0:F5:DF:C0:AE:95 RSSI: -61
[CHG] Device D0:F5:DF:C0:AE:95 Name: BBC micro:bit [vuzig]
[CHG] Device D0:F5:DF:C0:AE:95 Alias: BBC micro:bit [vuzig]
[CHG] Device 90:03:B7:C9:9C:D8 RSSI: -80
[bluetooth]# paired-devices
Device D0:F5:DF:C0:AE:95 BBC micro:bit [vuzig]
[bluetooth]# remove D0:F5:DF:C0:AE:95
[DEL] Device D0:F5:DF:C0:AE:95 BBC micro:bit [vuzig]
Device has been removed
[bluetooth]# agent KeyboardDisplay
Agent registered
[NEW] Device D0:F5:DF:C0:AE:95 BBC micro:bit [vuzig]
[CHG] Device 90:03:B7:C9:9C:D8 RSSI: -89
[bluetooth]# pair D0:F5:DF:C0:AE:95
Attempting to pair with D0:F5:DF:C0:AE:95
[CHG] Device D0:F5:DF:C0:AE:95 Connected: yes
Request passkey
[CHG] Device D0:F5:DF:C0:AE:95 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device D0:F5:DF:C0:AE:95 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device D0:F5:DF:C0:AE:95 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Device D0:F5:DF:C0:AE:95 UUIDs: e95d93af-251d-470a-a062-fa1922dfa9a8
[CHG] Device D0:F5:DF:C0:AE:95 UUIDs: e95d93b0-251d-470a-a062-fa1922dfa9a8
[CHG] Device D0:F5:DF:C0:AE:95 Appearance: 0x0200
[agent] Enter passkey (number in 0-999999): 959145
[CHG] Device D0:F5:DF:C0:AE:95 Paired: yes
Pairing successful
[CHG] Device D0:F5:DF:C0:AE:95 Connected: no

I've highlighted the text I entered in red. Initially, I brought the Bluetooth adapter's HCI (Host Controller Interface) down then up. This is a handy way to reset it and in my experience, this is sometimes necessary.

I then put my micro:bit into pairing mode.

Having done so, I launched "bluetoothctl", a utility that lets me enter various commands.

Once started, I ran "scan on" to start BlueZ scanning for other devices, and as you can see, it lists the Bluetooth devices that it finds, including a micro:bit.

I then ran "paired-devices" to see what devices my Pi was already paired with. It listed my micro:bit so to start with I removed that pairing. You should always do this if you've installed a new hex file on the micro:bit since this will have caused any previous pairing information to be lost from the micro:bit and the micro:bit and the device it is paired with must both have the same pairing information.

Then I specified "agent KeyboardDisplay". This tell the BlueZ to inform other devices that it is a device with both a keyboard and a display, during the pairing process. The point here is that during pairing, the two devices exchange information about each other's IO capabilities and this is used to determine what the best way to go about pairing might be. If neither device had a keyboard, for example, there would be no point trying to perform passkey pairing.

After that, I initiate pairing with the MAC address of my micro:bit as an argument. Pairing proceeds and the micro:bit display responds with an arrow on its display, pointing at button A. I pressed button A and was prompted on the Pi to enter the passkey displayed on the micro:bit.

And that's all there is to it. There's even less to do if you load a hex file configured for "just works" pairing.

Thursday, 2 February 2017

BETT 2017

Bett is a large conference and exhibition focused on technology and education. It has a very international attendance. I was there this year for the second time and spoke to people from various European nations as well as from the USA, Singapore and Hong Kong.

micro:bit featured all over the place as well as of course in the micro:bit Education Foundation's area.

Microsoft were everywhere as well! Rightly so. I love what Microsoft have done for developers with PXT, in particular.

Perhaps best of all, I got to see the Bloodhound project for schools going through its paces. They had an awesome set up, allowing two rocket cars to be raced inside a perspex safety "tunnel" with accelerometer data streamed from their embedded micro:bits over Bluetooth to tablets running my Bitty Data Logger application. Wonderful!

I gave a presentation, both on Wednesday and Thursday, about the opportunity afforded by the emerging Internet of Things and how micro:bit and Bluetooth are providing a great vehicle for educators to prepare youngsters for the Age of IoT when they leave the education system. You can see highlights of the presentation in this short video:

Thursday's presentation was very well attended, with standing room only, which is always very gratifying. And I got a "good job!" from none other than a teacher. That definitely made my day :-)

Wednesday, 21 December 2016

Bitty Software and Preparing Youngsters for the Age of the IoT

Bitty Software is the name I use for my micro:bit smartphone/tablet applications project. At the time of writing, there are 5 Bitty Software applications for each of iOS and Android in their respective app stores. In each case, micro:bit coding tutorials are available, the idea being that to use the smartphone applications, you have to program your micro:bit. For those who don't want to, or who are simply too impatient to get started, pre-built hex files are also available.

The idea behind Bitty Software was to create resources for education and fun which shine a light on communications technology and the micro:bit rather than just on coding. Bluetooth is of course my communications technology of choice.

Why emphasise communications? Well, given one of the primary goals of the micro:bit project is to educate youngsters in coding and making things and to prepare them for potentially becoming the next generation of technology entrepreneurs and leaders (or simply to make a living from their technical skills), communication between devices is an essential thing to know about, and here's why.

Goldman Sachs released a report in 2014 which discussed the Internet of Things (IoT). In that report, they characterised the internet as evolving through three major phases.

1. The 1990s. 1 billion devices are connected to the internet. These are largely desktop computers and servers. People use modems that make a quaint bleeping sound.

2. The 2000s. 2 billion devices are connected to the internet. This is the age of the smartphone.

3. The year 2020. It's forecast that by 2020 there will be <drum roll> 28 billion devices connected to the internet. This is a phenomenal figure. And those devices? Computers, smartphone and tablets. Obviously. But also light bulbs, manufacturing equipment, sensors of every conceivable type and much more besides.

The IoT is why youngsters need to be educated in communications as well as coding. At the "edge tier" of any IoT architecture, you'll generally find smaller devices, often equipped with microcontroller units (MCUs). The BBC micro:bit is an MCU. And they will very typically communicate wirelessly with each other and with the internet via entities known as "gateways".

There are various wireless technologies. Some of them are categorised as "low power wireless technologies" meaning that they use relatively small amounts of power to communicate data. Bluetooth low energy is one example and this is the Bluetooth technology on the micro:bit. Low power use is critical in many IoT scenarios. Consider a smart building. It can only be "smart" in any meaningful sense of the word if we have lots of data about its various aspects and from every nook and cranny of the building, let alone every room; temperature, light levels, water levels, security status of windows and doors, occupancy of rooms and so on. Data can be accrued, aggregated and analysed. It can form the basis of intelligent automation and reveal hitherto unknown things about the building (is this building energy efficient compared to other, similar buildings?) but this can only be achieved with the right type and quantity of data, acquired at the right time.

To obtain this magical data requires sensors. Lots of sensors. Everywhere. Placing sensors in wall spaces, attics and under the ground becomes untenable if they need their batteries changing every few weeks. Devices have to run for many years on a single battery or better still, require so little power that energy harvesting techniques which generate power from ambient light, temperature changes, mechanical vibration or naturally occurring radio in the environment, can be used instead of batteries.

Its ubiquity (over 3 billion Bluetooth devices shipped in 2015 alone), wide platform support, developer friendliness and very low power requirements have made Bluetooth the low power communications technology of choice for the IoT.

So those youngsters we have such high hopes for, they need to be immersed in communications as well as coding and learn about creating systems of devices, not just creating the code for one device.

Bitty Software and Bluetooth. Doing their bit. OK, I nearly finished on a pun there!

Wednesday, 16 November 2016

micro:bit support

The 'micro:bit foundation' has arrived and is charged with looking after the future of the micro:bit. It's also a great place to go for technical support. We've lacked a central place to find answers to questions or to get assistance until now, so this is a big step forwards.

Here are some handy support resources for you:

1. If you need help with a Bitty Software application or tutorial

Send a message to @bittysoftware on Twitter. If you can, post more extensive details on a blog or similar and include a link to these details in your tweet.

2. Anything else micro:bit related

Email or go to and open a support ticket.

That's it!

Tuesday, 15 November 2016

micro:bit Blue - open source at last!

Most of the micro:bit demos involving a smartphone shown on my micro:bit page involve an Android application I wrote and which I eventually decided to call "micro:bit Blue". It was initially put together to help me to test the Bluetooth profile I'd designed for the micro:bit. Then, as I started to have ideas, it transformed into a series of demos.

But I always had the aim that it be released as open source, so I also did my best to provide educational documentation in the helps screens so that people who are new to Bluetooth could get the hang of the primary concepts.

A few months ago I loaded the application into Google Play so that other people could find and install it easily.

 It's right here:

Meanwhile, releasing the source code was delayed by a variety of rather uninteresting issues. And then some more. To cut a long story short and at the same time apologise for having taken so long over this, today I'm delighted to say that the source code is now available!

The new microbit foundation have kindly offered a home for the code and their home being more palatial than my own github home, I gratefully accepted their offer.

I hope those people who have been waiting for this are pleased and that everyone and anyone with an interest in writing smartphone apps for the micro:bit finds this useful.

Here it is:

 Enjoy :-)