Category Archives: Uncategorised

BBC Microbit with MicroPython

If you haven’t read my initial first impressions of the Microbit blog post, I would suggest have a glance over it first.

This blog post is still a work in progress.

A few months back, I got the opportunity to sit in a meeting with Nicholas Tollervey while at Raspberry Pi on internship. He had with him an item,  rarer at the time than gold dust, an early prototype of a BBC Microbit and he was very excited!
Around then, Damien George (lead developer of MicroPython) had just got a very rough build of MicroPython running on the Microbit.
Nicholas just had a very rough prototype with him which you simple got a REPL (Read Eval Print Loop, type command in, instantly get result) over a serial connection to the Microbit. But, it was enough to get us all very excited!

Since then, the project as a whole has come a huge way including the development of the excellent Mu editor and overall is now generally very stable with an excellent set of documentation.

So why is this exciting?

Although the other platforms built for kids to write code with for the Microbit are great, Python has the massive advantage that kids already learning it.
Python is by far the most popular programming language for schools today. The Microbit will work as a great inroad for schools wanting to teach new students a fun introduction to Python.
For those schools already teaching it Python, those students can go even further using some of the more advanced features and libraries!

Writing your Python code with Mu

Mu editor with the same shake program, written in Python using MicroPython.
Mu editor with the same shake program, written in Python using MicroPython.

One of the extremely exciting additions recently has been the launch of the Mu editor.

Mu is an extremely simple Python editor that has similar features to IDLE, but is far easier to use. It uses the QT platform, allowing single file executables for Windows, Mac and Linux to be built. They just work which is wonderful.
The editor allows you write your Python code, then simply hit the flash button to flash it onto your plugged in Microbit. That is it, no need to download a .hex file and copy it over manually, Mu takes care of it all.

A key feature though of Mu is it is 100% offline. No web access is required which is a very nice feature that I am sure many schools will appreciate. Although it doesn’t include an emulator like the other 3 web based editors, it doesn’t really need it given you can just hit flash and it is on your Microbit, simple.

On top of this, it also includes support for the REPL built in. The REPL commandline can be opened with a single click. This allows you to see any outputs in your script (done with print()) and even get user input using input().
I really love this given it lets you experiment and try stuff out, before writing your main program.

Along with writing your programs in the main editor then flashing them to the Microbit, you can also try out stuff using the REPL.
Along with writing your programs in the main editor then flashing them to the Microbit, you can also try out stuff using the REPL.

Using Mu in schools

Mu is a really cool tool, but I have been getting questions from a stack of teachers about using it in school on locked down school computers.


If you have Windows computers, you can grab Mu (a single .exe file, no installation needed) from the Github page (or a direct link to the downloads page).

If you want to be able to use the REPL (highly recommended) you will also need to download and install mbed driver.
It is well worth it, although you are able to do it without it. You just won’t have access to the REPL.

Mac / Linux

On Mac OS and Linux, you can download the single executable applications from the Github page (or a direct link to the downloads page for Mac OS and Linux).
There is no mbed driver needed for Mac OS/Linux as it is built in, it is built in so you can use the REPL straight away!

Raspberry Pi

There are specific versions of Mu for the Raspberry Pi! So if you want to use the Microbit with a Pi, you will soon be able to simply type “sudo apt-get install mu”, although unfortunately that isn’t ready just yet. The direct link to the Raspberry Pi versions can be found here.
There is no mbed driver needed for Raspberry Pi Linux, it is built in so you can use the REPL straight away!

External hardware

You can do some pretty cool things with MicroPython and the BBC Microbit by connecting other hardware to it.


Everyone loves flashy multicoloured LEDs, right? Well the Microbit can drive a stack of them. In our tests, it can drive at least 256 pixels at one time! I have been working on testing the module and also writing documentation for it.

You can check out the Neopixel module documentation here.


By attaching a simple buzzer to your Microbit, you can get it to play music. In the case below, Amy Mather also made use of Makey Makey style resistive touch to create a music keyboard!

You can check out the music module documentation here.

