WinCoder Blog

Use the Force – Biofeedback Heart Monitor with Particle Photon and Microsoft Band


Today’s hack is an inspired submission for’s Are you an IoT Jedi? Join the Particle Alliance! contest.  The idea around the contest is to build something cool in the realm of Internet of Things using any of the amazing devices from  Having deep familiarity with Particle development and being an avid fan of the Star Wars Universe, this is an awesome opportunity to build something cool and possibly win some cool prizes in the process!

In this post, I plan to explain the creative process that lead to my idea, the serendipitous findings that ended up making it more interesting than I had originally planned, and of course the steps to reproduce the project on your own!

This project will introduce you to the concepts of toy hacking / modification, sourcing hardware components at reduced cost, Universal Windows App / Microsoft Band development, and proxy of communication between external sensors (Microsoft Band) and Particle devices using Particle.function().  Keep in mind, if you do not have access to a Microsoft band, there is a sub-project within this project that will allow you to create a modified lightsaber with programmable LEDs.  The end result will allow us to monitor heart rate visually on a modified Lightsaber using sensor data from a Microsoft Band.


When I saw the initial announcement of’s Are you an IoT Jedi? Join the Particle Alliance! contest, my first instinct was to do something related to the iconic lightsaber.   If you have seen the official trailer for “The Force Awakens“, we see the introduction of a new cross-shaped red-glowing lightsaber wielded by the villainous Kylo Ren.  I really wanted to include this iconic item into my hack, but how?

My initial idea centered around building my own lightsaber, which would have been cool.  However, there are numerous groups literally dedicated to this practice and the costs can be a bit prohibitive for some hobbyists / makers.  After attempting to construct something from inexpensive parts at the local Home Depot, I eventually gave up as nothing I could create looked convincing.  Knocked out, but not defeated, I also had to consider, how does one practically introduce a lightsaber into the Internet of Things, especially in a accurate and usable way?

To gather further inspiration, I started perusing the Particle Platform section on  To my delight, I came across a project by Barry Nusz for displaying your heart rate using a Particle device and Microsoft Band.  Then the inspiration hit me like a ton of bricks.  I could monitor my heart rate from the lightsaber, perhaps while throwing up weights at my local crossfit gym (Shout out to Alief Crossfit).

But… this would not be the end all of the idea, nor the peak of it’s usefulness.  As with many creative hacks, some of the best features appear after building for a specific use case and presenting to others.  Little did I know, I was about to get a serious lesson in real-life manipulation of the Force, or at least conscious control of a usually unconscious body function.

While showcasing the final build of this project at this year’s CodeMash conference, an attendee and partner at our booth (Mitch Muenster) made mention that he could control his heart rate consciously.  Initially, I was in disbelief and asked for a demonstration.  The skeptic in me then asked for about 50 more demonstrations to rule out any sort of foul play or miscalibration.  After exhausting my disbelief (and Mitch for that matter), I realized I had haphazardly constructed a mechanism that could be used to train individuals to control their heart rate using a scientifically validated method known as biofeedback.  See Mitch’s article on this project for a bit more information.



What might be the purpose of building a Biofeedback Heart Monitor?

First let’s explain what exactly Biofeedback is:

When you raise your hand to wave hello to a friend, or lift your knee to take another step on the Stairmaster, you control these actions. Other body functions — like heart rate, skin temperature, and blood pressure — are controlled involuntarily by your nervous system. You don’t think about making your heart beat faster. It just happens in response to your environment, like when you’re nervous, excited, or exercising.

One technique can help you gain more control over these normally involuntary functions. It’s called biofeedback, and the therapy is used to help prevent or treat conditions, including migraine headaches,chronic pain, incontinence, and high blood pressure.

The idea behind biofeedback is that, by harnessing the power of your mind and becoming aware of what’s going on inside your body, you can gain more control over your health. – Source

And here is a quick bit on how it works:

Electrodes, which look like stickers with wires attached to them, are placed on the client’s skin. The client is then instructed to use relaxation, meditation, or visualization to bring about the desired response, whether it be muscle relaxation, lowered heart rate, or lower temperature. The biofeedback device reports progress through a change in the speed of beeps or flashes, or pitch or quality of the tone. The results of biofeedback are measured in the following ways:

  • skin temperature
  • electrical conductivity of the skin, called the glavanic skin response
  • muscle tension, with an electromyograph (EMG)
  • heart rate, with an electrocardiograph (ECG)
  • brain-wave activity, with an electroencephalograph{EEG) – Source

Essentially, the idea is that by making an unconscious body function, such as heart rate, consciously detectable through sound, light, or other stimuli; one can achieve a level of control over these functions.  Some real-life mastering of the Force if you will =)

Applications of this technique have been cited in various scientific journals:


The Food and Drug Administration has approved a biofeedback device, Resperate, for reducing stress and lowering blood pressure. Resperate is a portable electronic device that promotes slow, deep breathing.

However, many biofeedback devices marketed for home use aren’t regulated by the Food and Drug Administration. Before trying biofeedback therapy at home, discuss the different types of devices with your doctor to find the best fit.

Be aware that some products might be falsely marketed as biofeedback devices, and that not all biofeedback practitioners are reputable. If a manufacturer or biofeedback practitioner claims that a biofeedback device can assess your organs for disease, find impurities in your blood, cure your condition or send signals into your body, check with your doctor before using it, as it might not be legitimate. Source



Note: The pieces above will allow you to create the first part of this hack
(Modified lightsaber with programmable LEDs)

To build the full Biofeedback Heart Monitor you will also need:


  • Soldering Iron
  • Solder
  • Electrical Tape
  • Wire Strippers



 Sub-Project #1 – Building a Modified Lightsaber with Progammable LEDs:


1.) Obtaining a Lightsaber casing

I opted to use a Kylo Ren LightSaber Room Light Kit from Milton Toys (which is actually a pretty sweet toy on it’s own).  Keep in mind, you do not necessarily need this ‘exact’ toy if you are interested in replicating this project.  You may be able to adapt a similar toy, for example any of the options available through Hasbro’s Blade Builder line or you could opt for some of the high-end custom parts available from UltraSabers.  If you want a 100% DIY solution, there are a variety of projects that focus around creating a lightsaber using PVC components.



You will want to ensure that your chosen form factor is capable of housing your Particle Photon, which will be used in later steps.

Particle Photon Dimensions and Weight

Headers Dimensions in inches (mm) Weight
With 1.44 x 0.8 x 0.27 (36.58 x 20.32 x 6.86) 5 grams
Without 1.44 x 0.8 x 0.17 (36.58 x 20.32 x 4.32) 3.7 grams


2.) Fitting and Powering a Photon within your LightSaber

I began by taking apart the blade handle from the Kylo Ren Room light kit and removing all unnecessary components.  I knew I would not need the stock electronic components as they would be replaced with a much cooler Particle Photon.  This is a good time to measure wire by laying it against the blade casing to get a good estimate of how long my wire would need to be for installing the LEDs.


The Photon device will require 5v, which you can achieve using a micro-USB cable or a battery source.  I wanted to create a fully contained solution I sacrificed a Particle Core micro-USB cable to create a short ~5 inch cable that could be fit inside the housing.

Creating the shortened cable is straightforward, simply sever the wires, then connect them back to the way they were originally using solder and electrical tape to seal it up.



There was a plastic piece within the kit that was necessary for connecting the blade ends that also housed the electronics.  While necessary, it took up a bit too much space.  To accommodate, I sawed off the portion containing the electronics to make room for my battery (Notice section where brown, black, and white wire enter).


At this point, you should be able to power the Photon device and keep everything nice and snug within the blade housing.


3.) Sourcing and Wiring Up LEDs

We know we want color options and we want to control them with code.  This means we need individually addressable programmable LEDs, often referred to as “NeoPixels”.

I had the foresight of checking the Particle libraries to confirm that there was support for the popular “NeoPixel” brand of programmable RGB LEDs before taking on the project.  While perusing the source code, I noticed that the library supports the WS2812, WS2812B and WS2811 LED specifications.  This means, we can technically source any of these the named LED components for a low-cost 100%  library compatible solution.  I opted for the WS2812B although the steps should be similar for the other listed components.


After obtaining your components (hint: eBay and Amazon). you will want to peruse your favorite search engine for “<Component> Spec Sheet”.  The WS2812B spec sheet can be seen below:


