BBC micro:bit

The BBC micro:bit

The BBC micro:bit is a small microcontroller board designed for computer education in the UK - see the Wikipedia Article for more information.

It contains:

Note: While we provide Espruino for the micro:bit, it takes a lot of memory to provide bluetooth functionality and as a result some functionality has had to be removed:

If you want the full experience, please consider buying an official Espruino Board. Puck.js and Pixl.js are especially useful if you want to experiment with Bluetooth LE.

Flashing Espruino

There is a build of Espruino designed specifically for the micro:bit. Releases are available from the Download page - however you may also download 'cutting edge' builds from here - these are updated every time something changes in Espruino's source code, so may occasionally not work.

To flash onto your micro:bit:

Using the micro:bit

There are two ways to communicate with your micro:bit:

USB

This is the easiest, and recommended way of communicating with Espruino.

For Windows users, you will need to install drivers first - on other platforms, the board should 'just work'.

Follow the instructions in the Quick Start tutorial to install the Web IDE (ignore the Plugging in section), and you should be able to communicate with the micro:bit just like any other board.

Note: as the micro:bit has a display but no general-purpose LEDs, the tutorials in the Quick Start that use LED1/etc will not work without modification.

Bluetooth Low Energy (BT 4.0 / Bluetooth Smart)

You can also program the micro:bit wirelessly! There are two main ways to do this:

Web Bluetooth (Google Chromebook, Android 6)

If you have a device that supports Web Bluetooth, you can go directly to the Online Web IDE in your web browser, and can connect with that:

Note: You can still use Web Bluetooth on Android 5, but you need the latest 'Chromium' builds. See this post on StackOverflow

micro:bit Functionality

The micro:bit has a few variables and functions that are useful:

BTN1 and BTN2

These read the state of the two buttons, for example:

BTN1.read() or digitalRead(BTN1) return 1 or 0 depending on the state of the button

The following will write Pressed each time the button is pressed:

setWatch(function() {
  console.log("Pressed");
}, BTN1, {repeat:true, debounce:20, edge:"falling"});

Or this will write Pressed or Released:

setWatch(function(e) {
  if (e.state) console.log("Released");
  else console.log("Pressed");
}, BTN1, {repeat:true, debounce:20, edge:"both"});

Note: Currently the state of the buttons is inverted - 1 means not pressed, 0 means pressed.

show(bitmap)

Shows graphics on the built-in 5x5 LED screen. This takes a binary number or a string. For example:

show("1   1\n"+
     "  1  \n"+
     "  1  \n"+
     "1   1\n"+
     " 111 \n");
`

You can use the Graphics library to display text and images, for example the following with scroll 'Espruino' across the display:

g = Graphics.createArrayBuffer(5,5,1);
g.flip = function(){show(this.buffer);};

var x = 0;
setInterval(function() {
  x++;
  if (x>50)x=0;
  g.clear();
  g.drawString("Espruino",5-x);
  g.flip();
}, 100);

acceleration()

This returns an object with x, y, and z elements, each containing the force in that axis in g.

compass()

This returns an object with x, y, and z elements, indicating the current direction of the magnetic field

Pinout

Hover the mouse over a pin function for more information. Clicking in a function will tell you how to use it in Espruino.

D3 3.3v ! ADC
D0 3.3v ADC
D4 3.3v !
D5 3.3v ADC BTN1
D6 3.3v !
D7 3.3v !
D1 3.3v ADC
D8 3.3v
D9 3.3v !
D10 3.3v ! ADC
D11 3.3v BTN2
D12 3.3v
D2 3.3v ADC
D13 3.3v SPI1 SCK
D14 3.3v SPI1 MISO
D15 3.3v SPI1 MOSI
D16 3.3v
3.3
3.3
3.3
D19 3.3v ADC I2C1 SCL
D20 3.3v I2C1 SDA
GND
GND
GND

Tutorials

Tutorials using the micro:bit Board:

Micro:Bit VotingMicro:Bit VotingSending Text to Micro:BitSending Text to Micro:Bit

Tutorials using Bluetooth LE:

About Bluetooth LE (BLE)About Bluetooth LE (BLE)BLE Advertising with Node.js/Python/C#/AndroidBLE Advertising with Node.js/Python/C#/AndroidControlling Bluetooth Lights with Puck.jsControlling Bluetooth Lights with Puck.jsControlling Other BLE Espruino DevicesControlling Other BLE Espruino DevicesExercise Machine controlled VideoExercise Machine controlled VideoGetting Started with Puck.jsGetting Started with Puck.jsPixl.js Bluetooth to Ethernet MQTT BridgePixl.js Bluetooth to Ethernet MQTT BridgePixl.js SMS Remote MonitoringPixl.js SMS Remote MonitoringPuck.js Bluetooth with the Graphical EditorPuck.js Bluetooth with the Graphical EditorPuck.js MIDIPuck.js MIDIPuck.js Music ControllerPuck.js Music ControllerPuck.js Security and Access ControlPuck.js Security and Access ControlPuck.js and BLE PrintersPuck.js and BLE PrintersPuck.js and BLE UARTsPuck.js and BLE UARTsPuck.js and Eddystone BeaconsPuck.js and Eddystone BeaconsPuck.js and HID KeyboardsPuck.js and HID KeyboardsPuck.js and HTTP ProxiesPuck.js and HTTP ProxiesPuck.js and If This Then ThatPuck.js and If This Then ThatPuck.js and Node-RED with MQTTPuck.js and Node-RED with MQTTPuck.js and iBeaconsPuck.js and iBeaconsPuck.js with SMS controlPuck.js with SMS controlQuick Start (Bluetooth LE)Quick Start (Bluetooth LE)Using Puck.js from a Web Bluetooth WebsiteUsing Puck.js from a Web Bluetooth WebsiteWeb Bluetooth on LinuxWeb Bluetooth on LinuxWeb IDE on a Raspberry PiWeb IDE on a Raspberry Pi

Tutorials using Bluetooth LE and functionality that may not be part of the micro:bit:

Door Controlled Light with Puck.jsDoor Controlled Light with Puck.jsInfrared Record and Playback with Puck.jsInfrared Record and Playback with Puck.jsPixl.js Wireless Temperature DisplayPixl.js Wireless Temperature DisplayPixl.js Wireless Weather StationPixl.js Wireless Weather StationTemperature Controlled Night Light with Puck.jsTemperature Controlled Night Light with Puck.js

Buying

micro:bits are currently available to buy in the UK and in the United States.

Official Espruino Boards

Espruino PicoEspruino PicoEspruino WiFiEspruino WiFiMDBT42Q Bluetooth ModuleMDBT42Q Bluetooth ModuleOriginal Espruino BoardOriginal Espruino BoardPixl.jsPixl.jsPuck.jsPuck.js

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.