The Use Case

Before going into details on building this project we should take a step back and look at the bigger picture as to how a simple demo project like this could be applied to a real world use-case, solving real problems.

Imagine you are staying at a hotel where each room is equipped with its own refrigerator. In most cases these refrigerators just sits there, consuming energy and not being used, still you end up paying for it indirectly as part of the rent. What if there was a mechanism that would allow you to pay the refrigerator directly for the time it is being used, and at the same time have it automatically turned off when it’s not being used? This is basically the use case we are going to recreate on this tutorial, only difference is that we will be replacing the refrigerator with a LED for convenience and safety.

Now, let’s try and describe a sequence of events to demonstrate how the system can be implemented and used.

First, let’s imagine the hotel owner has installed a refrigerator in your room, placing a relay in the refrigerator power circuit. The relay is then connected to the internal GIO pins on a Raspberry PI serving as a control unit for the refrigerator payment system. Next, he creates an IOTA address for the refrigerator to be used for monitoring when new refrigerator funds are being added. Finally, he prints a QR code of the IOTA address and attaches the QR code to the refrigerator.

Now that the physical part of the system is completed, he creates a simple Python program that runs on the Raspberry PI, continuously checking the refrigerator IOTA address for new funds, switching the refrigerator (relay) ON/OFF accordingly.

Now image you as the guest coming back from shopping having bought a nice bottle of white wine for later that evening. To make sure it stays cool you pick up your mobile phone, open your favorite IOTA wallet, scan the QR code attached to your refrigerator and transfer a certain amount of IOTA’s to the refrigerator depending on how long you plan to use it.

As soon as your transaction is confirmed by the tangle, the refrigerator balance is increased and the change in balance is picked up by the Python program running on the PI. The PI will then switch on the relay using its GIO pins and the refrigerator will turn on.

The Python program will keep track of time used and the amount of IOTA’s you transferred, continuously removing time from your active balance, and finally turning off the refrigerator when your balance is empty.

That’s it… Finally, you enjoy a nice bottle of cool wine before hitting the town.

Note!

In a scenario where you want to control multiple devices using the same setup it would probably be better to have a central Raspberry PI functioning as a common control unit for all devices, where each device is assigned its own unique IOTA address.This can easily be achieved using a multi-channel relay with some slight modification to the Python code. To simplify wiring and coding we will manage only one device in this tutorial, but feel free to extend the project later on to manage multiple devices.