Internet of Things: Microsoft Band Integration into PI

Blog Post created by dconde Employee on Aug 17, 2016



My name is Diego Conde and along with Ana K. Cortes we have worked on this project during a summer internship in the Frankfurt office. We want to thank all the OSIsoft team that made this project possible and especially to our mentors Moritz Foerster and Martin Straubinger.
This project wasn’t only thought as an educational project, but also as useful way to develop a tool for System Engineers and University Recruiting to showcase the PI System with easy-to-understand data during trade shows and at career fairs.

In this post I will introduce the functioning of the “OSIsoft Microsoft Band” application for Android running devices and the Microsoft Band 2.


Let us first take a look at the integration diagram:



First of all, the band sensors read out the data from the user wearing it and perform some other calculations such as calories burned, steps walked, distance covered…. These data will be read from a device running Android API>21 (Android 5.0 Lollipop) and the OSIsoft Microsoft Band app by using Bluetooth technology. This android based App will also read the time on the phone and send all this data every second into the UFL (Universal File and Stream Loading) connector as an https post request as a string with all the incoming data from the sensors.


This data will be parsed in the UFL connector and stored into PI Points.



A sample string sent by the application will look like the one below, and contains information about the timestamp, heart rate, heart rate status(LOCKED/ACQUIRING), XYZ acceleration components in g units, altitude gain in cm (since the Band was last factory-reset), air pressure in hPa, skin temperature in degrees Celsius, calories burned (since the Band was last factory-reset), contact state of the band (WORN/NOT_WORN), motion type (UNKNOWN/IDLE/WALKING/JOGGING/RUNNING), pace  in ms/m, speed in cm/s ,distance in cm, and steps (since the Band was last factory-reset). All these incoming data is explained more in to detail in the “Microsoft Band SDK” attached document.





The PI UFL interface can read text from ASCII files, a serial port, or a POP3 email server, parse and transform the incoming data, and update PI points. To specify how the incoming data is handled, a configuration (INI) file is created, which defines how data is filtered, parsed, manipulated and written to PI.  This “.ini” file is attached and will have to look exactly the same, it’s also configured for non-storing “0” or “null” values that are sent when the app is first launched. In our case these configuration file will create the PI Points.


We also needed a certificate for trusting the incoming data into our UFL running machine from a public domain. In our case we used a Self-Signed Certificate but a Trusted Certificate does work too.



Welcome page:

It contains some information about the app and by pressing on any of the images it will take you to their different websites. By pressing the continue button it will take you to the configuration page.


Configuration page:

It contains some information on how to use the app and the steps to follow.

SUBMIT: Stores the Basic Authentication credentials(USERNAME and PASSWORD), as well as the Host URL specified. (Service cannot be started without).

HEART RATE CONSENT: gives the application permission to access the heart rate data. A dialog will pop up if the band is connected, then press yes. Otherwise, heart rate information will not be accessible.

START: it will start displaying the incoming information from the Band under the sensor’s data, the Sendstring as well as the URL to which the https post request in being sent.



  • In order to install this app (.apk) "installation from unknown sources" must be enabled in the Android Settings > Security > Device Administration> Allow installation of non-official apps, as the app is not published in Google Play Store.


  • In order for the UFL Connector to not receive future data (which will not be stored), date and time on the phone should be the same as the one on the machine in which UFL connector is installed. Go to Settings>System>Date&time.


  • Microsoft Health application has to be installed in the Android device and configured with the Microsoft Band (as shown in the instructions).





In the installation of the PI UFL Connector, the listening port of the UFL Connector has to be specified. By default it is port 5460.

  • Please make sure that the firewall is not blocking that port.



  • Choose to configure or add a new data source. You can name it for example MicrosoftBand.


  • Set "Data Source Type" as REST and enter a "User Name" and "Password" that you want the data source to authenticate with to the PI UFL Connector.


  • Change the Scan Time to 1s.


  • Choose theMicrosoftBandConfigurationFile.ini file that contains the information on how to parse the received string. (File attached)


Save the configuration and start the connector.



1) Enter the same Username and Password that you have specified in the configuration of the data source in the PI UFL Connector.


2) Check the URL that is displayed under "Address" after saving the changes in the configuration page of the data source in the PI UFL Connector.

       Make sure to use the domain name that is public and can be reached via REST call. Hostname is probably not public.







5) Hit START


Data collection should be started if everything has been well configured. And the app should display something like these:











I have attached a PI system Explorer Database with some Analyses and Event Frames that we created for giving some actual meaning to the incoming data, please feel free to modify it yourself or ask me any questions about it. This Database is attached as an .xml file. You can import it in your own Database in the File tab > Import from File.


Microsoft Health Android App: https://play.google.com/store/apps/details?id=com.microsoft.kapp


Microsoft Band SDK: https://developer.microsoftband.com/content/docs/microsoft%20band%20sdk.pdf


UFL connector download link: https://techsupport.osisoft.com/Downloads/All-Downloads/All-Groups/All-Products/All-Categories/Current-Version/UFL


How to create a Self-Signed Certificate and add it to trusted certificates (Source: Creating Self Signed Certificates with PowerShell, http://windowsitpro.com/blog/creating-self-signed-certificates-powershell)


Rather than using Makecert.exe, PowerShell can also be use for this purpose.

First - you need the Fully Qualified Domain Name (FQDN) that you want to use for the certificate. For example, microsoftband.mydomain.com.


You then use the command:


New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname microsoftband.mydomain.com


Running that command will add the self-signed certificate to the local certificate store. When you run the command, you'll also get a certificate thumbprint that will look something like:




If you go to IIS (Internet Information Services)>YourMachine>Server Certificates you should find it there.


Now you need to add it to the trusted certificates:

You can do this in the Microsoft Management Console (MMC), use the keyboard shortcut Windows+R or go to Windows>Windows System>Run, type mmc and then click on OK. Now go to File>Add or Remove Snap-ins. On available snap-ins select Certificates and then click Add. When this window pops up select
Computer account.

Click on Next.


And Finish. Then click on OK. Now these should be displayed.


Go to Personal>Certificates, choose the certificate you just created and copy it and then paste in the Trusted Root Certification Authorities>Certificates. Go to File>Save. The self-signed certificate should be working now.


Next step is to bind to the PI UFL connector, this is explained in the following KB Article.


KB01421 - How to change the SSL Certificate bound to a PI Connector (ANY) Administration page (port): https://techsupport.osisoft.com/Troubleshooting/KB/KB01421