Integrating physical devices with IOTA — Philips Hue edition

The 14th part in a series of beginner tutorials on integrating physical devices with the IOTA protocol

Hugo Gregersen
Jan 5, 2020 · 7 min read


This is the 14th part in a series of beginner tutorials where we explore integrating physical devices with the IOTA protocol. In this tutorial we will be revisiting the use-case from the first tutorial in this series, where we built a simple power circuit that would allow us to purchase services from a physical device using IOTA tokens. In this tutorial, we will take on the same idea and apply it on top of an existing ecosystem of hardware and software, namely the .

This will be a two-part tutorial where in the first tutorial we focus on integrating IOTA with the popular . In the second tutorial, we will look at smart home devices in general and how we could integrate IOTA with the opensource protocol.

The use case

So, why would our hotel owner choose to implement his IOTA payment system on top of an existing ecosystem like the vs building it from scratch as we did in the first tutorial? Well, the simple answer is “plug and play”. Instead of having to deal with a lot of wiring and microcontrollers, he can now simply go to his nearest electronics store, get all the smart devices (lamps, bulbs, plugs, etc.) he needs and have his new payment system up and running in a couple of hours.

What is Philips Hue?

is an ecosystem of color-changing lamps, bulbs, LED stripes, switches, dimmers, motion sensors, smart power plugs etc. that can be controlled wirelessly from an app or the API. In the center of the ecosystem is the The functions as a common controller for the entire system. The can manage up to 50 Hue devices simultaneously in a mesh type wireless network.

You should be able to get a starter kit with a Bridge and a couple of smart light bulbs for less than 100 USD at your nearest electronics store.

Installing Hue

First of all, before we can move on you have to install your system according to the documentation that comes with the system. It’s pretty straight forward and should not take more than a few minutes.

After you have installed the Hue app on your IOS or Android device, and verified that everything is working correctly, you need to get the IP address of your Hue Bridge.

To get the IP address of your bridge, open the Philips Hue app and go to: , select the (i) icon on your bridge. You will now see some technical details related to your bridge. Make a note of the as we will need it later on in our Python script(s).

Assigning IOTA addresses to Hue devices

The next thing we need to do is to assign a unique IOTA payment address to each individual Hue device. The simplest way of creating new IOTA addresses (including QR codes) is using the Trinity wallet. Make a note of each address as we will need them in our Python script(s) later on.

Next, print the QR code for each address on a piece of paper and attach it to, or place it next to its respective physical Hue device.

Required Software and libraries

A cool feature that comes with the system is that it has its own application programming interface (API), that allows developers like our selves to interface and build new apps on top of the system. And even better, a team of developers calling them self’s studio imaginare have already made a simple Python wrapper around the API called that we will be using in our project.

You will find a github repository with documentation and installation instructions for the library here.

The Code

Now that we have made all the preparations, let’s look at the Python code for this project.

The Python script we are using for this project is basically the same as we used for the first tutorial with some minor adjustments. Notice that there are no longer any references to the Raspberry PI GPIO pins or library, which means that we now can run the Python script(s) from any computer inside the local network.

The Python script(s) are basically just checking the balance for each IOTA address (created in a previous step) every 10 sec. As new funds are being added to an address, the script simply turns ON it’s associated Hue device, using a Hue API call. As time passes, the script continually removes time from a local device balance, switching the device OFF (again with an API call) when the balance is empty.

And here is the Python script:

You can download the script from here

Running the project

To run the project, you first need to save the script in the previous section as a text file on your computer.

Notice that Python program files uses the .py extension, so let’s save the file as
referring to the particular hue device id being controlled by the script)

Next, we need to make some minor adjustments to the script:

  1. Replace the IP address in the b = Bridge(‘’) statement with the IP address of your Hue Bridge
  2. Replace the IOTA payment address with the address you created for this particular device id earlier in this tutorial.
  3. Update the device_id variable according to the particular hue device you are targeting (unless the id=1, then no need to change)

To execute the script, simply start a new terminal window, navigate to the folder where you saved and type:


You should now see the code being executed in your terminal window, displaying the current light balance for device 1, and checking the devices’s IOTA address balance for new funds every 10 seconds.

Pay the light

To turn on a particular Hue device, simply take your mobile phone with the Trinity wallet, scan the associated QR code for the device and transfer some IOTA’s to its IOTA address. As soon as the transaction is confirmed by the IOTA tangle, the device should turn ON and stay on until the balance is empty, depending on the amount of IOTA’s you transferred. In my example I have set the IOTA/device time ratio to be 1 IOTA for 1 second of service.

Managing multiple Hue devices

If you take a look at the Python script for this tutorial you will notice that the script itself is not prepared for managing multiple Hue devices simultaneously. I guess the appropriate way of dealing with this would be to re-write the code to include some type of device list or array that would allow us to manage multiple devices in parallel. Another alternative is of course (as i did) to simply have multiple instances of Python running at the same time. Each instance running its own script with its own device id/IOTA address.

Feel free to make a pull request in the github repository below if you want to take on the challenge of re-writing the script to support multiple devices in parallel.


If you would like to make any contributions to this tutorial you will find a Github repository here


If you like this tutorial and want me to continue making others, feel free to make a small donation to the IOTA address below.


Get Best Software Deals Directly In Your Inbox


Coinmonks is a non-profit Crypto educational publication.

Sign up for Coinmonks

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.


Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project —

Hugo Gregersen

Written by


Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project —

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store