Visualizing Sensor Data using Intel Internet of Things (IoT) Analytics

Last week, I published an article on Smart Maraca that covered the journey of data from a sensor, to the cloud, to a web application. The article received more interest than I was expecting. Sameer Khandekar asked if I can use Azure instead of Amazon Web Services (AWS). My knee-jerk response was — “Sure, Azure has Event Hubs and Stream Analytics, so it wouldn’t be difficult.” For those of you who are new to these, Event Hubs is an Azure web service for ingesting stream data and Stream Analytics is another Azure web service for real-time processing of the stream data.

I must admit, it was not as easy as I was hoping. I could not find client libraries for Event Hubs in the Azure SDK for Python, Node.js or Java. I was able to find API support for Event Hubs in the Azure SDK for .NET. However, it felt like an unnatural act to get .NET code running on Intel Edison for a simple task of streaming data to Azure; especially when the Edison was running Yocto — an embedded Linux distribution.

I was not ready to give up so easily though.☺After a bit of searching, I came across Intel IoT Analytics (currenly in Beta)— a web service that enables collection and analysis of sensor data provided using Intel IoT Developer Kit. I gave it a try. It involved two steps — registering for the service and streaming data from the device. Both the steps were straightforward. In a short time, I was able to simulate streaming temperature data from Intel Edison and visualize it on the IoT Analytics dashboard:

Web console for Intel IoT Analytics showing a temperature chart for data sent by Intel Edison

Interesting, right? Let’s look at what was involved in each of the two steps:


Registering for IoT Analytics was as easy as it can get. Literally, it involved nothing more than signing in with my Google account and specifying a name for the IoT Analytics account being created. No credit card and no forms to fill. I was on the My Dashboard page of the web console in no time:

My Dashboard page of the web console for Intel IoT Analytics


Streaming from Intel Edison was also easy. I simply followed the instructions from the user guide. At a high level, it involved three tasks — activating the device, registering a temperature component, and submitting the data.

The Yocto image for my Edison had the iotkit-admin tool pre-installed. Here is how the help for the tool looks like:

Help for iotkit-admin tool


First, I activated my Edison using iotkit-admin activate <activation_code> command. It required an activation code that I got from my IoT Analytics account. The activation process creates a device record in the cloud, associates the device with the account (where the activation code came from), and provides the device with security credentials.


Next, I registered a component with my Edison using iotkit-admin register <comp_name> <catalog_id> command. A component is a time series that consists of sensor observations sent from the Edison. So if I want to send temperature data, I would need to register a temperature component. Each component is required to reference a component type within the account catalog. Think of component type as a template for the component — you define the details of the time series once instead of defining it for every device. Each account in IoT Analytics comes with three default component types — humidity, power, and temperature. Since I wanted to send temperature data, I registered the temperature component with my Edison using iotkit-admin register temperature temperature.v1.0 command.

The following screenshot shows three commands — the test command tests the connectivity of the Edison with the IoT Analytics service, the catalog command lists the components that are available for registration, and the components command list the components that are currently registered with the Edison. As you can see, a component labeled temperature shows up in this list because I had registered that component with my Edison.

Three iotkit-admin commands — test, catalog, and components


Finally, I was ready to submit temperature data. I wrote a small Python program that issued iotkit-admin observation <comp_name> <value> commands. Every minute, it randomly selects a number between 15 and 25 (temperature in Celsius) and sends it as a value for the component labeled temperature. Here is how the code for looks like:

# Program to run on Intel Edison to send temperature data to Intel IoT Analytics
# Shon Shah — Feb 21, 2015
import random
import subprocess
import time
while True:
# Generate a random number between 15 and 25
temp = random.randint(15, 25)
# Use Intel’s iotkit-admin tool to send the temperature
print “Sending temperature”, temp, “degree celsius…”

output = subprocess.check_output ([“/usr/bin/iotkit-admin”, “observation”, “temperature”, str(temp)])

print output
# Wait for one minute
print “Waiting for one minute. Press CTRL+C to stop…”
time.sleep (60)

Here is a sample run of

Sample run of a Python program that simulates sending temperature data to IoT Analytics using iotkit-admin tool


To begin with, I wanted to figure out how to use Azure instead of AWS for visualizing sensor data coming from Intel Edison, but ended up using Intel IoT Analytics. This was primarily because I could not find Azure SDK support for Intel Edison. Until Azure SDK for Python, Node.js or Java includes support for Event Hubs or until Windows can be run on Intel Edison, AWS or Intel IoT Analytics seem to be the viable options. The thing that I liked about Intel IoT Analytics is that it did not require any additional effort on my part to plot the temperature data on a chart.

— Shon