SPI/I2C modules

Unlike the other programming environments, MicroPython allows more advanced students or developers to interact with additional sensors/modules using the I2C/SPI interface libraries.

This opens up use possibilities for connecting additional modules to the Microbit. For example, you could connect an SPI LCD, an OC2 pressure sensor or even an SPI GSM modem to send text messages from your Microbit!
Is worth keeping in mind, although you could do all this, it isn’t as simple as importing a module. It will require a little work (and datasheet reading), but the important bit is people have the tools to do it.

Other peoples projects

Nicholas has also been making a few videos to demo some new Micropython features.

To conclude

I am extremely excited for MicroPython and Mu. Although there is going to be a simple web based MicroPython editor coming soon, I think many schools will want to use Mu instead given it can be run completely offline and includes awesome extra features like the REPL.

Although the other programming environments are excellent, and I take my hat off to their development teams as they have done a really great job. I still think MicroPython is the one everyone should be keeping an eye on. It has huge potential to be grabbed by students and allow them the true freedom to run with their ideas while learning a useful language at the same time!

BBC Microbit – First impressions

For the past few weeks, I have been playing with a developer version of the BBC’s new Microbit device. Below are my first impressions of the hardware and software.

The second part of this series, focusing on MicroPython on Microbit can be found here.

The what?

The BBC Microbit is a tiny circuit board with an onboard Arduino-like microprocessor and a number of sensors built in along with a 5×5 red LED matrix..
Every year 7 (year 8 in Northern Ireland) student across the UK will be receiving one for free as part of the BBC’s Make It Digital programme. Right now, the current expected rollout is that teachers will receive devices late February 2016 while students will receive theirs a few months later.

The Microbit circuit board includes

  • A 5×5 red LED matrix
  • 2 buttons (and another reset button on the back)
  • A compass and accelerometer
  • An edge connector with 22 pins (16 of which are usable GPIO pins)
  • Micro USB port for programming/power
  • 2 pin JST port for powering from 3V battery (x2 AAA batteries for example)
The front of the Microbit has its 5x5 red LED matrix, 2 buttons and a marked edge connector.
The front of the Microbit has its 5×5 red LED matrix, 2 buttons and a marked edge connector.


Hardware like this though is no use without a way to program it.

There are currently 4 different ways to write code for the Microbit, 3 of which are right now, entirely web based.

  1. Microsoft Touch Develop (online)
  2. Microsoft Block Editor (online)
  3. Code Kingdoms Javascript editor (online)
  4. MicroPython (online soon and offline)

The first thing worth pointing out is there is currently 2 ways to actually load your programs onto your Microbit.

  1. If using a computer with a USB port, download a .hex file and copy the file onto the “MICROBIT” flash drive that appears when you plug the device in (so no special drivers needed).
  2. If using a tablet or phone (iOS or Android is fine), you will be able to download your programs over bluetooth to the Microbit. I have seen a working demo of this at BETT 2016 for Android, although as of yet have not seen anything working with iOS.

All the programming environment are listed here.

Microsoft TouchDevelop

A simple script to show a smiley face when shaken.
A simple script to show a smiley face when shaken for 1 second.

The first is Microsoft TouchDevelop. A project initially born out of Microsoft Research, TouchDevelop is an interesting environment for writing code, without actually needing a keyboard… It is very weird coming from a Scratch and Python standpoint, but I do understand where it is coming from. It is a perfect environment for using with touch based devices and works out of the box with Android and iOS web browsers.

Its interface is rather intuitive and for beginners, I think it will work great. You can run your code once you are ready on the virtual Microbit simulator to the right, or hit compile to download the .hex program file.

Microsoft Block Editor

Same script as above, in Microsoft Block Editor.
Same script as above, in Microsoft Block Editor.

Microsoft Block Editor (based on Google Blockly) is more Scratch-like environment for building programs. It is based on Blockly (same as App Inventor). Students and teachers familiar with MIT Scratch or App Inventor will feel at home using the block editor.

To use it, you grab blocks from the menu on the left hand side of the screen and drag them onto the programming space.

