Tag Archives: computer science

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!

Minecraft coding in the classroom – 1st draft

Today’s post sways a little off the normal Raspberry Pi stuff, there is a link though!


One of the awesomest pieces of software the Raspberry Pi has for teaching in Minecraft Pi edition Link . If you don’t have it on your Raspberry Pi, why not?! It is great as kids can easily program modifications to the game in python allowing them to place blocks, move players and do all kinds of cool stuff. There is a problem for it though in education, not every school has a classroom of Raspberry Pis…

Fret not though, a Bukkit developer has gone and made a Bukkit plugin to emulate the API but for the normal version of minecraft.

We will start though from the start. What is minecraft?

Minecraft is a sandbox! It is a game played by millions of people across the world. It is very popular with teenagers especially. The game has a massive community behind it and is easily modifiable with the use of Java.

Modifying the game though brings with it a number of problems including modifications not playing nice with each other. To make it easier to mod the game and to help mods play nice together, a number of community projects emerged making their own APIs. The 2 most popular of these are Bukkit and Minecraft Forge. Both are not run by Mojang (Minecraft developers) and are maintained as opensource projects through donations.

Bukkit is an stable and the standard server platform for 90% of Minecraft servers out there. It has an easy to use API and a massive collection of plugins allowing you to manage players on a server and keep order. There are also a number of specialist plugins, we will be looking later at one called RaspberryJuice. Bukkit is a server only platform, it can not modify the actual client (aka add more buttons, new blocks or new menus).

Minecraft forge, the other major platform, allows direct modification to the client. This allows you to do things like add new menus, buttons, blocks. MinecraftEDU is designed for Minecraft forge. It has a very powerful API that allows you to change most of Minecraft.

 Minecraft Pi edition

Minecraft Pi edition is a special version of minecraft developed for the Raspberry Pi which is based off another branch of minecraft, Pocket edition (designed for mobile devices). It has only the basic features of minecraft but can easily run on the Raspberry Pi.The important bit though about minecraft Pi edition is it has its own simple to use API for interacting with the world! You can tp players, break or place blocks etc in languages like python, java, javascript etc.

This API is great for the classroom and at home but it has an issue. What if you don’t have a Raspberry Pi? A lot of schools dont yet have a full classroom yet of Raspberry Pis but have a fully kitted out ICT suit with much more powerful computers than the Raspberry Pi. What about this API for normal PCs? A developer has gone and created just that! An easy to use plugin called RaspberryJuice has been released that allows players to use exactly the same API but using normal Minecraft.

Each student must be running a mini server though to use this seeing as it requires bukkit, this allows teaching simple commandline based server applications too.

By using Bukkit, you also have access to 1000s of plugins that allow you to customize the entire experience. For the plugins check out their database http://plugins.bukkit.org/

Lets set up a server

First you will need a minecraft account (€19), it is likely most students will have one. MinecraftEdu offer discounts to schools and can get them as low as €10. You only need 1 set of accounts per classroom (and if they arent connecting to the same server, 1 set per school).

Next you need to set up the clients, it is a very easy process. Make sure java is installed (most machines it is), download client from Here and you are good to go.

If you are using RaspberryJuice each client also needs a mini server running in the background. The basic idea is they run their own mini preconfigured server then they just connect to localhost (aka, themselves). Using this method also allows students to connect to each others servers if they know their IP addresses.

You need to create a folder with the server stuff in it. I will be demoing this on a mac, but it will work also on windows and linux.

Make a new folder for your server and grab the latest beta build of bukkit (It is also known as craftbukkit) from dl.bukkit.org .

Bukkit has 3 standard release channels, unstable (daily releases, dont use), beta (a tested build that most things should work for, these are fine) and a recommended build (these are the most stable, there are very few of these).

