Connecting HoloLens with IoT

Yifei Yin
2 min readApr 21, 2017

--

Accompanying the last post on Arduino to Unity, this one can be universally applied to all remote devices that have the capability of reading data from a server.

Setup your IoT device

Your IoT device should be able to publish data that HoloLens can access. I am using Particle Photon for this since it comes with the Particle.variable method that is easy to use and access.

In setup, call: Particle.variable(“variableName”, variableValue);

The variable will be published onto a link like this:

https://api.particle.io/v1/devices/deviceID/variableName?access_token=AccessToken

a. Find your device ID:

In the Particle Dev, show serial monitor and input i.

The device ID will be returned.

b. Find your access token

In the Particle IDE, go to settings and you can see your access token.

So in the end your link will look like something like this:

https://api.particle.io/v1/devices/310020000b51323432383931/variableName?access_token=df43a6ada43611342c90e3d2c64b920a17f8xx69

For more information on Setting up a photon to the internet, check this out.

Detailed Documentation on the particle.variable method:

Unity Scriptings

Now you get the link, you can use UnityEngine.Networking, the StartCoroutine method and the JSON object Unity plugin.

using UnityEngine.Networking;
public Coroutine StartCoroutine(IEnumerator routine);

Here is a code sample with detailed comments:

Build and deploy to test

Make sure in the player settings, you have internet server client capability enabled.

Menu -> Build Settings -> Player Settings -> Publishing Settings -> Capabilities -> InternetServerClient

Happy building!😌

--

--