Mar 262015
 
 March 26, 2015  Posted by at 12:33 pm Microsoft Band, Sensors  Add comments

AjVDKV_N

The blog has been bit more quiet than usual the last two weeks as I have been working on a new course for Pluralsight on Microsoft Band, a course I’m wrapping up this weekend (if all goes as planned). I’ve gotten to know the device and the SDK rather well over the last month or so and would love to share with you a detailed tutorial that covers the SDK in details, as well as some ideas for applications, cover bugs and peculiars (at the time of writing the SDK is still in preview) related to the SDK, the band and the environment.

For this tutorial I recommend Windows 8.1 or up, Visual Studio 2013 and up (community edition is a free version you can use), and Windows Phone 8.1 SDK. However, the band has SDK for iOS and Android as well, and you can also use Xamarin.

In this part I’m going to cover setting up the environment and a little bit about the device so we can get started immediately. In every upcoming tutorial part I’ll cover more and more about the device so we can get a good mix of information and code, as it makes more sense to talk about the details as we are actually integrating those parts in our application.

In short the Microsoft Band is a device worn as a bracelet/band with a bright display and with as far as I know has the most sensors in any band out there at the moment:

  • Optical heart rate sensor
  • 3-axis accelerometer
  • Gyrometer
  • GPS*
  • Ambient light sensor**
  • Skin temperature sensor
  • UV sensor
  • Capacitive sensor
  • Galvanic skin response**

I’ll cover the sensors in more detail when we get to that part in the SDK.

*The GPS is built in and at the moment is not accessible through the SDK. This is in large part out of privacy concerns, and maybe access will change once preserving privacy can be secured.

** These are currently not accessible through the SDK

These are the sesnors we currently have access to. Distance is not really a sensor:)

Contact only provides two possible results, if the band is currently worn or not.

public interface IBandSensorManager
{
    IBandSensor<IBandAccelerometerReading> Accelerometer { get; }
    IBandContactSensor Contact { get; }
    IBandSensor<IBandDistanceReading> Distance { get; }
    IBandSensor<IBandGyroscopeReading> Gyroscope { get; }
    IBandSensor<IBandHeartRateReading> HeartRate { get; }
    IBandSensor<IBandPedometerReading> Pedometer { get; }
    IBandSensor<IBandSkinTemperatureReading> SkinTemperature { get; }
    IBandSensor<IBandUltravioletLightReading> Ultraviolet { get; }
}

WP_20150208_22_07_34_Pro

Besides the sensors there is also a microphone, a tiny keyboard that works exceptionally well (and also has wordflow/swipe) and a haptic feedback motor that allows us to signal the user with vibrations. The band has a default app on all the platforms called Microsoft Health that uses the health vault for storage. The app is where you update the band, as well as manage all existing applications*

*Your application can only access the tiles it created itself

There are many applications and features already available for the band through the application, as well as an increasing number of third party applications, and not all are related to health. We have calendar sync, notifications, calls, sms, email, sleep/walk/run/bike tracking, Cortana (Microsoft speech assistant), weather and a whole lot more. But with that said, there is absolutely room for more applications, and this where we come in. So let’s set up our environment and get started!

Here are our very first basic first steps- tomorrow we will connect to the band and retrieve band information and continue on from there.

The band requires the latest update, so before we can proceed you need to make sure that it is updated. This is done through the Microsoft Health application. Here are some problems you might encounter, and some fixes you can try:

Update the Microsoft Band with the latest update

               Problems with update:

Close health app by holding down back button and clicking the X or swiping the app down

Check that Band is paired and connected under Bluetooth settings

Make sure you have a reliable connection, if not use the Windows app for the update and an Ethernet cable

Restart the Health app and select sync, this should prompt update

If you have a windows machine you can update the band through the USB cable used for charging.  This will speed up the update.

Problems connecting:

First make sure you have all the latest Windows Phone updates

