Sniff is a "Scratch-like" programming language that's designed to help Scratchers move gently from Scratch to more conventional languages. They can start writing programs, without having to learn a new language because Sniff is based on Scratch. They learn a little more about variables, compiling, syntax errors (!), and they can have fun controlling real hardware while they're doing it.

Friday, 29 April 2016

The Microbit Breakout Board Breakout Board

The core strength of the microbit is that it has a bunch of stuff built into it. You can connect external stuff up to it, but realistically beyond the odd LED its not much fun. The edge connector is really cool looking, but its a pain to actually work with. So start by enjoying what it can do first. Realistically if you're going to start hooking up significant amounts of external hardware, then consider moving to  an Arduino, or perhaps the Nucleo N411RE. Sniff will run identically on these platforms.

In the future I can imagine a rich ecosystem of equipment that you can just plug a microbit into. You can code on your own board, and then just plug it into something that has sensors and actuators on it for a specific task. That would be pretty fun, though I'm not sure its particuarlty practical.

However right now the small UK hardware manufacturers who are likely to produce such equipment can't get their hands on a microbit to work with, and with the future of the micro:bit undisclosed they can't really make plans for future products.

The one company with access to the board in advance of the release (or even following the release!) are Kitronik. They've essentially produced two key products which operate with the microbit: a motor driver board, and a breakout board. They bundle these in various forms (buggy: motor driver+chasis, "inventor kit": breakout + breadboard). The motor board is a great idea, though a bit expensive at £11.50 - an Arduino equivalent would be about £1.50.

However the "Essential" which I expect they'll sell thousands of is the breakout board. Right now if you want to connect something to your microbit, then this is the only way to do it. I suspect over the next few weeks we'll figure out where to get hold of the parts to make these ourselves, but right now the only way to tap onto the edge connector reliably is to order one of these. These sound great value, but the headline price doesn't really last long: £2.50 sounds great, but then you decide not to solder it yourself, then add vat, then add postage and your £2.50 costs you £9.50! But they're the only game in town!

So what do you get for your £9.50? Its a simple board with an edge connector to plug the Microbit into and 2 lines of 20 pins. The 20pins carry the signals from pin0-16 plus 1x3v power and 2x0v ground pins. If you check the microbit docs you'll see that it actually has pads numbered up to 22, but 17,18 are 3V, and 21,22 are 0V. That leaves 19, 20 which are the i2c pins. If you've done this sort of stuff before (or you followed our Microbit tutorial) then you'll know that this is used internally to communicate with the Accelerometer and Magnetometer. Presumably to stop people messing with these 19 and 20 are connected to a couple of extra pads which aren't part of the main connector and don't have any pins soldered to them. If you want to add i2c you'll need to solder the pins in yourself.

So far we have a board that's (baring the i2c) totally functional, but hooking stuff to it is a total pain. It's a breakout in the strictest sense that all the pins are now accessible slightly more easily than they were before. However its not a lot of fun to use. While the pins are numbered, there's no indication of what functions they actually perform, so you'll constantly be referring back to the docs to see which pins are used by the display, or which support analog inputs...

What we really need is a project board - a breakout for the breakout (Microbit Breakout Breakout or MBB), that turns the strictly functional kitronik boarding something that we'd actually like to use, perhaps sacrificing some of that functionality for practical usability...

The first issue was how to attach stuff to the breakout board - my first thought was somehow to make the MBB plug into the Kitronik breakout and sit on top of it, perhaps using something like this:
However there were a couple of problems: it would leave everything at a funny angle, and I din't have one so it would take a few days to order one! Then came the breakthrough moment: I realised we needed a 40pin ribbon cable...  which it turns out is exactly what old IDE hard drives use! I had 3 in a box under my desk that were never going to be used for hard drives, and they fit perfectly.
With that sorted, we can connect a ribbon cable from the Kitronik breakout to the MBB Board (or MBBB). Now we're "in" we can layout at the MBB anyway we like.

The breakout I use most often (all the time!) is the Arduino Sensor shield V4. It's really easy to plug things into because each signal pin is part of a group of three, with gnd and power. Simple devices like servo's, LEDs, potentiometers, thermistors, speakers, DHT11's etc can be wired so they use this three pin header and just plug in.

However there's no point in breaking out ALL of the Microbits pins. We just don't need that many (or if we do then the Microbit is probably the wrong tool), and it would be confusing if we did. Also many of the pins are also used to control the screen, so it makes sense to stay away from them if we don't have to. I'm sure some project will use all of those pins for something, but at that point you probably need a custom board anyway, so that's not the problem we're trying to solve here. Instead I started be breaking out pins D0, D1 and D2 - the big ones!

The other thing I like on the Arduino Sensor shield is that it breaks out i2c on a four pin connector (0v, 5v, data, clock) and its really easy to plug stuff into it. Unfortunatly i2c isn't going to work here as its not carried on the 40pin header of the Kitronik board. If we were going direct the Microbit I'd include two sets of the i2c headers. However we do have SPI. SPI is a bit like i2c, but works in a slightly different way (think firewire Vs USB - different but doing the same job). I'll cover using it in the next post, but its broken out on the Microbit as pins 13,14,15. However while these are the main 3 SPI pins, we actually need a fourth pin to act as "CS". Pin 16 is free and almost certainly has been left free for that purpose, so we use 6 pins 13-16+power and earth. If you're not using SPI, then this gives four pins you can plug stuff into, so they'd be good for a stepper motor controller.

Finally, one of the things I missed when testing the Microbit was what is technically know as ein "BLINKENLICHTEN". The display is great but actually requires quite a lot of code to get working. Sometimes you just need to flash an LED to tell the world that you're OK. According to the spec's Pin 8 is the final, completly unused pin (12 may or may not be "reserved" depending on the docs you have), so lets throw an LED on there.

And thus the design was finished. From there it was straightforwards to wire it all up, and here it is! My soldering skills are awful, so I won't show you the reverse of the board - its not pretty. I also still need to make some labels, though that's a lot less of an issue now there are less available pins.

It took me an hour or so to wire this up, but I'm pretty confident that it will save me a lot more time than that over the next few weeks.  Initial tests worked great. I was able to quickly and easily plug loads of different things in, with far more confidence than using the regular breakout. If you're looking to use the microbit to teach electronics, then this exactly what you need. If someone out there has PCB facilities, they could lay it out in minutes and it would cost next to nothing to make on a small commercial scale.

There are few changes I'd make if this were a commercial product, but for now I'm really pleased with it.


  1. I am a STEM ambassasdor tooled up with a micro:bit and an electronic engineering background. The issue of easy I/O expansion also hit me, and I too ended up with a Kitronik kit for the connector, plus flying breadboard leads with dupont ends in order to do some interfacing.

    According to Elektor, who have published details of their own expansion board, they are trying to source the perfect connector too, but they seem to be currently using a less-than-ideal one from RS components:

    I know that various people are working on getting an 'official' micro:bit edge connector available through a main supplier.

    I am also keen to find out where all the micro:bit hackers and makers are hanging out so we can pool knowledge - is there an online location I have not found yet that someone can point me towards?

    1. I see I was listed as 'unknown' - I can be reached as linker3000 at gmail dot com, or through a reply here.

      Happy hacking!