Skip to Content

Internet of Things (IoT) Viewing your Tessel data from IoT Services

Previous

Internet of Things (IoT) Viewing your Tessel data from IoT Services

By Craig Cmehil

Now it is time to display your stored data from your Tessel device

You will learn

Now that you have data stored in the system its time to display that data within an application. To do that you need to create a new application that can interface with data service and display the data our device has been generating. What you will find next are the steps necessary to do just that. You will need your Eclipse environment setup, basic knowledge in using Eclipse as well as GitHub set up and some basic Java programming skills. It will also assume that you have already connected your Eclipse environment to your SAP Cloud Platform trial account.
For more information on that please see tutorial

Details


Step 1: Open Eclipse

Open Eclipse and first switch over to the Git Repository Perspective.

git perspective
Step 2: Clone Git repository

Choose “Clone a Git repository” using the following URL
https://github.com/SAP/iot-starterkit.git which is the SAP official IoT Starter Kit.

Clone repo
Step 3: Select master branch

  1. Select master then next.
Clone repo
Step 4: Choose directory

Choose your directory location then finish

Clone repo
Step 5: Import projects

Select the repository at the highest level, right click, and select Import Projects.

Step 6: Edit index file

Once that has finished you will need to open your index.html file and make some small modifications. You will find this file in the following directory.
iot-starterkit/src/apps/java/consumption/com.sap.iot.starterkit.ui/src

For starters you will need to change your settings to match your newly connected device.

oSettingsModel.setData({
"deviceId" : "dcc6d8b5-fec2-43a2-96be-1a85b0a1912b",
"deviceTypeId" : "a87bb50d9b3789aa4c2f",
"fromDeviceMessageTypeId" : "1",
"toDeviceMessageTypeId" : "2",
});  

Don’t remember just go back to your iotmms application and you can get them from there. Once you have that in place you will need to adjust the graph settings to match the values of your message type as well as your data values, change Slider Value to Temperature F.

function createMeasureFeed() {
return new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid" : "primaryValues",
"type" : "Measure",
"values" : ["Temperature F"]
});
}  

Now change Slider Value to Temperature F, and add in your column name.

function createDataSet() {
return new sap.viz.ui5.data.FlattenedDataset({
dimensions : [{
		name : "Timestamp",
		value : {
			path : "sensor>C_TIMESTAMP",
			formatter : function (oValue) {
				//can be a string primitive in JSON, but we need a number
				if ((typeof oValue) === "string") {
					oValue = parseInt(oValue);
				}
				//ensure that UNIX timestamps are converted to milliseconds
				var oDate = new Date(oValue * 1000);
				return oDate.toLocaleString();
			}
		}
	}
],
measures : [{
		name : "Temperature",
		value : "{sensor>C_TEMPERATURE}"
	}
],
data : {
	path : "sensor>/"
}
});
}
Step 7: Build the project using Maven

Now in Eclipse, build the project using Maven. If you don’t have Maven, click on Help install new software. In the Work with line, start typing eclipse.

Step 8: Open Collaboration

Open Collaboration, and look for m2e-Maven Integration for Eclipse

Step 9: Accept terms

Then click next, next, agree to the terms, then finish.

Step 10: Build the project using Maven

In Eclipse, build the project using Maven. Click on the project name in the project explorer, right click Run As Maven Build (your screen might look different than this)

Run As

iot-starterkit/src/apps/java/consumption/com.sap.iot.starterkit.ui

Clean Install

For the goals, enter clean install

Step 11: Deploy applications from SAP Cloud Platform trial accoun

Now jump back over to your SAP Cloud Platform trial account Cockpit and choose Java Applications then select the Deploy Applications.

Deploy Applications
Step 12: Deploy was file

Find your .war file, give it a name and click deploy. When it has been loaded, click Done (not Start)

Step 13: Import file

Back inside of Eclipse, find the iotmms file in the destinations file. You are going to import that into the HCP. Modify the file so that it uses your account.

destination file
Step 14: Choose destinations

Now in the SAP Cloud Platform cockpit select your new application under your Java Applications then choose the Destinations.

destinations
Step 15: Import the file

Click on Import From File, and browse to your file that you’ve created.

Import
Step 16: Add your password

Add in your password. Save the entry. Stop the application and restart.

Step 17: Select data bindings

Now select the Data Bindings

Step 18: Change the Schema ID

Leave the Data Source as default and change the Schema ID to your iotmms (XXXX.iotmms.web) and click save e.g. pXXXXXXXtrial.iotmms.web

Bindings
Step 19: Click start

Click on Overview, and click the Start button under State. This will take a minute or two.

Bindings
Step 20: Click the URL

When it has started up, click on the URL that is under Application URLs.

BindingsBindings

Next Steps

Updated 10/04/2017

Time to Complete

20 Min.

Beginner

Prerequisites

Next
Back to top