We can glean everything we need to know for connecting these LEDs using the information contained above.

  1. There is a notch on the face of the LED which marks pin 3, knowing this and using it’s relative orientation, we can deduce the location of the remaining pins 1, 2, and 4.
  2. PIN function is described in the lower table, Pin 1 is Power, Pin 2 sends Data Signal Output, Pin 3 is Ground, and Pin 4 receives Data Signal Input.
  3. We can daisy chain multiple LEDs by connecting Pin 1 to Pin 1 of all LEDs and Pin 3 to Pin 3 of all LEDs to power each LED in series.  We will connect Pin 2 (DOUT) to Pin 4 (DIN) to maintain data communication between all LEDs.

It is suggested to test by wiring a single LED up to the photon and verifying that it can be controlled by the Photon using one of the NeoPixel Library examples before proceeding.

Here is the full wiring for our project diagram:



The assembly should look similar to the following.  Notice that I am soldering directly to the LED solder pads, these are very small and require detail to ensure there is no electrical short.  Be sure that the end result fits in your casing and string it through appropriately as indicated in the pictures.


20160108_124213 20160108_124316  20160108_12422420160108_124237

With everything wired up, you can now flash the LightSaber Light Show code to your Photon device!


Sub-Project #2 – Building a Biofeedback Heart Monitor:

In this next segment of our project, we will leverage our modified light saber to control the LEDs using sensor data from a Microsoft Band.  This will give us the ability to see our heart rate, through a visual pulse and color indication.
We will discuss deploying the code to a Windows 10 device and updating the Particle Photon code in this section.
The client Code for this project is packaged as a Universal Windows Project along with a legacy Windows Phone 8.1 project.  The Universal Windows Platform allows us to use a single codebase across theoretically any device capable of running Windows 10 and meeting the requirement of Bluetooth connectivity.  It has been tested on Windows 10 Desktop (Surface Pro 3), Windows Phone 10 (Lumia 1020).

Note:  Raspberry Pi 2 running Windows IoT Core does not work at this time due to a failure when calling “bandClient.SensorManager.HeartRate.RequestUserConsentAsync()

1. ) Ensure that you have installed:

2.) Pair your Microsoft Band to your PC or Phone running Windows 10


  1. ) On Band : Settings => Bluetooth => Pairing
  2. ) On Device : Settings => Bluetooth => Add Device
  3. ) Follow on screen prompts on Device to successfully pair

3.) Grab the Windows 10 Device Code from: 

4.) Open the WP10PhotonHeartRate Solution

5.) On lines 32 and 33, you will want to find and modify the PHOTONDEVICEID and ACCESS_TOKEN properties


6.) Obtain the PHOTONDEVICEID @  => Devices => Select <YourDevice> => Click to expand => Copy <DeviceId>


7.) Obtain the ACCESS_TOKEN @  => Settings => Copy <Access Token>


8.) Deploy to your Device and you should see the program start


9.) Deploy the following Code to your Particle Photon:

10.) With your Lightsaber assembled, Particle Photon Powered, and and the appropriate code Flashed to your Photon, click “Run” to begin collecting Data from the sensor.  You should see the LEDs begin to pulse according to the heart rate.


How it all works:

The Particle device listens for “function call” events in the Particle Code when we define:

bool success = Particle.function(setRGBHR, setRGBHR); 

Meanwhile, on the Win10 Device Client side we publish the current heart reading from the Microsoft Band to the Particle event in the SetRGBHeartRate method of our Win 10 client code.

A few conversions happen along the way to determine the time between pulses and the current color of the LEDs.

More information on the Particle.function method can be found in the Particle Documentation.







This project was very exciting, mainly due to the facets of creativity involved and the accidental discovery of what ended up being the main use case.  Outside of the contest parameters of “Use a Particle Photon” and “Fit a Star Wars Theme”, the space was pretty much wide open to build anything.  Starting with a lightsaber and some LEDs, I wound up stumbling into the subject of biofeedback.  I haven’t personally developed the ability to control the Force (errr, heart rate), with this device, yet…  But, it was all too awesome to run into someone who could.  In fact, since revealing the concept to a few friends, I have found that controlling heart rate consciously is a bit more common than I though.  To date I’ve found three more friends who can control it up or down on command.  It’s pretty wild to see in person!  Maybe it isn’t a surprise that the end result was cool when you consider the contest rules.  After all, it is Star Wars season and it was all too fitting of a contest to occupy my tinkering time during the holidays.  It also gave me a good excuse to purchase one of the awesome toys that have popped up around the franchise.  Hacking + Star Wars, you can’t really go wrong with that =)

Until next time, Happy Hacking!

Leave a Reply

Your email address will not be published. Required fields are marked *