Internet of Things – Wearable Business Intelligence

Today I will show you how components connected to a wearable can be controlled from the cloud via a mobile phone. I will do this by showing how a CIO could wear an indicator of the overall status of his company’s IT systems.

Most companies have a dashboard indicating the overall status of their IT systems. It usually includes a number of metrics, or KPIs, but basically boils down to an overall indicator showing if everything is fine. Putting that indicator on the CIO would be a great way for him or her to show that (most of the time) the IT systems are operational. When there’s a problem, it would also be a clear signal to everyone that this is something the CIO is working on fixing.

Let’s create a simple iPhone app that subscribe to an MQTT broker and set the color on a RGB LED connected to a wearable. To do that you need an iPhone 4S or later as well as register as a paying iOS developer (you can enroll at https://developer.apple.com/programs/ios), and you need a Lightblue Bean (www.punchthrough.com/bean, and to simplify connections, it’s a good idea to add headers to it). You also need an RGB LED (I used one with a common cathode), and to connect everything, you need a breadboard, three resistors (two 10 ohm and one 68 ohm), and four jumper cables.

To setup the hardware, you start by disconnecting everything from its power source, and then connect the GND on the Lightblue Bean to the second (longest) pin of the LED. Then connect the Bean’s pin 1 to the LED pin 4 (blue) over the 10 ohm resistor, the Bean’s pin 2 to the LED pin 3 (green) over the other 10 ohm resistor, and the Bean’s pin 3 to the LED pin 1 (red) over the 68 ohm resistor.

The code for the iPhone app is almost identical to the one in my previous video (called “Internet of Things – Wearable Actuators”), so please check that out for details. The only difference is that line 29-33 in ViewController.m is now replaced by the new line 29…

29: dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.bean sendSerialString:message.payloadString]; });

…and it sends the color code as a serial string to the Lightblue Bean.

To pick up that value, the Lightblue Bean is running the code (sketch) shown here…

…and first the variables are defined, like the pins for the three colors (on lines 1-3). In the setup, we initialize the serial communication (on lines 11-12), and set the color pins to output mode (on lines 13-15). The eternal loop starts by checking if there is any serial content (on line 21), and if so, each color value is extracted from the string (on lines 26, 28, and 30), and the color pins are set (on lines 27, 29, and 31).

When you have deployed this code to the Lightblue Bean and run the code on the iPhone, the only thing missing is the server-side code that publishes the correct color depending on the IT system’s status. I will not show that part here, but you can simulate the operational status by publishing to the topic by opening the terminal, and enter the command below:

curl -X POST --data-binary "ff0000" http://eclipse.mqttbridge.com/chris%2fpocket%2fled

That’s how components connected to a wearable can be controlled from the cloud via a mobile phone.