element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Bluetooth Unleashed Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Bluetooth Unleashed Design Challenge
  • More
  • Cancel
Bluetooth Unleashed Design Challenge
Blog Bluetooth Maze – MicroBit talking to the Beaglebone Wireless
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 8 Jul 2018 12:48 AM Date Created
  • Views 1644 views
  • Likes 6 likes
  • Comments 2 comments
  • bluetooth unleashed
  • bluetooth_maze
Related
Recommended

Bluetooth Maze – MicroBit talking to the Beaglebone Wireless

carmelito
carmelito
8 Jul 2018

Here is a quick blog post which is a followup to my previous blog post on - setting up BlueZ on the Beaglebone Wireless , as part of the blog post I have the BBC MicroBit talking to the Beaglebone Wireless via Bluetooth.

image

Here are the steps, and the Arduino code you will have to upload to the MicroBit -

First connect to the Beaglbone Wireless via SSH and setup Adafuit's Python library  using the following commands, and also clone the repository so that we can run the UART service example

 

pip install Adafruit-BluefruitLE
git clone https://github.com/adafruit/Adafruit_Python_BluefruitLE.git

 

Now for the BBC Microbit, download and install the latest version of the Arduino IDE(version that I have installed is 1.8.5), and also follow this guide on the Adafruit Learning system - https://learn.adafruit.com/use-micro-bit-with-arduino/adafruit-libraries to install the following libraries

  • BLE Peripheral library
  • Adafruit GFX library
  • Adafruit_Microbit library

 

Copy paste the Arduino Code below into your, IDE and upload it to the BBC MicroBit

/*
 * Serial Port over BLE
 * Create UART service compatible with Nordic's *nRF Toolbox* and Adafruit's *Bluefruit LE* iOS/Android apps.
 *
 * Copyright (c) Sandeep Mistry. All rights reserved.
 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
 * BLESerial class implements same protocols as Arduino's built-in Serial class and can be used as it's wireless
 * replacement. Data transfers are routed through a BLE service with TX and RX characteristics. To make the
 * service discoverable all UUIDs are NUS (Nordic UART Service) compatible.
 *
 * Please note that TX and RX characteristics use Notify and WriteWithoutResponse, so there's no guarantee
 * that the data will make it to the other end. However, under normal circumstances and reasonable signal
 * strengths everything works well.
 */
//07022018- Modified to send button press to Beaglebone Wireless 
#include <Adafruit_Microbit.h>
Adafruit_Microbit microbit;


void setup() {
  Serial.begin(115200);


  Serial.println("Microbit ready!");
  //setup the two buttons on the microbit
  pinMode(PIN_BUTTON_A, INPUT);
  pinMode(PIN_BUTTON_B, INPUT);
  //custom services and characteristics can be added as well
  microbit.BTLESerial.begin();
  microbit.BTLESerial.setLocalName("microbit");
  // Start LED matrix driver after radio (required)
  microbit.begin();
}


void loop() {
  microbit.BTLESerial.poll();
  forward();
  //loopback();
  spam();
}




// forward received from Serial to microbit.BTLESerial and vice versa
void forward() {
  if (microbit.BTLESerial && Serial) {
    int byte;
    if (microbit.BTLESerial.available()) {
      Serial.write(microbit.BTLESerial.read());
    }
    char buffer[10];
    memset(buffer, 0x0, 10);
    int idx = 0;
    
    while (Serial.available() && idx != 10) {
       buffer[idx] = Serial.read();
       idx++;
    }
    if (idx) {
      microbit.BTLESerial.write(buffer, idx);
    }
  }
  delay(1);
}


// echo all received data back
void loopback() {
  if (microbit.BTLESerial) {
    int byte;
    while ((byte = microbit.BTLESerial.read()) > 0) {
        microbit.BTLESerial.write(byte);
    }
  }
}


// send button press
void spam() {
  if (microbit.BTLESerial) {
    //microbit.BTLESerial.print(millis());
    //microbit.BTLESerial.println("data");
  if (! digitalRead(PIN_BUTTON_A)) {
    Serial.println("Button A");
    microbit.BTLESerial.println("ButA");
  }
  if (! digitalRead(PIN_BUTTON_B)) {
    Serial.println("BUtton B");
    microbit.BTLESerial.println("ButB");
  }
    delay(1000);
  }
}

 

image

 

Now on the Beaglebone run the uart_service.py from the example folder , and once you see the transmission from the Beaglebone to Microbit saying 'Hello Bluetooth!', press the buttons on the Microbit and you should see them appear on the SSH teminal for the Beaglebone as shown in the screenshot below.

image

 

Video coming soon, edit is still a work in progress

  • Sign in to reply

Top Comments

  • genebren
    genebren over 7 years ago +2
    Great progress on your design challenge project. Nice to have gotten the two boards to start talking. Keep up the good work! Gene
  • DAB
    DAB over 7 years ago +2
    Interesting idea. You could set up the BB as a hub and link to multiple microbits. DAB
  • DAB
    DAB over 7 years ago

    Interesting idea.

     

    You could set up the BB as a hub and link to multiple microbits.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 7 years ago

    Great progress on your design challenge project. Nice to have gotten the two boards to start talking.

    Keep up the good work!

    Gene

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube