Intro: HackerBox 0022: BBC Micro:Bit
BBC Micro:Bit - This month, HackerBox Hackers are experimenting with the BBC Micro:Bit embedded computing platform and associated interfacing and wireless communications technology. This Instructable contains information for working with HackerBoxes #0022. If you would like to receive a box like this in your mailbox each month, now is the time to subscribe at HackerBoxes.com and join the revolution!
Topics and Learning Objectives for HackerBox 0022:
- Working with the BBC micro:bit tiny embedded computer
- Programming the micro:bit in multiple languages
- Understanding Nordic nRF 2.4GHz wireless functionality
- Exploring wireless security research opportunities
- User interfacing with LEDs, audio, and OLED displays
- Leveraging connector breakouts and prototyping
- Expanding IoT applications with Wi-Fi connectivity
HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. We are the dreamers of dreams.
Step 1: HackerBox 0022: Box Contents
- HackerBoxes #0022 Collectable Reference Card
- BBC Micro:Bit Computing Platform
- BBC Micro:Bit Connector Breakout Kit
- Twin AA Battery Holder
- OLED 128x64 pixel I2C Display
- Alligator Clip Jumper Wires
- Miniature Solderless Breadboard
- ESP-01 Wi-Fi Modules
- Six LED Indicator Module
- Passive Piezo Buzzer
- AMS1117 3.3V Regulator Module
- Header Pins
- DuPont Jumpers
- MicroUSB Cable
- MicroUSB Breakout Module
- Exclusive Micro:Bit Decal
Some other things that will be helpful:
- Soldering iron, solder, and basic soldering tools
- Two AA battery cells
- Computer for running development tools
Most importantly, you will need a sense of adventure, DIY spirit, and hacker curiosity. Hardcore DIY electronics is not a trivial pursuit, and we are not watering it down for you. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from learning new technology and hopefully getting some projects working. We suggest taking each step slowly, minding the details, and never hesitating to ask for help.
FREQUENTLY ASKED QUESTIONS: We would like to ask all HackerBox subscribers a really big favor. Please take a moment to review the FAQ on the website prior to contacting support. While we obviously want to help all members as much as necessary, over 80% of our support emails involve simple questions that are very clearly addressed in the FAQ. Thank you for understanding!
Step 2: Introducing the BBC Micro:bit
The micro:bit is a tiny programmable computer, designed to for learning and teaching. Development of the Micro Bit is a product of a number of partners including: the BBC, ARM, Cisco, Microsoft, Samsung, and several other heavy hitters. The original motivation for creation of the micro:bit was educational and it is a lot of fun to play with, but the platform's impressive embedded hardware capabilities make it quite suitable for more advanced experimentation.
Primary Microcontroller: The Nordic nRF51822 has a 16 MHz 32-bit ARM Cortex-M0 core, 256 KB of flash memory, 16 KB of static RAM, and 2.4 GHz Bluetooth low energy wireless networking. The ARM core has the capability to switch between 16 MHz or 32.768 kHz clocks.
Secondary Microcontroller: (for USB interfacing) The NXP/Freescale KL26Z has a 48 MHz ARM Cortex-M0+ core. It also includes a full-speed USB 2.0 On-The-Go (OTG) controller. The USB interface can regulate the 5V USB supply down to the 3.3V required by the PCB. When the micro:bit is running on batteries, this regulator is not used.
Accelerometer: The NXP/Freescale MMA8652 is a three-axis accelerometer sensor connected via I²C-bus.
Magnetometer: The NXP/Freescale MAG3110 is a three-axis magnetometer sensor connected via I²C-bus. It can act as a compass or metal detector).
Connectors: MicroUSB, JST battery connector, 23-pin edge connector.
Display: 25 LEDs in a 5×5 array.
Tactile pushbuttons: Two user buttons. One reset button.
Step 3: Programming the Micro:bit
Hello World: The micro:bit comes with a little demo firmware preloaded. Power up the micro:bit using the battery pack or the USB cable. The display will scroll text inviting you to test the buttons, shake the board, and finally tilt the board to chase the dot.
MicroPython: The version of Python that the BBC micro:bit uses is called MicroPython. The official guide to micro:bit MicroPython is quite useful. At least try out their MicroPython "Hello World" exercise.
Code with Mu: The Mu Editor is a simple MicroPython code editor for programmers. It is written in Python and works on Windows, OSX, Linux, and Raspberry Pi.
Step 4: Wireless Sniffing and Drone Hacking
Damien Cauquil presented a talk at DEFCON 25 entitled "Weaponizing the BBC Micro:Bit" [slides]. He demonstrated that, with a little Python code, the micro:bit turns out to be an excellent wireless sniffer. Cauquil used publicly available code on the micro:bit to snoop on signals from a Bluetooth wireless keyboard. He also attached a micro:bit to a drone controller handset to take control of a quadcopter in mid-flight. Cauquil observed that the micro:bit wireless hardware and Python support make it better at over-the-air sniffing and attacks than many dedicated hacking devices. [Article reported by The Register.]
Cauquil's GitHub repo for Radiobit is a set of MicroPython of tools for security researchers to sniff, receive, and send data over Nordic's Enhanced ShockBurst (ESB) protocol, Nordic' ShockBurst (SB) protocol, and Bluetooth Smart Link Layer. The tools also support sniffing raw 2.4GHz GFSK modulated data.
NOTICE: This information and the associated tools are provided for security research and education - ultimately to improve device security. Do not be evil. Do not not use this technology, or your knowledge, for evil. "When you're smart, people need you." -Chris Knight, Real Genius.
Step 5: Micro:Bit I/O Pads and the Music Module
MicroPython on the BBC micro:bit comes with a powerful music and sound module supporting the generation of sounds on an attached speaker or buzzer. Use alligator clips to attach pin 0 and GND to the positive and negative pins on the buzzer.
Step 6: Micro:Bit As a Wearable Badge
Quite a few customized micro:bit-based badges were on display this summer at DEFCON 25. Given its compact geometry and simple LED display, the micro:bit is an easy wearable platform for displaying symbols, scrolling text, and supporting 2.4GHz wireless functionality.
Collaboration on /r/defcon cooked up the DEFCON 25 micro:badge which displays a skull animation and implements a pager network between paired badges over Bluetooth.
Also check this simple interactive badge project published by codeclub.
Step 7: Micro:Bit Edge Connector Breakout Board
If you are looking to do more hardware hacking with the BBC micro:bit than afforded by the alligator clips, Kitronik offers a lot of very cool gizmos including their Edge Connector Breakout Board. This breakout board has been designed to offer an easy way to connect additional circuits and hardware to the pins on the edge of the BBC micro:bit. It provides access to all of the BBC micro:bit processor pins allowing a lot of extra functionality to be added. Kitronik's datasheet (here) includes a helpful diagram explaining the function of every pin on the BBC micro:bit.
The Edge Connector Breakout Board for the BBC micro:bit gives access to all of the important pins on the bottom edge of the BBC micro:bit. 21 pins are broken out in total; providing additional I/O lines, direct access to buttons A and B, the LED matrix outputs and the I2C bus.
The BBC micro:bit pins are broken out to a row of pin headers. These provide an easy way of connecting circuits using jumper wires. The SCL and SDA pins are separated at the edge of the board (solder pads) providing easy identification. The PCB includes a prototyping area with 3V, 0V and unconnected rows that can be soldered. This allows the easy connection of switches, sensors and any pull-up or pull-down resistors etc. as required.
Step 8: OLED Display for More Pixels
Sometimes 25 LEDs are simply not enough. This demo shows how to leverage a 0.96 inch OLED display with 128x64 pixels using the micro:bit I²C bus. The demo uses the micro:bit MicroPython I2C module with the OLED's SCL pin connected to micro:bit pin 19, and the OLED's SDA pin connected to micro:bit pin 20.
The driver functions in the attached code file (SSD1306_DEMO.py) are from the fizban99 SSD1306 repo.
Also check out the bitflyer game created by Steve Stagg using this same OLED display module.
Step 9: Micro:Bit IoT, C Programming, Wi-Fi
If you want to get closer to the metal than Python, there is a detailed online guide to programming the micro:bit in C/C++. The examples include IoT operations using the ESP-01 module featuring the ESP8266 Wi-Fi chip. The ESP-01 serial interface can also be accessed in MicroPython using the UART module.
Note that the ESP-01 draws more current from the 3.3V rail that the micro:bit on-board regulator can supply. A microUSB breakout board can supply 5V to a 3.3V regulator module, as shown in this schematic. This setup will provide enough current at 3.3V to power the ESP-01.
Step 10: More Micro:Bit Projects
Step 11: Handy Six Bit LED Indicator Module
This module is a great tool for quickly adding six extra LEDs to any I/O lines. It is useful for debugging or other LED indicator needs. The current-limiting resistors are already in place and the indicators share a common ground pin.
The Six LED module can be plugged directly onto an Arduino UNO. It can also be used with pretty much any other microcontroller, CPLD/FPGA, or other digital system via jumpers or a solderless breadboard.
Step 12: Make. Break. Repeat.
Thank you for joining our adventures into the world of the BBC micro:bit. If you have enjoyed this Instrucable and would like to have a box of electronics and computer tech projects like this delivered right to your mailbox each month, please join us by SUBSCRIBING HERE.
Reach out and share your success in the comments below or on the HackerBoxes Facebook page. Certainly let us know if you have any questions or need some help with anything. Thank you for being part of HackerBoxes. Please keep your suggestions and feedback coming. HackerBoxes are YOUR boxes. Let's make something great!