RedBear

Getting Started with Blend Micro

We recommend using Codebender, an online development and collaboration platform for all Arduino users, please read to our Quick Start with Codebender to start playing with your Blend Micro in just a few easy steps.


Objective

  • Getting Blend Micro to work with our BLE Controller for Android or iOS.

Requirements

  • iOS Devices with BLE support and running iOS Version 7.0 or later, including:
    iPhone 5s/5c/5, iPhone 4S, iPad Air/3rd-Gen/4th-Gen, iPad mini, iPod Touch (5th-Gen)
  • Android Devices with BLE support and running Android Version 4.3 or later, such as: Nexus 4, Nexus 5 and Nexus 7
    (please visit our Android Support page for list of compatible Android devices)
  • A host machine with Arduino IDE installed:
    Mac, Windows or Linux PC

Hardware Checklist

Blend Micro

Blend Micro

Micro USB Cable

Micro USB Cable


Software Checklist


Arduino IDE Setup (first time only)

An Add-On is required in order for the Arduino IDE to support your Blend Micro, please follow the steps below:

  1. Before install the Add-On package, you shoud not be able to see the Blend Micro board

    alt text

  2. Check your "Sketchbook location" in Arduino IDE (it is for storing Arduino support files), go to menu File > Preferences... (on Mac OSX, go to menu Arduino > Preferences...)

    alt text

  3. Exit/Quit Arduino IDE

  4. Navigate to your Sketchbook folder (e.g. C:\Users\\Documents\Arduino), it should be empty or contains a folder named "libraries"

    alt text

  5. Unzip the "RedBearLab Blend Add-On" package and copy the "hardware" folder (inside "Arduino" folder) to your Sketchbook folder

    alt text

  6. Locate "main.cpp" in your Arduino IDE folder
    • Windows
      Arduino IDE folder > hardware > arduino > cores > arduino > main.cp
    • Mac OSX
      Ctrl-Click/Right-Click the Arduino.app file and choose Show Package Contents
      Contents > Resources > Java > hardware > arduino > cores > arduino > main.cpp

  7. Replace it with the "main.cpp" from the "RedBearLab Blend Add-On" package. You could modify the file yourself, see below.

  8. Re-start the Arduino IDE and two (2) Blend Micro boards should be available

    alt text


You can modify the “main.cpp” manually by adding the following code before "setup()".

#if defined(BLEND_MICRO_8MHZ)
    // As the F_CPU = 8000000UL, the USB core make the PLLCSR = 0x02
    // But the external xtal is 16000000Hz, so correct it here.
    PLLCSR |= 0x10;             // Need 16 MHz xtal
    while (!(PLLCSR & (1<<PLOCK)));     // wait for lock pll
#elif defined(BLEND_MICRO_16MHZ)
    // The CPU clock in bootloader is 8MHz, change to 16MHz for sketches to run (i.e. overclock running at 3.3v).
    CLKPR = 0x80;
    CLKPR = 0;
#endif

This code is to set the USB and CPU clock as it is running at 8 MHz with 3.3v but the external crystal is 16 MHz, so need to adjust the USB to run correctly.


Install Windows Driver (first time only)

  • No need to do this if you are using other POSIX systems like Linux or Mac OSX.
  • Follow the Windows Driver Installation Guide to install the driver for the Blend Micro.

Libraries Setup

Important: Blend, Blend Micro and our BLE Shield share the same libraires. If you have followed our other "Getting Started" guide and installed the above libraries, you can skip this section go to "Test Installation"

  1. Remove older versions of Nordic & RedBearLab Libraries, go to your Sketchbook folder (e.g. C:\Users\\Documents\Arduino\ on Windows) and delete the following folders
    • "BLE"
    • "BluetoothLowEnergy"
    • "RBL_BLEShield"
    • "Nordic_BLE"

  2. Unzip the "ble-sdk-arduino-0.9.0.beta.zip" and "nRF8001-20140509.zip" packages

  3. Launch Arduino IDE and select menu Sketch > Import Library... > Add Library...

    alt text

  4. Navigate to folder "ble-sdk-arduino-0.9.0.beta" > "libraries", select the "BLE" folder icon and click "Open" to import

  5. Select menu Sketch > Import Library... > Add Library... again, navigate to folder "nRF8001-20140509" > "Arduino" > "libraries" and import "RBL_nRF8001" folder

  6. Now both Nordic's "BLE" and our "RBL_nRF8001" should appear at the 'Contributed' section of Import Library menu

    alt text

  7. Your "Arduino" > "Libraries" folder should contain the "BLE" and "RBL_nRF8001" folders

    alt text

Test Installation

  1. Open the Blink sketch, Arduino IDE Menu: File > Examples > 01.Basics > Blink

  2. Select Board and Serial Port

    Arduino IDE Menu: Tools > Board > Blend Micro 3.3V/8MHz

    alt text

    Arduino IDE Menu: Tools > Serial Port > (Your Serial Port)

    alt text

  3. Upload the Sketch - click on the Right Arrow button at the IDE toolbar to begin upload (it will compile first)

  4. The LED on Blend Micro should be flashing.



Troubleshooting

There are two possible causes of not able to upload sketches to your Blend Micro

  1. You may have forgotten to change/modify the main.cpp file.

  2. Fail to upload a complete sketch last time. (e.g. uploading and suddenly removing power source, then the board's USB will not work since the firmware inside the board is invalid)


Recovery Procedure

  1. Modify the main.cpp as mentioned in the "Arduino IDE Setup" session shown above.

  2. Open the Blink sketch

  3. Reset the board, it will enter to bootloader mode for 8 seconds (the LED - L will be flashing).

  4. During this 8-second period, select the COM port of the board in the Arduino IDE (Menu -> Tools -> Serial Port)

  5. Press "Compile and Upload" and then press the reset button on the board again, it should be able to load the sketch and fix the issue.


Run the Demo App

  1. Connect Blend Micro to host PC with a Micro USB cable

    alt text

  2. Open the BLEControllerSketch, Arduino IDE Menu: File > Examples > RBL_nRF8001 > BLEControllerSketch

    alt text

    alt text

  3. Select Board and Serial Port

    Arduino IDE Menu: Tools > Board > Blend Micro 3.3V/8MHz

    alt text

    Arduino IDE Menu: Tools > Serial Port > (Your Serial Port)

    alt text

  4. Upload the Sketch - click on the Right Arrow button at the IDE toolbar to begin upload (it will compile first)

    alt text

    alt text

    alt text

iOS Setup

  1. Download BLE Controller from Apple App Store

    alt text

  2. Turn on Bluetooth, unlike traditional Bluetooth devices (e.g. Bluetooth 2.1, 3.0), BLE devices will not be shown on this screen

    alt text

  3. Start BLE Controller

    alt text

  4. Click "Scan", if everything is correct, the list will show your BLE devices, select BlendMicro to connect

    alt text

  5. On success, it will shows all pins of your Blend Micro board

    alt text

  6. Change the pin mode and set the pin state to control

    alt text

  7. Click the 'X' button to disconnect. (Located at top-right corner)

Android Setup (Nexus 5)

  1. Download BLE Controller from Google Play Store

    alt text

  2. Turn on Bluetooth

    alt text

  3. Start BLE Controller

    alt text

  4. Click "Scan" - if everything is correct, the list will show your BLE devices, select BlendMicro to connect

    alt text

  5. On success, it will shows all pins of your Blend Micro board

    alt text

  6. Change the pin mode and set the pin state to control

    alt text

  7. Click the 'RedBear' icon to disconnect. (Located at top-left corner)