Skip to content

Bluetooth Low Energy (Nordic) TinyShield

If you haven't already, go through the setup tutorial for the processor board you plan to use with this tutorial.

Learn more about the TinyDuino Platform


Description

Our Bluetooth Low Energy (BLE) TinyShield allows you to connect your TinyDuino system to any compatible iOS or Android (4.3+) device using Bluetooth Low Energy (also known as Bluetooth Smart and Bluetooth 4.0). This technology is great for low power sensors and accessories and works with most modern phones without the need for jailbreaking on iOS devices. This TinyShield is based around the popular Nordic nRF8001 chipset and allows wireless communication up to 10 meters away. The TinyShield also Includes power supply and level shifters on the board, so you can run your TinyDuino from 3.0V – 5V.

The Nordic rRF8001 chipset only supports slave mode. This allows it to connect to master Bluetooth LE devices (like smartphones) while rendering it unable to connect to other Bluetooth LE slave devices (ie, two BLE TinyShields cannot communicate directly with each other). If you need master mode as well, take a look at the Bluetooth Low Energy TinyShield Bluegiga version.

To see what other TinyShields are compatible with this TinyShield, see the TinyShield Compatibility Matrix

Technical Details Nordic BLE nRF8001 Specs
  • Fully Bluetooth Smart v4.0 compliant
    • Supports slave mode
  • Integrated Bluetooth Smart stack
    • LL, L2CAP, GAP, SM, ATT and GATT mandatory features for peripheral role operation
    • Bluetooth Smart profiles
  • Radio performance
    • Integrated chip antenna
    • TX power: +0 dBm to -18 dBm
    • Receiver sensitivity: -87 dBm
    • Range: up to 10m
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V
  • Current:
    • Transmit: 11mA (0 dBm)
    • Down to 4µA for 4s connection interval
    • Down to 9µA for 1s connection interval
    • Down to 16µA for 500ms connection interval
    • Down to 30µA for 250ms connection interval
    • Deep Sleep Mode: 0.5µA
    • Due to the low current, this board can be run using the TinyDuino coin cell option.
Pins Used

SPI Interface used

  • 2 - SPI_IRQ: This signal is the interrupt output from the nRF8001 to the TinyDuino.
  • 9 - BLE_RST: This signal is the reset signal to the nRF8001.
  • 10 - SPI_CS: This signal is the SPI chip select for the nRF8001.
  • 11 - MOSI: This signal is the serial SPI data out of the TinyDuino and into the radio transceiver.
  • 12 - MISO: This signal is the serial SPI data out of the radio transceiver and into the TinyDuino.
  • 13 - SCLK: This signal is the serial SPI clock out of the TinyDuino and into the radio transceiver.
Dimensions
  • 20mm x 20mm (.787 inches x .787 inches)
  • Max Height (from lower bottom TinyShield Connector to upper top TinyShield Connector): 5.11mm (0.201 inches)
  • Weight: 1.1 grams (.04 ounces)

Materials

TinyZero and Bluetooth Low Energy (Nordic) TinyShield

Hardware

Software


Hardware Assembly

On top of your processor board of choice, place the Bluetooth Low Energy (BLE) TinyShield. Plug a MicroUSB cable into the USB port and then plug the cable into an available USB port on your computer. Make sure the processor is switched on.

An assembled stack of a TinyZero and Bluetooth Low Energy (Nordic) TinyShield


Software Setup

Make sure you have the Arduino IDE. If you don't have it installed, check out a processor board setup tutorial respective to the one you are using: TinyDuino Setup Tutorial.

Upload Program

Download the included example program zip file that can be found under Materials/Software. This zip file contains header files that are necessary for the Arduino Sketch to work properly. After unzipping the folder, you should be able to select the main sketch TinyShield_NRF8001_BLE_Example to open the program in the Arduino IDE.

To upload the program, all you need to do is make sure that the correct board is selected under your Tools/ selection tab. For example, here are the selections for a TinyZero:

  • Board: "TinyZero"
  • Build Option: "Default"
  • Port: "COM##(TinyScreen+)" 

Tools Selections

Code
/*
  TinyCircuits NRF8001 UART Example Sketch

  This demo sets up the NRF8001 for Nordic's BLE virtual UART connection, and
  can pass data between the Arduino serial monitor and Nordic nRF UART V2.0 app
  or another compatible BLE terminal. Now supports TinyScreen+/SAMD21 boards.

  Written 27 May 2016
  By Ben Rose
  Modified 07 January 2019
  By Hunter Hykes

  https://TinyCircuits.com
*/