The Block Editor works fine on a touch device, but is best suited to computer with a keyboard and mouse. It again also has the same simulator as Touch Develop to the right.

Out of the 3 web based editors available right now it is my favourite.

Code Kingdoms Javascript Editor

Same program, this time in the Code Kingdoms Javascript editor. Using full block/icon mode.
Same program, this time in the Code Kingdoms Javascript editor. Using full block/icon mode.

Not having ever really used Javascript, I was not really sure what to expect when trying the Code Kingdoms Javascript Editor. I will admit, I was certainly through pleasantly surprised.

Like Microsoft Block Editor, your available code blocks are down the left hand side, but unlike the other 2 web editors, you can switch between blocks and icons, right down to the raw Javascript itself if you want. This can be done using the slider at the bottom of the page and allows the more proficient programmer kids to go on ahead and write the text based code, while the students just starting out can stick to the blocks/icons mode.

By using the slider at the bottom, you can switch over to the raw Javascript code view.
By using the slider at the bottom, you can switch over to the raw Javascript code view.

Overall, it is a very nice and intuitive editor and a bit of a mixture between the block based system used in Microsoft Block Editor and the more code based approach of Microsoft Touch Develop.

MicroPython (with Mu)

Mu editor with the same shake program, written in Python using MicroPython.
Mu editor with the same shake program, written in Python using MicroPython.

The final platform built for students to use with the Microbit is MicroPython and the Mu editor.
(It is worth pointing out here I am only looking at Mu, the offline editor for MicroPython. An online editor is coming but isn’t ready just yet)

Python is arguably now the most popular text based programming language used in schools with students. It is an extremely versatile language and has an easy to pick up, human readable focus on it.

MicroPython is an implementation of Python based off Python 3 for microcontrollers and devices with limited resources. This makes it a perfect candidate for use with the Microbit.

As part of bringing MicroPython to the Microbit, one of the developers decided to go ahead and build a beautiful offline environment to write your Python in. This editor is called Mu and can be grabbed from its Github repository. I am extremely impressed with Mu and MicroPython in general. It really opens up the possibilities of students doing some proper crazy stuff in a language they may have already had experience with. I am doing a separate post on Mu and MicroPython with more detail on the project as I have been most involved with it.

I think the biggest fundamental feature MicroPython on the Microbit has over the other platforms is it provides (if you install the driver on Windows, is included on Mac and Linux) a full console, or REPL. This allows you to simply type Python commands straight in and see the results. It also allows scripts to print data back to the serial console. It is worth pointing out though, Mu does not include any Microbit simulator like the other 3 platforms.


Edge connector


The Microbit features a large golden edge connector at the bottom. This edge connect brings out a number of GPIO pins from the microprocessor. 5 of these pins are large pads, designed to be used with crocodile clips. These 5 pins include 3 GPIO pins, 3V and ground. The 3 GPIO pins include Makey Makey style resistive touch which is a nice addition.

Although it looks like plenty of pins to work with, be warned that many of them have additional functions, whether that be driving the LED matrix, buttons or the I2C interface. Unfortunately because of this, instead of 22 GPIO pins, you actually really only have 9 pins you can use without interfering with other parts.

Of the 9 GPIO pins brought out with no additional features, 3 (0, 1, 2) can be used as analog sensor inputs while all can be used with PWM.

Other interfaces available on the edge connector includes I2C (pin 19 and 20) and SPI (pin 13, 14, 15). It is also possible to redirect UART serial out to any 2 pins, but in doing that you loose the REPL over USB. Right now, only MicroPython supports working low level with these interfaces.

Kitronik edge connector breakout board.
Kitronik edge connector breakout board.

To make use of all but the 5 touch pads, you will need to get yourself a breakout board. Kitronik do an excellent (and pretty cheap) one over on their site which is available in assembled or unassembled form. They also have a rather nice assembled motor driver board available.
I am sure more companies with bring out similar boards when the Microbit is officially launched and publicly available.

Microbit vs Raspberry Pi


