1 Reply Latest reply on Nov 8, 2018 11:32 AM by neilk

    HowTo:  Connect a phone or tablet to the BBC micro:bit


      This posting may become a work-in-progress with the possibility of updates as I go along.


      One of the really NICE things about the micro:bit is that it is a really-and-truly "shirt-pocket" system,  If you get the tiny power-board add-on with the 3v button cell, you can have the entire working thing in your pocket.  Pairing the micro:bit with a tablet and/or smartphone gives you the opportunity to have a truly portable development environment without having to lug a huge system around with you.


      There are two possibilities here:

      1. Using Bluetooth.
      2. Using the micro:bit's USB port via OTG. ("unofficial" beta)



      Using Bluetooth:

      Just about everything under the sun nowadays supports Bluetooth to one extent or another and the micro:bit is no exception.  So much so that Samsung has developed a micro:bit app for Android.  Using this, you can create software and write it to the micro:bit for testing.  There is, however, one teeny-tiny fly in that ointment.  It only works ONCE.  After you've flashed over your first program, you cannot do it again.


      Why?  Because "Bluetooth" is not the default communications protocol for the micro:bit, "radio", (a proprietary packet-radio protocol), is the default and it displaces Bluetooth.  The result of this is that, (usually), you can flash the micro:bit once and once only.  This is why the Samsung app has so many negative reviews.  Additionally, MicroPython completely removes Bluetooth capabilities - including the base-level pairing functionality - as there isn't enough room.  With respect to MicroPython, part of the workaround is to use a web editor and flash something, which re-enables Bluetooth pairing.



      Neil Kenyon wrote a really excellent article on how to re-establish Bluetooth communication with a micro:bit.  His "Correct Answer" gives a list of steps to follow that will allow you to re-flash your micro:bit after flashing it the first time.  I have not yet tried it but, based on what I know about it and what I've read, these steps sound spot on.  They've also received a LOT of excellent feedback, so I'd go try that.  In fact, as soon as I finish writing this, I'll go try it myself.



      Using the micro:bit's USB port:

      Since the micro:bit has a USB port and since the USB port is the primary programming interface for the micro:bit, it makes sense to plug your micro:bit into your device's USB port using an easily obtained OTG connector.


      OTG?  Yep.  Stands for "On The Go" and is an implementation of a new USB standards extension that allows devices like phones and tablets to act as "computers" instead of "devices".  The idea is that instead of plugging your phone or tablet into your computer, you can plug things into the phone or tablet as if it was the computer itself.  Which is handy.  A tablet with a wired, (or wireless), mouse/keyboard can be really convenient as a portable workstation.


      Unfortunately, like Bluetooth, it's not as easy as it sounds.  Why not?  Simple.  The current release firmware from Mbed/micro:bit does NOT implement OTG master-device functionality.



      "Update" the firmware to a beta version that has a patch that enables OTG functionality.  It can be found on GitHub here:

      This is a 7z (7-zip) archive file that contains one binary file that can be flashed in maintenance mode. (See: How to upgrade the firmware on the micro:bit)  The discussion talks about HEX files, but binary files can be flashed too.


      Note:  This is "unreleased" experimental firmware that has been patched to enable OTG and shows as version 0246.  (The latest release is 0250)  You are welcome to use it, however do not update to this firmware version unless:

      1. You have a particular and specific need for the OTG functionality.
      2. You are interested in providing beta test feedback to the Micro:bit Foundation.


      Reason #2 is probably one of the best reasons.  Providing the people at the Micro:bit Foundation with feedback on how well the OTG patch works on various phones and devices is crucial information that may well speed implementation of the OTG patch into the main firmware branch.



      Other possibilities:  (For experienced users only!)

      There are two other emerging possibilities:

      1. WebUSB  (Highly experimental)
      2. Web Bluetooth  (Still in development)


      Note that these are emerging technologies and are strictly experimental in nature.  Because of this, you can, and should, expect there to be issues with them.  Handle with care!


      WebUSB is an emerging technology that the micro:bit Foundation is encouraging people to test.  Information can be found here: Beta testing - Web USB

      Note:  This is highly experimental and - due to recently discovered security concerns - may not even work.  Google is actively addressing these concerns and they may be solved by the time you read this.


      Web Bluetooth is a very new technology that has attributes similar to WebUSB - and similar security concerns.  I first heard about it in an e-mail from the Micro:bit Educational Foundation, but have not found anything else about it, not even a beta program yet.  I suspect that it is still in development as I have seen several Github projects involving Web Bluetooth.



      Let me know what you find out.


      Jim "JR"