Delete old pairing (Bluetooth settings on the phone)

Restart phone

Restart Band

Pair again

Connect

Create a WP project

Just do a a file, new project, Windows Phone 🙂

Install package using NuGet console

Install-Package Microsoft.Band –Pre

If you use the package manager UI (right click on project, Nuget Package Manager) make sure that you have selected pre-release in the left dropdown before searching for the Microsoft Band SDK (online)

2015-03-28_14-37-34

Check that Proximity has been added to the manifest file, and that the following lines have been added as well (right click on the manifest file and select open with, select XML editor)

    
  <DeviceCapability Name="bluetooth.rfcomm" xmlns="http://schemas.microsoft.com/appx/2013/manifest">
      <Device Id="any">
        <!-- Used by the Microsoft Band SDK Preview -->
        <Function Type="serviceId:A502CA9A-2BA5-413C-A4E0-13804E47B38F" />
        <!-- Used by the Microsoft Band SDK Preview -->
        <Function Type="serviceId:C742E1A2-6320-5ABC-9643-D206C677E580" />
      </Device>
    </DeviceCapability>
    

You are now ready to start developing for Microsoft Band!

The only way (at the moment) to work for the device is to have the device connected to the phone (or tablet depending on the platform) through Bluetooth and installing the application on your phone or tablet.

In the next part we are going to connect to the band and retrieve information about the connected band or bands. (Yes, you can connect to several bands so you could make some rather interesting games or collaboration applications).

  5 Responses to “Developing for Microsoft Band Tutorial part 1”

  1. Do you know if you can use the SDK on a WP background task to periodically retrieve sensor data?

  2. Hi Iris,
    since I did not find anything about this, you are my last hope. 🙂
    I want to access the MS Band from a background task on the phone – this should be possible with the latest version of the Band SDK.
    It requires registering a DeviceUseBackground Task (see: https://msdn.microsoft.com/de-de/library/windows/apps/windows.applicationmodel.background.deviceusetrigger).

    The problem is: This task requires a “DeviceInformation.Id” for the Band but what IS this Device ID?
    The sample code for the band does not use background tasks and I was not able to find anything about it.

    If you have some time for this, thank for your help – if you don’t have time for it, i understand this too, so much ideas for cool apps and so little time *gg*

    waiting for your windows 10 pluralsight course 😉 + greetings from austria,
    Hannes

  3. Hello, I am working on the Microsoft Band to detect gestures using accelerometer and gyroscope and I need your help on this. Please have a look at aka.ms/gestur

  4. Hi Iris,

    Thanks for covering this. It’s pretty hard for a rank beginner to know where to start. I believe your knowledge and guidance will be great help to me.

    I chose the Microsoft Band for the very reasons you seem to like it: it has an exceptional sensor suite, and an API that delivers full access to the same (apparently). However, I think I have hit a snag.

    I obtained a Band via an exporter because it isn’t yet available here in Australia, and it seems I am prevented from downloading the app to my Sony Xperia Z2. (Maybe this is because it runs Android 5.1.1, whereas the Microsoft Band website only claims compatibility is 4.3 to 5.0, or maybe there is no agreement between Sony and Microsoft, or maybe there is a geographical exclusion — I don’t know yet). I was hoping that I could create a Windows application (using 8.1 on my laptop) that would communicate directly with the Band via Bluetooth, but I have been worried that perhaps the Band will only talk to a mobile device. Your advice appears to confirm this. Is this indeed the case? Do you think I should (a) buy another phone, or (b) just continue with my efforts to develop for the Band without a smartphone in the loop, or (c) give up until the Band becomes available to the rest of the world?

    Thanks in advance for any advice you may care to offer!

    — Allen

  5. Hi

    I am looking to develop an app for the band, without having a corresponding mobile app, do you know if this is possible? I have a number of bands, and the intention is to link them to a single tablet as part of a group initiative.

    Thanks
    Emma

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 12 + 8 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)