This is a question I have had a lot when chatting to people about the Microbit, especially teachers.

“What is the difference between the Microbit and the Raspberry Pi?”

The simple answer is they are completely different kettles of fish!
Here is why:

  • The Raspberry Pi is a full computer that you can plug a keyboard, mouse and screen into. The Microbit is not, it needs another computer to program it. Interestingly you can use a Raspberry Pi to program a Microbit!
  • The Microbit has an acceleromenter and compress built in, along with 2 buttons and a 5×5 LED matrix. The Raspberry Pi does not include anything like that out of the box, you have to purchase an addon board (HAT) or other modules and plug them in.
  • The Raspberry Pi can be programmed in many many more programming languages and platforms, hundreds even given it runs Linux. The Microbit can only be programmed in 4 or 5 languages.
  • The Microbit is very low power, using less than a 5th of the power of the Raspberry Pi.
  • The Microbit has GPIO pins like the Raspberry Pi, but only has 9 usable free ones, vs the Raspberry Pis 26 free GPIO pins.
  • Both support expansion interfaces like SPI and I2C, but the Raspberry Pi has libraries for many addon boards already, where as the Microbit doesn’t just yet.
  • The Raspberry Pi is much more powerful, the processor is 50-60 times as powerful and has 64,000 times as much RAM(16kb vs 1024mb)!

So the main difference is the Raspberry Pi is a full blown Linux computer, where as the Microbit has a simple little microprocessor which runs a single program and that is it. They can’t really be properly compared, but can be used alongside each other. The Microbit is a great starting point after which, a Raspberry Pi makes perfect sense to progress to.

It is pretty cool though that you can use the Raspberry Pi to program the Microbit. Using MicroPython, you can even use it as an “external sensor” for the Raspberry Pi. You could for example use it as a game controller for your game on the Raspberry Pi! Will be very exciting to see what people do with the Raspberry Pi and Microbit combined!

So what have I been doing with it?

I have been spending a majority of my time with the Microbit using MicroPython and in turn, breaking MicroPython!
Because the MicroPython environment is open source and on Github, it is really easy to open new issues for ideas for features or to contribute to documentation.

I have been fiddling about with a few of the less mainstream features including the new Neopixel library and playing with Touch support. I have gone into more detail about this in my MicroPython blogpost.

A few of my projects have involved a crazy mish-mash of wiring.
A few of my projects have involved a crazy mish-mash of wiring.

To conclude

I think there is a lot of potential for the Microbit. Sure a decent chunk will end up in drawers, on shelves or even on Ebay. But, those that don’t, those that get picked up by students with teachers that understand how to use them… Those it could really make a big difference with.

Will it inspire and create the next generation of computer scientists?
I am going to reserve taking a side till I can get a set and use it with a class of kids, but I can say with complete certainty,  it will certainly inspire thousands of students across the UK to give Computer Science a go.
And who knows, maybe some of them will go on to create tomorrows “next big thing” because chances are, it will involve computers.

The second part of this series, focusing on MicroPython on Microbit can be found here.

Where can I get more information?

Raspberry Pi Zero – Programming over USB! (Part 1)

Part 2 to this post can be found here.

Update 19/05/2016 – The modules are now included in the most recent version of Raspbian and thanks to some digging around in kernel documentation, it is now possible to set the full thing up without a keyboard/mouse/screen! Just need a Windows/Mac/Linux computer!

Update 15/01/2016 – The modules have now been merged into the Raspberry Pi Foundation maintained kernels! So no more need for custom kernels, just need to grab the most recent alpha kernels. Doing this is now far simpler.

Full credit for the initial documentation for this goes to a number of Pi experts from the Raspberry Pi community, see here and here.

An acknowledgement also to Lady Ada of Adafruit who was working on documenting in parallel to myself on Christmas eve. She has taken a different approach which requires a UART serial cable. Her guide can be found here.

What is this?

The Raspberry Pi Zero is a very cool little computer. At £4, is pretty amazing for the price. But one thing many Pi users have wanted to be able to do for a long time is program their Raspberry Pi from another computer, using only a single USB cable!

