Send/Receive data using BLE and MBED | BBC Microbit

BLE

This video is all about sending and receiving data between BBC Microbit and any BLE enabled smart phone. Over here I have used C/C++ (MBED) as the programming language as other language (Python/JavaScript) don’t support UART data transfer service.

 

The BBC micro:bit is a pocket-sized, codable computer that allows anyone to get creative with technology. Made possible through a major partnership with 31 organisations, a micro:bit has been given to every 11 or 12 year old child in year 7 or equivalent across the UK, for free.
Source : Mbed (goo.gl/dTBWGi)
———————————————————————————————–
Links :
Setting up Yotta : bit.ly/2hCPxLH
Code File: bit.ly/2hWQWt8

#include "MicroBit.h"
#include "MicroBitUARTService.h"

MicroBit uBit;
MicroBitUARTService *uart;


int connected = 0;

void onConnected(MicroBitEvent)
{

    uBit.display.scroll("C");

    connected = 1;

    // mobile app will send ASCII strings terminated with the colon character
    ManagedString eom(":");

    while(connected == 1) {
        ManagedString msg = uart->readUntil(eom);
        uBit.display.scroll(msg);
    }

}

void onDisconnected(MicroBitEvent)
{
    uBit.display.scroll("D");
    connected = 0;
}

void onButtonA(MicroBitEvent)
{
    if (connected == 0) {
        return;
    }
    uart->send(ManagedString("Connected"));
    uBit.display.scroll("Y");
}

int main()
{
    // Initialise the micro:bit runtime.
    uBit.init();

  uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected);
  uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected);
    uBit.messageBus.listen(MICROBIT_ID_BUTTON_A, MICROBIT_BUTTON_EVT_CLICK, onButtonA);


    uart = new MicroBitUARTService(*uBit.ble, 32, 32);
    uBit.display.scroll("Ready");

  release_fiber();
}

Config File: bit.ly/2hWXgRx

{
    "microbit-dal": {
        "bluetooth": {
            "enabled": 1,
            "pairing_mode": 1,
            "open": 1,
            "event_service": 1
        },
        "gatt_table_size": "0x600"
    }
}

 

Configuration details : bit.ly/2hX2zAh
Android app by Martin Woolley : bit.ly/2hWWvrF
********************************************************************
Subscribe YouTube : bit.ly/2gsIZ2g

Guys Subscribe to my channel for latest contents into your inbox.
Support me to keep going.
___________________________________________

Website : www.weargenius.in
Twitter : twitter.com/geekybikash
YouTube : www.youtube.com/weargenius
Instagram : www.instagram.com/weargenius/
GIT : github.com/oksbwn
Facebook: www.facebook.com/geekybikash

Suvendu Swain
Catch Me On

Suvendu Swain

Blogger/ Educationist at WeArGenius
A person passionate about tech stuffs.
Suvendu Swain
Catch Me On

Suvendu Swain

A person passionate about tech stuffs.