BBC micro:bit + Arduino IDE
This documentation is for the LEGACY version of Blynk platform which is no longer supported and will be shut down.
You can sign up for the current version of Blynk platform here.
The new mobile apps can be downloaded from App Store and Google Play.
The actual Blynk documentation is here.
But you can get bored with the functionality of the board itself. What if you could easily build an iOS/Android app to interact with your micro:bit? Blynk does just that! Here is how to use it with Arduino IDE. The whole tutorial should not take more than 30 minutes.
Install required software
Download and install the latest Arduino IDE.
Install Nordic nRF5 support package for Arduino. Follow instructions here.
Install BLEPeripheral library. You can use Arduino Library Manager or install manually.
Install the latest Blynk libraries. Our instructions.
Install Blynk app on your smartphone, and create an account (if you don't have one).
Configure your Arduino IDE and Micro:Bit
In Arduino IDE:
Select Tools -> Board -> BBC micro:bit
Select Tools -> SoftDevice -> S110 *
Select Tools -> Programmer -> CMSIS-DAP
Connect your Micro:Bit
Select: Tools -> nRF5 Flash SoftDevice (read and accept the license)
*Blynk device works as a Peripheral. So you may select any compatible SoftDevice: S110 is for Peripheral S120 is for Central only S130 is for Central + Peripheral S132 is for Nordic nRF52-based boards, Central + Peripheral
Upload your first sketch!
A new Auth Token for this device will land in your email box. Open our example for micro:bit in Arduino IDE: File > Examples > Blynk > Boards_Bluetooth > BBC_MicroBit
That's it! Click "Upload" button. In your project, add BLE widget and tap on it to open BLE Settings.
Click "Connect BLE device" button.
Select "Blynk" device.
Blynk App should report that the device is connected.
Make something useful ;)
Reading Analog Sensor
In Blynk App, add a Value Display widget and attach it to Analog Pin 1. After you run the project, you should see the value of analog sensor.
Reading Button Status
Add these lines on the top of setup
function, and upload it to the board.
Add a Value Display widget and attach it to Digital Pin 5. This is the pin of Button A, for Button B use pin 11 (see the pin map). Run your project to see the button status.
Switching some LEDs on and off
For this, you will have to add more code to your sketch. Add this above your loop and setup functions (not inside of them):
Why do we need to use 2 pins to drive a single LED? That's a legitimate question! Actually, this trick allows us to control all 25 LEDs by toggling just 12 GPIO pins in total. Read more about how micro:bit display works.
What next?
Read about Virtual Pins concept and unleash full power of Blynk. Blynk supports huge amount of board types. Check if your favourite is on the list! Our library is Open Source Software. Give us a star on GitHub.
Challenges
While micro:bit is working quite well in this mode, there are no default drivers currently available. For example, no convenient functions to work with the on-board LED array. However (with some efforts) these drivers can be ported to Arduino IDE: https://github.com/lancaster-university/microbit-dal/ The pin mapping for Arduino IDE core can be found here. And here is some advanced information on low-level C/C++ programming on micro:bit.
Last updated