#if defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitorInterface SerialUSB
#else
  #define SerialMonitorInterface Serial
#endif

#define BLE_DEBUG true

#include <SPI.h>
#include "lib_aci.h"
#include "aci_setup.h"
#include "uart_over_ble.h"
#include "services.h"

uint8_t ble_rx_buffer[21];
uint8_t ble_rx_buffer_len = 0;
uint8_t ble_connection_state = false;

void setup(void)
{
  SerialMonitorInterface.begin(9600);
//  while (!SerialMonitorInterface);//Optional- On TinyScreen+/SAMD21 boards this will block until the serial monitor is opened
  delay(1000);
  BLEsetup();
}

void loop() {
  aci_loop();//Process any ACI commands or events from the NRF8001- main BLE handler, must run often. Keep main loop short.
  if (ble_rx_buffer_len) {//Check if data is available
    SerialMonitorInterface.print(ble_rx_buffer_len);
    SerialMonitorInterface.print(" : ");
    SerialMonitorInterface.println((char*)ble_rx_buffer);
    ble_rx_buffer_len = 0;//clear afer reading
  }
  if (SerialMonitorInterface.available()) {//Check if serial input is available to send
    delay(50);//should catch full input
    uint8_t sendBuffer[21];
    uint8_t sendLength = 0;
    while (SerialMonitorInterface.available() && sendLength < 19) {
      sendBuffer[sendLength] = SerialMonitorInterface.read();
      sendLength++;
    }
    if (SerialMonitorInterface.available()) {
      SerialMonitorInterface.print(F("Input truncated, dropped: "));
      while (SerialMonitorInterface.available()) {
        SerialMonitorInterface.write(SerialMonitorInterface.read());
      }
      SerialMonitorInterface.println();
    }
    sendBuffer[sendLength] = '\0'; //Terminate string
    sendLength++;
    if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, (uint8_t*)sendBuffer, sendLength))
    {
      SerialMonitorInterface.println(F("TX dropped!"));
    }
  }

}

Upload the program to your TinyDuino stack. Open up the Serial Monitor in order to begin viewing data.


Connect Stack to Phone

At this point, if you have not already, download a phone application that can interface with Bluetooth objects. As mentioned above under Materials/Software, the apps we have tested and used for Android and iOS are nRF UART v2.0 and nRF Connect, respectively. These are both free options!

Open up the Bluetooth interfacing app of your choice, and connect to the URT board which should be discoverable with the Serial Monitor open.

NOTE: Make sure your phone is in Discovery mode / turn on your Bluetooth.


iOS: nRF Connect

Open your application. Your Bluetooth device should be listed as 'URT' and you should select CONNECT for this object:

nRF Connect Opening Screen

Select the Nordic UART Service, and the RX option to prepare to send a message.

You should get some feedback on your Serial Monitor to show you that you have successfully connected to the TinyDuino stack:

Connection Status Serial Monitor

Now let's try to send a command from your phone to the Bluetooth module. Select the upward-facing arrow on the right side. Change your Format to Text, and then type in a message to send:

Saying hello!

Once the message is sent, you should immediately see that it is received from the Serial Monitor:

Serial Monitor feedback


Android: nRF UART v2.0

At this point, your program should be uploaded to your TinyDuino stack with your Serial Monitor open. If you haven't already, download the Android application, and open it.

Your phone should be in Discovery mode, and after clicking Connect on the app's opening screen, you should see a "URT" object. That's the nRF8001 module! After selecting the device, you should be connected to it via your phone.

nRF UART v2.0 Selections to Make Connections

To ensure that the connection has been made, you should see some feedback on the Serial Monitor telling you that the connection was made:

Serial Monitor Showing Connection Made: "Evt Connected"

With the connection made, you can now send a message from your phone to the TinyDuino stack:

Say hi!

After sending a short message, you should again see feedback on the Serial Monitor to show that the message was received:

Receiving a message!

Notice that the Serial Monitor prints the number of bytes, or characters in this case, and states that before printing the sent message.

Now you can talk to your stack from the convenience of your mobile device! You can use this to send commands to your TinyDuino project to activate different behavior like reading from sensors, controlling a motor, or really anything!


Downloads


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!