Minecraft is constantly being upgraded with new features, a new update comes out on average every 1.5-2 months and will be heavily publicized before its release. Best place to hear about new versions is https://mojang.com/. They also do snapshots which are unstable test versions normally released once a week. These are minecraft versions, not bukkit. Minecraft follows a numbering system that increments .1 every major release and .0.1 for bug fixes, for example as of writing, the current version is 1.6.2. 1.6 is the main version number and there has been 2 bug fix updates. Remember, these are different from bukkit releases. Bukkit releases can take 1-2 weeks after a major update and 2-3 days after a bug fix update. When a new version comes out, you dont need to update, it is normally smarter not to until everything settles down.

When configuring the clients, it is important to go into edit profile and change the dropdown menu from latest version to the current version, this way the clients wont auto update. See the picture belowVersion

So, now you have bukkit (also known as craftbukkit), place it in your server folder you created and rename it to craftbukkit.jar. The result of this is below

We only have 1 file so far, the server!
We only have 1 file so far, the server!

The normal thing to do for most people is just double click it, sadly minecraft servers dont work like that, they need a script to launch them correctly. I have provided all the startup scripts here StartFiles

The .bat is for windows, .command is for mac.

Remember, the server .jar file must be called craftbukkit.jar

We are now ready to test out our server. Double click the start.something file and watch as a terminal or cmd opens with a load text.

The important bit here is at the bottom. It explains that it is generating the minecraft work which can take a few mins.
The important bit here is at the bottom. It explains that it is generating the minecraft work which can take a few mins.

You now have your very own minecraft server up and running.

!!!VERY IMPORTANT!!! Do not ever close the terminal or cmd with the x at the top! To correctly stop a server you must type stop into the terminal and hit enter. If you close it by mistake, easiest way to fix it is reboot your computer !!!VERY IMPORTANT!!!

You can connect to your minecraft server by launching minecraft, clicking multiplayer and connecting to localhost

If you can connect, you have done it all right!



To modify the experience for your students you can use plugins. These are modifications to the server developed for free by members of the community using the bukkit API. To add one, you simply download its .jar file and drop it into the plugins folder inside the server folder. Reboot your server and it will auto load on startup. Keep an eye on which version plugins were developed for, some older plugins may not work on more recent versions of bukkit. Most plugins work perfectly fine, RaspberryJuice for example was released 2 major releases back and it still works perfectly fine. Make sure to read the documentation that is on the plugin page if you are putting any other plugins.

Other stuff you need to know

You may want to edit some configuration text files, these are auto created when the server starts. The server.properties file is the main config file for the server. Details of it and its settings can be found at http://www.minecraftwiki.net/wiki/Server.properties

Minecraft servers have a built in permission system that is rather simple, you have 2 levels.

  • Player – can build, mine and play as a normal player
  • Op – (short for operator). The Op has full power over the server, can spawn in blocks, can change to creative mode (fly and infinite blocks) and can stop the server.

To add yourself as an op open the ops.txt file and add your name on the first line. You can also add it ingame and from server console.


The server is controlled via a series of commands, a user at the console has full permission to type any command, an Op ingame can type most commands and a play can type barely any.

To type a command ingame you prefix the command with a /

For example /stop from ingame would shut down the server. At the console you only need to type in stop and hit enter and the server will shut down. Make sure to give it a min to save the map.

A full list of commands can be found at http://www.minecraftwiki.net/wiki/Commands

You will need to download the minecraft pi version to grab the api folder which contains the python library, drop the api/python/minecraft folder into the base directory of your server. Then follow the normal minecraft pi guides but make sure to save your python scripts in your server base directory

Server is red World data files are grey Some of my python files are green API folder is yellow Text files to worry about are purple Stuff to ignore is orange
Server is red
World data files are grey
Some of my python files are green
API folder is yellow
Text files to worry about are purple
Stuff to ignore is orange

Each student will need a mini server for themselves, you can create the folder, zip it up and put it on a pendrive or shared network space and let them grab it, you dont need to include the folders in grey as the server will auto generate new worlds if no worlds exist.

Also keep in mind, if students know other students IP addresses, they can connect to each others server or write python scripts to do stuff to other peoples servers, it is up to you if you want to allow them to find out each others IP addresses 🙂

With a server running, connect to it with your client and you are good to go, create some python scripts!