Saturday, 23 December 2017

Debugging micro:bit code using the serial port and USB

Debugging micro:bit code can be tricky. It can only display one character at a time so the LED display is not a great option, though you'll be surprised how much you can still get done when you need to.

You can write full strings and variable values to the serial port however and so by connecting your micro:bit into a computer using a USB cable and firing up a terminal application like Putty, you can monitor serial output as your micro:bit code executes.

This is a great way to get to the bottom of weird code problems you just can't figure out!

Here's how you'd do this from C/C++

uBit.serial.printf("P0:%d P1:%d P8:%d P12:%d\r\n", pin0, pin1, pin8, pin12);

Friday, 15 December 2017

4tronix Bit:Bot and Bitty Controller

New hex files have been published at which allow Bitty Controller to be used with the 4tronix Bit:Bot

Note that a new version of Bitty Controller is in development and this will provide data from the Bit:Bot sensors as well as allowing it to be driven. But there's no need to wait because both the existing d-pad and touchpad controllers in Bitty Controller work today as long as you install the right hex file on your Bit:Bot mounted micro:bit!

Provisioning a Silicon Labs Bluetooth mesh developer board

Provisioning is the process which makes a Bluetooth mesh device a secure member of a specific mesh network. It involves a smart phone or tablet, running an application known as the Provisioner and results in the Bluetooth device being issued with a series of security keys. Conceptually it's comparable with Bluetooth pairing but technically is not the same and is concerned with the security of a whole network, not just the security of a pair of devices.

For a more technical explanation of Bluetooth mesh, download the Bluetooth Mesh Technology Overview document from

There are also numerous blog posts on various aspects of the topic:

Here's a quick demo of me provisioning a Silicon Labs Blue Gecko developer  board which is running a Bluetooth mesh stack with software models that make it equivalent to a mesh light.

Thursday, 14 December 2017

Remote control your smartphone camera with a micro:bit

Using your micro:bit as a remote control for the camera on your smartphone is easy.

I wrote a quick MakeCode application which lets you take a photo by pressing button A on the micro:bit and have shared it at this URL: 

The "Tell camera" block is in a special package called Devices. You need to add it to your MakeCode project. You do this by going into the Advanced section at the bottom of the list of block categories on the left, click Advanced, then Add Package and then select Devices. When it asks if you should remove the Radio package,confirm that it should.

The procedure you should then follow with an Android phone is this:

1. Download the hex file from MakeCode and copy it to a micro:bit. I used USB for this. 

2. In Android, go into Settings/Bluetooth and if the micro:bit is listed as paired, "Forget" it. You need to forget pairing every time you flash a hex file as the pairing details get deleted from the micro:bit, leaving the phone thinking it's paired and the micro:bit thinking it is not. They both need to think they are paired or they both need to think they are not paired otherwise Bluetooth communication will fail, with one side trying to perform encrypted communication and the other having no idea what's being said to it!

3. Launch the official Samsung micro:bit app. Select Connect and then PAIR A NEW MICRO:BIT.

4. Put your micro:bit into pairing mode using by holding A+B and pressing and releasing the reset button, all the time keeping A+B pressed. When "PAIRING MODE" appears, you can release A+B.

5. Complete pairing, following the instructions on the smartphone app.

6. Press reset to restart the micro:bit with the new code. You should briefly see a smiley icon appear and then vanish.

7. Now in the Connect screen, connect to the micro:bit you just paired (select it in the "Connect to previously paired micro:bit" section. After a short delay you should see "C" on the micro:bit. This means a Bluetooth connection was established.

8. Now press button A. This should cause your phone to open the camera app, count down 6 seconds and then take a photo.

Have fun.