RedBear

Getting Started with nRF51822

The getting started guide will show you how to develop applications for BLE Nano and RedBearLab nRF51822 using mbed, an online development platform, and on Arduino.


Requirements

  • iOS Devices with BLE support and running iOS Version 7.0 or later, including:
    iPhone 6+/6/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 Setup (BLE Nano only)

The MK20 USB board is designed to make it easy to deploy firmware to BLE Nano

  1. Solder the connectors for MK20 USB board and BLE Nano alt text

  2. Mount BLE Nano onto MK20 USB board alt text


Install Windows Driver (first time only)

MK20 USB board can be connected to your computer as both a serial port and a removable mass storage disk. On Mac and Linux, this will happen by automatically.

For Windows, you need to install the mbed Windows serial port drive.


Using mbed

Setup mbed Environment

  1. Go to mbed official website . Click on the top-right button to Login or signup if you do not have an mbed acount yet
    alt text
  2. Connect RedBearLab nRF51822 or BLE Nano with MK20 USB Board to your PC, the PC should detect a removable mass storage disk named MBED.

  3. Open the disk, you'll find a file named mbed.htm. Open the file a Browser. at text

  4. The Brower will open the corresponding platform page of the board you are using and add the board to your platform list automatically. at text at text

  5. Click on the "Compiler" at top-right corner. It will open the online development environment, then click on the button at top-right corner at text

  6. On the popped up window, select the platform you are using at bottom-left corner as your target platform. After you choose the platform, it will show the detail informations about the board. Click on the "Select Platform" at top-right corner to continue. at text at text

Build Blinky Application

  1. Click on the "Menubar > Import" and choose "Programs" to be imported. it will search all the programs stored in the mbed server. Select "mbed_blinky" and click on "Import" button to import the program.
    at text

  2. Rename the program if you wish and check the box to update all libraries to the latest revision, click "Import" to continue. at text

  3. After import the program, make sure the current platform at top-right corner is the board that you are using.

    BLE Nano only, not required in the future
    Open the main.cpp to edit, BLE Nano's on-board LED is connected to P0_19, so we change the LED object from "LED1" to "P0_19" at text

  4. Click on the "Menubar > Compile" to compile the program. If everything is ok, it will pop up a message box to let you download the generated hex file for the board you are using.

  5. Open the MBED disk and drag the downloaded hex file and drop it into the disk. After the file is uploaded, the LED on the board should start blinking. at text

Build Beacon Application

  1. Click on the "Menubar > Import" and choose "Programs" to be imported. Type "nRF51822" in the search box. It will search all the relative programs stored in the mbed server. Select "BLE_Beacon" and click on "Import" button to import the program.
    at text

  2. Rename the program if you wish and uncheck the box, not to update the libraries to the latest revision, as the latest BLE library version may prompt errors when compiling, click "Import" to continue.
    at text

  3. Open the main.cpp to edit, we change the Beacon's advertising UUID to 0xE2C56DB5-DFFB-48D2-B060-D0F5A71096E0 which is the default UUID used by a lot of samples.
    at text

  4. Make sure the current platform at top-right corner matches the board that you are using, click on the "Menubar > Compile" and download the hex file.

  5. Open the MBED disk and drag the downloaded hex file into the disk. Your BLE Nano or RedBearLab nRF51822 board becomes a BLE Beacon.

Using Arduino

*You must register your BLE Nano or RedBearLab nRF51822 board first before you could access our pre-release library, you will find a product registration card inside the product box with the instruction on how to register.

Setup Arduino IDE and Library

  1. Download Arduino IDE version 1.5.7 from Arduino website and install it to your PC

  2. Download RedBearLab nRF51822 add-on for Arduino IDE 1.5.7, which including the nRF51822 board configuration and library

  3. Merge the "hardware" folder that under "(downloaded packet path)..\arduino-1.5.x" to the "hardware" folder that under "(Arduino 1.5.7 installation path)..\arduino-1.5.7". Merge the folders and replace the files that are existed, no worry, our files do not overwrite the existing boards configuration and libraries. Then in your Arduino IDE folder, inside hardware/arduino, you should see three folders:
    • avr
    • RBL_nRF51822
    • sam

  4. Open Arduino IDE 1.5.7. Under "Menubar > Tools > Board" you will see the ReaBearLab boards being added. Choose the board you are using as your target board (we use BLE Nano for demonstration). at text

  5. Connect RedBearLab nRF51822 or BLE Nano mounted on MK20 USB board to your PC, a removable mass storage disk named MBED should appear. On Arduino IDE, under "Menubar > Tools > Port" you will see a comport number for your board. at text

  6. Follow the instruction on the README.md page of the RedBearLab nRF51822 add-on to finish the setup.

Build Blink application

  1. Open the Blink sketch: "File > Examples > 01.Basics > Blink". at text

  2. Then upload the sketch, clicking on the Right Arrow button at the IDE toolbar to begin uploading (it will compile first).

  3. After uploaded the sketch, the LED on the board should start blinking.