It’s time to take a look at the micro:bit, which is quite the impressive little device, and see what’s packed onto its small surface (4.5 × 5 cm—it’s been billed by the BBC as being about half the size of a credit card). I usually introduce new users to a device like this by examining each component one by one, moving clockwise around the board, and that seems like a perfectly reasonable route to take now. I’ll refer to the side of the micro:bit with the USB power connector and the micro:bit logo as the back, and the side with the array of LEDs and the two push buttons as the front (Figures A and B).
Starting with the Back
Starting at the top (12 o’clock position) on the back, we have a standard USB micro port (not a USB mini port). When you connect the micro:bit to your computer, the port is used both to power the board and for data transfer from your computer. The board requires 3.3V to operate. USB offers around 5V, so a regulator is used to lower the input voltage to a level that the board can use when it’s being powered by your computer.
Keep in mind, however, that this port is not necessary for either power or data transfer. You can power the micro:bit with a battery pack, and you can load programs to the board (also called flashing the board) by way of Bluetooth and a Bluetooth-enabled device such as a smartphone or laptop. This can come in handy if you install your micro:bit in an inaccessible place such as a project box or buried deep inside a load of electronics and wiring; you can flash the board with a new program by merely coming within a few feet of it.
The LEDs
Just next to the USB port, before the push button, is a small yellow LED that you probably wouldn’t notice until you plug the unit into your computer. It’s a status LED, and its purpose is simply to let the user know that the micro:bit is doing something, whether it’s loading a program or sending data.
Next to the USB port and the status LED is a momentary push button that serves as the reset button. When the board has a program onboard and is executing it, pushing this button resets it to the start of that program, as if the board had been powered off and then on again. This button is not programmable by the user; it’s hard-coded as a reset button only. If you’ve played around with an Arduino, you’re familiar with the concept of this button and what it’s used for. It’s helpful if your board freezes, if you need to restart a program for any reason, or if you just need to reset the board to a last-known-good configuration.
Connectivity
Next to the reset button is another power port. This port has two pins and is where you’ll plug in an external power source if you’re not powering the device via USB. The basic device comes with a battery pack that holds two AAA batteries; the Molex female connector to that pack plugs into the male pins on this connector.
Continuing in a clockwise direction, you’ll see a small black integrated circuit (IC) set back a bit from the edge of the board (Figure C). This is the USB controller that allows the CPU to communicate with the USB port. It’s an ARM Cortex-M0+ chip that not only allows the USB communication to take place, it also regulates the 5V power from the USB port down to the 3.3V, which the micro:bit needs to operate. The regulator portion of the chip isn’t necessary or used if you’re powering your board with batteries.
Now we come to the bottom of the board and its piano key-like appearance. Each of these twenty-five individual metal-plated “stripes” is a general-purpose input/output (GPIO) pin, which can be accessed by the user. It can be a difficult thing to do if you don’t have an edge connector, but the pins labeled 0, 1, 2, 3V, and GND (on the front of the board) are easily accessible with either a small alligator clip or a banana plug (Figure D).
Still moving clockwise, directly above the pins on the left is the first of the onboard sensors, the accelerometer. This miniscule black IC is a Freescale MMA8652 full-fledged three-axis accelerometer that communicates with the processor using the I2C protocol. It has 12 bits of resolution and communicates with data rates from 1.56 Hz to 800 Hz — quite a wide range of possibilities, depending on your needs and your project. No, it’s not a professional nine-axis inertial measurement unit (IMU) like you will find in many drone autopilots (for example), but three axes should be plenty for most simple micro:bit projects. You always have the option of upgrading and connecting a more powerful sensor via the GPIO pins, should your project call for it.
Next to the accelerometer is the other onboard sensor, the compass/magnetometer. Similar to the accelerometer, this IC is a Freescale MAG3110 three-axis digital magnetometer. It can be used as either a compass or a metal detector, and, like the accelerometer, communicates with the CPU over the I2C bus. It measures magnetic fields with an output data rate of up to 80 Hz, and has a sensitivity of 0.1 microteslas.
The I2C Protocol
I2C (or I squared C or I-I-C) stands for inter-integrated circuit, and is a communications protocol that was developed by Philips Semiconductor and released back in 1982. It’s a multi-master, multislave protocol that allows multiple devices to communicate with each other over typically short distances. I2C is a serial bus that’s often used with microcontrollers, sensors (like those on the micro:bit board), and small embedded devices. Most single-board computers like the Raspberry Pi and many, many sensors, ranging from barometers to GPS modules to magnetometers to thermometers and others, have native support for the I2C protocol, and it remains one of the easiest, most basic ways to communicate with external devices and sensors from a central CPU.
The Processor
After these two sensors, we come to the heart and brain of the whole thing—the processor (Figure E). This little black square is a 32-bit ARM Cortex M0 processor with 256 KB of flash memory and 16 KB of RAM, running at 16 MHz. It’s Bluetooth-capable, with an embedded 2.4 GHz Bluetooth low-energy transceiver.
So what does all of that mean in the context of capabilities and power? First of all, it’s a 32-bit machine, so it’s not quite as fast or powerful as the 64-bit processors we’re all getting used to. However, it’s more than fast enough for a tiny machine like this. The 256 KB of flash memory refers to the memory that is retained when there is no power; in other words, when you unplug the micro:bit from your computer or from its battery pack, the contents of flash memory are retained, sort of like the hard drive on your computer or laptop. This is where your hex files are stored and is why the program will repeat every time you power on the device. Now, 256 KB may not seem like a lot of memory (most JPEG files are bigger than that, for example), but the hex files your programs are stored in are tiny. A 256 KB hex file would be quite a hefty program.
The contents of the 16 KB of RAM, on the other hand, disappear every time the device loses power, just like the RAM in your computer. This batch of memory is where the micro:bit performs calculations; it moves data from the registers into RAM, does what it needs to, and then moves it out again. Because 16 KB is not a whole lot of space, it limits the micro:bit’s capabilities, but the board was never designed to do a lot of heavy lifting, compute-wise. Instead, it makes more sense to farm calculations and computations out to another, more powerful device, such as a smartphone, and merely use the micro:bit to collect and display data. It’s helpful to remember that the micro:bit, like other IoT platforms, is necessarily a very low-power device, and a more powerful onboard CPU would use unhealthy amounts of power. It’s quite impressive that the ARM chip is as powerful as it is for the amount of power it uses—at most around 0.03 watts, or about a one-hundredth as much as a standard night light.
Bluetooth Low-Energy Antenna
Finally, to complete our journey around the back side of the board, we come to the almost invisible Bluetooth Low-Energy (BLE) antenna just above the processor. If you tilt the micro:bit just right in the light, you can see the square-wave-like design embedded in the board in the top- left corner. This antenna allows the board to communicate with any other Bluetooth-enabled objects less than 100 meters away, according to the published specifications. The BLE, also called Bluetooth Smart protocol, enables a data rate over the air of 1 to 3 megabits per second, all while using less than 15 milliamps. Not only does this allow you to flash your board remotely with a laptop or smartphone, but it also lets you send sensor data from the board to another device without having to worry about draining your batteries. BLE is supposed to allow you to operate your device for weeks or even months using only a simple coin cell battery.
What’s the Range of BLE?
Although the published specs for Bluetooth Low-Energy state an operational range of 100 meters, my editor and I had doubts as to what the actual range of these devices is, so I decided to conduct a few informal tests. For both tests, I used a “Find my phone” application that requires pairing the micro:bit with your phone. The application loads a script onto the board that asks you to press the left (A) button. When you do that, it sends a Bluetooth signal to the phone, and the phone hollers “Yoo-hoo! Here I am!” at you until you press an acknowledgment button. For the first test, I paired with my board and then walked through my house, seeing how far away I could get before the phone would no longer respond. The results were disappointing, to say the least: in a clear line-of-sight path, the phone lost the signal at 26 feet (about 8 meters) away. When I turned a corner, I immediately lost the signal and the phone disconnected from the micro:bit.
For the second test, I took the phone and the micro:bit to a local football field, where I wouldn’t be dealing with local WiFi signals, walls, metal, and other possible interference, electromagnetic and otherwise. Again, I paired my phone with the micro:bit and walked away until the phone no longer responded to the device. The results? As disappointing as indoors. The farthest I was able to get before the phone no longer responded was again 26 feet. A few variables such as phone and micro:bit positioning seemed to affect results; holding the phone one way increased the range, whereas holding the micro:bit another way made communication completely impossible. Multiple attempts resulted in a maximum communication distance of about 8 meters.
The BLE specs probably apply to idealized conditions only— in a padded room, encased in a Faraday cage, etc. In addition, the size and shape of your antenna can make a real difference, and the antenna on the micro:bit is pretty small. I found some reports online of people getting ranges of over 200 meters, but I was unable to duplicate or confirm those results. In the real world it appears that you’ll only be able to rely on Bluetooth connectivity when you’re in the same room as your micro:bit. Keep that in mind as you design your future applications.
On to the Front
All right, that’s the back of the board, where all of the behind-the-scenes action is. Let’s take another look at the front (Figure F).
The front of the micro:bit may be where all the magic happens when you’re interacting with it, but there really isn’t much there. There’s a momentary push button on each side, A and B, each programmable by the user. Between them is a five-by-five matrix of low-power surface-mount LEDs, each of which is again programmable by you. These can be used to scroll text, display patterns, show arrows pointing in particular directions, and almost anything else you can think of doing with a grid of twenty-five tiny lights.
Along the bottom is the row of GPIO pins that we discussed earlier, though here you can see the labels for the most commonly used pins. The best way to access these pins is to purchase the edge-connector breakout board and simply slide your micro:bit into the slot, front-side up, as you see in Figure G. This breakout board exposes a double row of pins more like the ones you’re probably used to accessing on your Raspberry Pi board, and lets you use the header wires you probably already have in your toolkit. Be aware, however, that the number of pins is misleading; the pins are double-stacked, which means that each pair of adjacent pins leads to one single GPIO pin on the micro:bit. You do not, however, have to connect to both pins to interact with that GPIO pin. One or the other is sufficient.
So that’s a tour around the little micro:bit board. It’s a very basic device, designed to be easy to use and still be powerful enough to do interesting things. As a device for experimenters and hobbyists, it’s a bit low-powered compared to the Raspberry Pi, but it also fills a completely different niche than the Pi and its ilk.
Learn more about this amazing little device via Getting Started with the micro:bit, available at all fine booksellers.
ADVERTISEMENT