Internet of Things Insights Dashboard

Following on from the previous article about setting up the Raspberry Pi's, Robot and the Bluemix IoT Foundation Service, this article will show you how to use the IoT Insights service to visualise the captured data and to create Actionable events based on the data.


Decide if the Lite version is sufficient for you (it allows up to 25Mb a month, which is quite a lot for developing/testing with).  You do not need to bind it to anything at the moment as we'll hook it up in the settings later on.

After pressing [CREATE], the service will start and you will be shown the Dashboard.  Select to [Add a data source]:

This will open up a different Dashboard - you'll immediately tell because the colouring will change.  Select the [Add New Data Source] link, this will make the slide-in appear on the right-hand side of the screen.  Here you can enter the details of your IoT Service (if you cannot remember them, go back to the Bluemix Dashboard, select Services and click on the IoT Service to see the org/api key and auth-token value)
Once you have finished this, you will see that a new Data Source has been created and that it can connect to the IoT service:
The next step is to add a Schema.  You do this by selecting the 'Manage Schemas' tab and select the [Add new message schema] link:
Once you do this a pop-up dialog will appear, give it a name for the Data source, you'll notice that the 'Device type' will be pre-populated with the Types from the IoT service.  I selected 'raspberryPi' and I left the 'Event' as '+' to collect all the events.
After linking the Data Source, we now have to 'Add data points', again, we can select the dropdown and there is a setting 'Add from connected device' - this automatically connects to the devices and will show the data we can pick from:
I selected to include all of the data:
Once we have finished, you will see that the new Schema is shown:

That sorts out the definition of the Data Source and what Data we are actually concerned with from the Devices, we now need to do something with that data.  I want to create a new Rule that will perform an action if some of the captured data is beyond a certain value, to do that we need to perform the following steps.


We now select the 'Analytics' tab and select 'Add new rule':
We are asked to Name the new rule and add an optional Description.  Select the Message schema that we created earlier:
When you press [Next] you'll notice that the User Interface changes to quite a funky layout that will allow you to make up some simplistic rules:
To define the 'Condition' we need to click on the 'New condition' box, this allows you to select which 'data point' value you want to use and select a simple 'Operator' and what value you want to compare it to.  I want to create the logic of "If the CPU Temp is greater than 46 then....":
Once you've pressed [OK], we move onto defining the 'Action' that we want to happen when that 'Condition' is met.  Click on the 'New action' box and then select the 'Add action' link:
You can select what 'Type' of Action you want to happen from the dropdown, I have selected 'Send Email' and I have populated the values with my email address etc... and a subject line that is distinct:
Now, here's a slight oddity (that will most likely be fixed by the time you read this), after pressing [OK] you will be shown this screen:
As you can see the 'New Action' is listed on the right-hand side, BUT, it has not been added as the 'New Action' to happen after the 'Condition' has been met.  Make sure you pick it before you press [OK].  You'll know you've done it correct because it'll look like this:
Once that is done, you will be shown the new 'Rule' and you need to select the little gear icon and select to 'Activate' the rule:


Select the 'Dashboards' tab from the top menu.  You will be shown the Default Dashboard in the 'Overview' tab.  Now, you could select 'Browse Dashboards' and create a new empty one for yourself, but I have decided to just add a new chart into the 'Alerts Dashboard'.
This is what the default Dashboard looks like, as you can see it shows a list of the Devices that could trigger the Alerts (notice it is only listing the 'raspberryPi' types):
Now, select 'Add new component', the 'Dashboard Editor' will be displayed on the right-hand side, select 'Realtime chart', then 'Add line to chart'.  This will open up a dialog to the left where you can 'Select a device...', you can see the list of devices displayed on the left-hand side, displaying the device Ids.  As shown, I select a device with the Id of '111' (as I happen to know that one is transmitting data):
After selecting the 'Device', you can 'Select a parameter', this is where you get to pick what data you want to display on the chart itself.  I'm interested in the CPU TEMP, so I select that value:

Once you've done this, the chart will be embedded to where you originally clicked on the Dashboard.
If you now click on it, you'll see a little gear icon appear, but, when you click again, a message will be shown stating 'The dashboard is not editable'.  Oh no!  Our new chart is embedded inside another component and we cannot edit/move it?....

It's not all doom & gloom though!  If you select the 'Browse Dashboards' tab, select the little gear-icon and then change the 'Modifications' setting to 'Editable' and press the green tick, we should now be able to make changes:
Now, when we go back to the 'Overview' tab we can click on our new 'Component' and are able to edit the layout:
After a bit of artistic re-designing, we can now have our chart displayed in a nice section in the top middle of the Dashboard:
Once happy, select the green tick to save the layout.

The end result is a LIVE custom chart plotting and showing the live data coming from the Raspberry Pi as shown here:

You can double-check the devices that are available, by selecting the 'Devices' tab and the 'Browse Devices' sub-tab:
As you can see, the Robot1 device 'type' is not configured to provide the data that we have defined in our Schema.  You can see that we have 1 'Connected' device and 2 devices that are not connected.  This is indeed true!

There we have it, in the previous article we setup the IBM Bluemix IoT Foundation Service, we setup the Raspberry Pi's to gather data and send it to the IoT Foundation Service via the MQTT protocol.

In this article, we have shown a simple way of creating an IoT Insights Service to visualise the live data being sent from the IoT connected devices.

I assure you, this is just a starter on the IoT journey, I have a huge number of idea's that can extend this architecture further and I'm sure a LOT of other people will be doing the same and along the way services such as Bluemix and the IoT services will help this along the way (and the bit I REALLY like, is the minimal amount of coding that was required to achieve what we needed)...

No comments:

Post a Comment