Microbit Sensors

Microbit Sensors demo.This app demonstrates how to scan for and communicate with a Microbit over BLE and read and display a range of sensor data from it.

You must run this app in Evothings Viewer, or build a Cordova app with the plugin com.evothings.ble. iOS device or Android device with support for Bluetooth 4.0 and Android 4.3 or higher required.

Source code

You can browse the source code for this example at the Evothings GitHub repository

The file index.html is the main HTML file of the app.

In file app.js you will find the JavaScript code for the app.

What you need

This example runs in Evothings Viewer on Android or iOS.

You need to run the example in Evothings Viewer. Alternatively, you can make a Cordova application if you wish to distribute the app. You then need to include the Cordova plugin com.evothings.ble. Read more in the documentation of the Evothings Viewer.

An iOS device or an Android device with support for Bluetooth 4.0 (which includes BLE) is required. For Android version 4.3 or later is needed. Please note that BLE support on Android is still not fully mature. As a result, you may experience difficulties running this example. If the app stops working, restart Evothings Viewer and/or reset Bluetooth on the device.

You also need a Microbit device.

Pairing up

Here are some things you need to know about how to connect your micro:bit. First of all, a micro:bit is meant for operations in schools and other environments that need to be safe, and where it's possible that there are a lot of micro:bits transmitting at the same time. As a precaution, a micro:bit will therefore whitelist any paired devices, so any device without a bond won’t be able to connect. Period. Also note that when a device has no bonds, it won’t even bother advertising. Once it has created one or more bonds to other devices, it will advertise anonymously as "BBC micro:bit". It also means that encryption is required at all times.

The actual pairing can be carried out using the "offical" micro:bit mobile app, graciously provided by Samsung. Pairing is only permitted in a special pairing mode, which you enter by holding down both buttons on each side of the LED screen (called A & B), and pressing reset with your other fingers, or nose. The 5x5 LED screen will say "PAIRING MODE" and show a pattern, which is copied by hand to the pairing view inside the micro:bit app on Android or iOS. Follow the rest of the on-screen instructions to pair up your micro:bit and your phone.

Micro:bit now advertises as BBC micro:bit[xxxxx], where xxxxx is a friendly name.

Note; You can of course make your own firmware using ARM's mbed framework which has less tight security in place. This and other tools for embedded development can be found on BBCs official site for the Micro:bit.

How to get up and running

Follow these steps to get started with this example:

  • First make sure your micro:bit is paired according to the instructions above.
  • Launch the Evothings Workbench on your desktop/laptop computer.
  • Launch Evothings Viewer on an Android mobile device and connect to the Workbench.
  • Run the example "Microbit Sensors" from the Workbench window.
  • Start the scan by pressing the "Connect" button.
  • If everything works, the app should automatically detect the Microbit and start displaying a range of sensors data from the Microbit.