Friday, 27 May 2016

Programming the BBC micro:bit directly from your phone

One of the things I love about the BBC micro:bit is that with great development tools from Microsoft, the Samsung micro:bit Android application and a little help from Bluetooth, you can program your micro:bit right from your phone or tablet with no PC or laptop needed at any stage.

My latest micro:bit video shows me creating code which turns my micro:bit into a Bluetooth remote control with which to control the music player on my Android phone.

Saturday, 7 May 2016

Using ARM mbed to create Bluetooth enabled micro:bit applications

The code editors available at at best give you only very limited access to the extensive Bluetooth capabilties of the BBC micro:bit based on predefined use cases like starting a song on your smartphone (provided you're running the Samsung companion application for micro:bit). Python on micro:bit has no access to Bluetooth at all. So how do you get the most out of Bluetooth on micro:bit? The answer is to use ARM's mbed system, either the online version via or the offline variety called Yotta.

My latest video talks about the Bluetooth capabilities of the micro:bit, shows you how to use ARM mbed to use them, explains the potential issues and how to work around them.

Thursday, 5 May 2016

Bluetooth advertising and micro:bit

The BBC micro:bit has a special "pairing mode" which it needs to be in for you to be able to pair it with another device such as your smartphone. When not in pairing mode it's in... well let's call it "normal mode". I published a video showing how to pair with your micro:bit some time ago.

When a micro:bit is not in a Bluetooth connection with another device it will be broadcasting small packets of data over Bluetooth called "advertising packets" (provided it has been paired with at least one device at some point - if you've not yet paired your micro:bit with anything it will not be advertising when in "normal mode").

Advertising is the Bluetooth mechanism which allows other devices like a smartphone to discover your micro:bit.

There are important differences between the advertising (ADV) packets which are broadcast when in pairing mode vs those which are broadcast when in normal mode however and this may have an impact on how the Bluetooth settings screen of your smartphone or tablet behaves.

Here's an ADV packet from when my micro:bit was in pairing mode:

The LE General Discoverable Mode flag is set and this means other devices can regard the micro:bit as willing to be discovered. This is not a security mechanism by the way, it's an expression of intent of sorts.

When a previously paired micro:bit is in normal mode however, the ADV flags look like this:

Neither of the discoverable mode flags are set and the micro:bit is said to be "non-discoverable". It's there of course and it's advertising. Other devices can see those advertising packets as plain as day but they're being politely asked to pretend they can't see it. In practice what this means is that if you've not paired your micro:bit with your smartphone it may not be listed in the smartphone's Bluetooth settings screen under "Available devices". Here's a screen shot from my Nexus 9 tablet which I have *not* paired with my micro:bit which is currently on and advertising:

My micro:bit is not listed despite the fact that it is in range and is advertising because this device has not paired with it and the advertising packets are indicating that the micro:bit does not want to be discovered by random devices it has never been introduced formally to.

On the other hand. my Nexus 5 smartphone has been paired with the micro:bit and so it is listed in the Bluetooth settings screen.

The moral to this story? If you can't see your micro:bit listed on your phone's Bluetooth settings screen and you think it should be, check the description of micro:bit's expected advertising behaviour that I've given here. Hopefully all you need to do is pair your micro:bit.