The Raspberry Pi Zero is able to do this, hardware wise anyway, although a lack of software support was holding up it ever happening. Until now!

So what can it do?

Using the Linux USB Gadget modules, we can get the Pi Zero to emulate a whole host of USB devices including

  • Virtual Serial – So can get a serial connection into the Pi, similar to using the UART pins. You can use Putty (on Windows) or Screen (on Mac and Linux).
  • Virtual Ethernet – You can get your Pi Zero to appear as a USB Ethernet modem. With a little configuration, you can then get full SSH, VNC, FTP etc.
  • Mass storage device – You can get the Pi Zero to appear as a flash drive, allowing you to for example, copy files over and have the Pi run these files (useful for robotics for example)
  • Virtual MIDI – The Pi Zero could appear as a virtual MIDI instrument.
  • Virtual Audio – The Pi Zero could appear as a virtual headphone output or microphone input.
  • Virtual Human Interface Device (HID) – The Pi Zero could appear as a virtual HID, for example a keyboard or mouse. So when you plug it into your computer, it could start typing!

You can also combine a few of the above (up to 3 at a time) using the g_multi module, although Windows and Mac have difficulty handling it then.


Where is this useful? Lets take an example of some Raspberry Pi robots in a classroom. Although you could be using Wifi for each robot, remembering addresses, unreliability with wifi etc all make wifi a bit of a rubbish answer.
With this, the student simply plugs in the robot and perhaps drops their script onto the flash drive that appears. When they unplug it, the robot runs the script, dumping the results of the script back onto the mass storage device, ready to be read when it is plugged in next.

Another example, lets say you don’t have access to a screen to use with your Raspberry Pi Zero, in for example, a school. You could still let your students play with GPIO or Linux by simply using the serial module (with Putty or Screen), or the virtual ethernet module to allow them SSH access.

How to I set it up on my Raspberry Pi?

I have thrown together a guide over on Github Gists, including links to the downloadable precompiled kernels.

Destination space at W5

On Tuesday 15th December 2015, Tim Peake, the first British ESA astronaut, launched on a Soyuz rocket from Baikonur Cosmodrome.

To celebrate this, a number of Destination Space public events were being held across the UK with one at W5 in Belfast.
Myself and some of the Northern Ireland Raspberry Jam team went along and with us, brought 10 Raspberry Pis, some Sense HATs and a stack of Raspberry Pi DOTS Boards.

Rocket dots

Our most popular activity we were running on the day was as usual, the DOTS boards. For the launch, I hastily added a new Easter Egg to the RPi-dots-minecraft program, a rocket simulation!

To enable the secret mode, you simply don’t draw the wings on the plane, causing your drawing to look like a rocket!

Lots and lots of rockets filled in by schoolkids!
Lots and lots of rockets filled in by schoolkids!
Lots of schoolkids busy drawing their customised rockets!
Lots of schoolkids busy drawing their customised rockets!

The activity was extremely popular with over 200+ students giving it a go.

We even had a real ESA astronaut, Jean-Francois Clervoy try out the activity!
We even had a real ESA astronaut, Jean-Francois Clervoy try out the activity!

Sense HAT activity

We also brought along a set of Sense HATs and set them up with the excellent Raspberry Pi Foundation Sense HAT pixel art activity.

Although not as popular as the DOTS boards, Dean and Art were certainly kept busy helping stacks of kids create some awesome pixel art using Python!

Of course, there were a number of creepers created.
Of course, there were a number of creepers created.


Big thanks to the wonderful team of Northern Ireland Raspberry Jam volunteers who were able to make it down for the day and for W5 for having us. We all had a great day!

NI Raspberry Jam team at Destination Space. From left to right. Vincent Lee, Andrew Mulholland (myself), Dean Welch, Artemiy Knipe, Sam Stuart.
NI Raspberry Jam team at Destination Space.
From left to right.
Vincent Lee, Andrew Mulholland (myself), Dean Welch, Artemiy Knipe, Sam Stuart.