Thursday, 19 January 2017

Raspberry Pi and BBC micro:bit for C2Pi

Right now the Raspberry Pi and the BBC micro:bit look like a winning team.

If you're following this blog you will know that I am evaluating new hardware and software for C2Pi (the re-generated C3Pi, neƩ Trackbot).

Over the weekend I discovered that the micro:bit now supports MicroPython.

Since I am looking for a micro that supports a language with a REPL, I had to investigate.

MicroPython on the pyboard

I've been a fan of MicroPython for a while. It runs on several platforms, including a custom board (the pyboard).

I first met the pyboard, and Damien George, (its designer, and the original implementer of MicroPython) at an Open Technology conference in Cambridge a couple of years ago.

I learned that MicroPython is a full, optimised implementation of Python 3; the only difference lies in MicroPython's specialised libraries, which  focus on direct access to the hardware.

At the time I felt that the pyboard and MicroPython had great potential but I couldn't use them for the project I was building back then.

Things have changed.

MicroPython on the BBC micro:bit

The original Pyboard is a good fit for C2Pi. However, the BBC micro:bit looks even better. It's cheaper, and there are over a million micro:bits out in the field.

The micro:bit has slightly less functionality than the pyboard and a smaller memory but  looks entirely adequate for what I want to do.


I ordered a Kitronics micro:bit prototyping kit from my friends at Pimoroni and the kit arrived a couple of days ago.

Image courtesy of Pimoroni

So far I am encouraged and impressed. It's been easy to set up a link for the Pi to the micro:bit. I can send Python commands from the Pi for execution on the micro, which is perfect for fast development.

Interactive Python on the micro:bit

The session below shows the Linux screen app on a Pi, talking to a micro:bit via a USB serial link and running a couple of simple Python expressions.


Hardware interfaces exposed


The micro:bit running MicroPython gives easy access to all the interfaces that C2Pi needs: GPIO, UART, I2C and SPI.

If all continues to go well I will set up a public GitHub repo for my experimental code, and post more details here.


Prototyping kit

It seems there's great potential for the Pi combined with the micro:bit. What do you think?

If you have questions, opinions or ideas, do post a comment. I'd love to hear from you.