It is one of many examples of different devices supplying environmental sensor data (temperature, humidity) to SAP Cloud Platform (SCP). Here Tessel 2 device is used. Sensor data will be send synchronously using HTTP REST protocol.
Prepare your Tessel 2 deviceMake sure your went through Tessel's Climate tutorial http://tessel.github.io/t2-start/modules/climate.html prior to continuing with this project.
Make sure you have free developer account in SAP Cloud PlatformIf you do not, please follow this tutorial first: https://www.sap.com/developer/tutorials/iot-part6-hcp-services.html
Configure virtual device for Tessel 2 in SCPFollow the tutorial https://www.sap.com/developer/tutorials/iot-part7-add-device.html and then create a separate virtual device for your Tessel 2. Instead of "myDevice" you can call it "tessel2".
Note down technical ID of this tessel2 virtual device and its assigned authorization token.
Modify the codeModifying the attached JavaScript code provided below, you will need to add in your Message Type ID, Device ID, etc.
The lines in particular you will need to modify are the following:
var accountOwner = '<your account user>';
var messageTypeID = '<message type>';
var deviceId = '<device id>';
var authToken = '<auth token of the device>';
You should modify: - The accountOwner
line to add your own SAP Cloud Platform Account User ID which starts with either an S
, P
, I
, D
or C
.
- The
messageTypeID
is the ID of the message type you created, and not the name of the message type.
- The
deviceId
is the ID of the device you created, not to be confused with thetoken
- The
authToken
line contains the token of the device (not the device type!). You received it in the pop-up window after creating your device. But if missed it, then regenerate this token from Device screen once again.
Save the file as scpiot_neo_tessel2_http.js
Run the code and check the resultsOnce you have saved your file, you will deploy and execute it from the command line (Windows) or terminal (Linux/Mac). t2
is the command line interface for Tessel2
devices.
Connect the device to the internet and run the following command:
t2 run
If everything is correct, then you should see something like this as the output.
You can preview received data in the cloud in Message Management Service Cockpit and use the OData API link to now use this data in your applications!
Have a good weather!
Comments