Build an Internet-connected Bluetooth wearable with Arduino and Cordova, part one

Have you ever wanted to create your own Bluetooth app? Bluetooth is one of the most popular protocols for wireless communication between devices. Bluetooth powers a countless number of devices, from Bluetooth speakers, to smartwatches, headsets, fitness trackers, and more.

This two-part tutorial will walk you through how you can create your own Bluetooth fitness tracker using Arduino and Cordova. You might not have any experience with Arduino or Cordova, but don't worry! Both technologies are extremely simple and we're not even going to wire anything! In fact, we'll be talking to our Arduino over Bluetooth before we even have to write a line of code.

What you need

First things first, this ain't your momma's software demo. We're gonna need some real hardware for this one. Everything here should cost you just less than $100 and at the end of it all you'll be communicating wirelessly between your phone and an Arduino like magic.

We're going to be using TinyCircuits products for the Arduino side of things? Why? Because TinyCircuits is a totally awesome miniature Arduino platform about the size of a quarter. The shields snap together like LEGOs, leaving us nothing to wire.

Even better, the TinyDuinos are so small that they can function as a fitness band themselves! No need to ship your schematics off to China. Just strap these babies onto your wrist and you'll be a self-gamified cyborg in no time.

Here's the list of stuff you're gonna need:

• An Android or iOS device

• The respective syncing cable for above device

• TinyCircuits TinyDuino Basic Kit

• TinyCircuits Accelerometer Tinyshield

• TinyCircuits Bluetooth Low Energy[1]

• A micro-USB cable with data capabilities for TinyDuino

I'm betting you already have an Android or iOS device on you. I found all the TinyDuino stuff at my local Fry's Electronics near the Arduino gear. If you don't live near a Fry's, you can order the products online at

Getting started

Let's get it started in here. Pop open the clamshell packaging that the TinyDuino components come in. We're going to be working with the Processor and USB shield for now.

Stack the components one on top of another like this:

1.  USB

2.  Processor

Now you've got a super tiny Arduino platform! In fact, once you're done programming the TinyDuino you can throw a watch battery into the Processor shield and remove the USB shield altogether! Not yet though, we still have business to take care of.

Open the Arduino IDE, plug in the Micro USB cable into the TinyDuino, and load the normal Blink sketch. Choose "Arduino Pro or Pro Mini (3.3V, 8MHz)."

If you need more help with getting Blink running on the TinyDuino, TinyCircuits has a great getting started guide.

Once you've got Blink running you're ready for the next step!

Arduino Bluetooth

Alright, let's get to the fun part. Snap the TinyDuino Bluetooth Low Energy shield onto the top of your stack. It should look something like this now:

1.  Bluetooth

2.  USB

3.  Processor

At this point we're going to step away from the Arduino IDE and instead use an online tool called CodeBender. CodeBender is an awesome cloud-based Arduino programming interface that allows us to program our board using the browser. TinyDuino distributes their examples via CodeBender. You will need to install an extension to interface with your Arduino, but trust me, it's worth it.

Close the Arduino IDE (important!) and load the codebender sketch at Select "TinyDuino" under board and find your Arduino USB location. Finally, click "Run On Arduino."

Fire up the serial monitor on codebender and select 115200 Baud. The example will update you with Bluetooth logs throughout the connection process.

After a few seconds you should see the following messages in the serial monitor:

Evt Device Started: Standby

Advertising started

Use your phone to talk to the Arduino

Once you've confirmed that the Bluetooth sketch is running, you're ready to make your first connection! You may not see the Arduino within the Bluetooth devices connected to your phone, but don't worry. This isn't how you'll be connecting to the device.

Instead, we'll connect through our application. Before we use our own application, we're going to use an official application for debugging purposes. Download the NRF UART 2.0 app for Android or iPhone and launch it. Tap the button marked "connect."

If your Arduino is powered on, you should see a device called "URT" available. Tap on that device, and then a console should appear on your phone. Your phone will pair with your Arduino project and you should see the message "Connected to URT." If you're having trouble connecting, make sure your Arduino is powered on, Bluetooth is enabled on your phone, and the Arduino device is within range. Check the Arduino serial output on codebender for more debug information.

Once you've connected, you can type into the text field below and begin to send messages to your Arduino! As you send messages via your phone, you should see them echoed within the codebender console as well as in the NRF UART log.

At the end of this short test, my serial console had the following log:

Evt Device Started: Standby

Advertising started

Evt Connected

Evt Pipe Status

Evt Pipe Status

Evt link connection interval changed

Pipe Number: 11

4 bytes: test



Congratulations! You've created a basic Bluetooth device!

Click here to proceed to part two.

Ian Jennings is a developer at PubNub who specializes in building Internet of Things prototypes. Based in Ausin, Texas, Ian enjoys cycling, hiking, drumming, and cooking.

1. This hardware list uses a Nordic Bluetooth Low Energy chip. Bluetooth Low Energy (BLE) is designed to provide similar features to Bluetooth with reduced power consumption.