Complete the tutorial to perform some basic tasks.
The first tasks to complete when you start to use the product include getting data into the data lake, applying a calculation to the data, and displaying the results on a dashboard.
In the tutorial, you are simulating a room sensor in a conference room to measure room occupancy and room temperature. Room occupancy is provided as a percentage of room capacity, and temperature is measured in Centigrade. You configure a dashboard to monitor the levels of occupancy and the deviations in temperature values over a 24-hour period.
Before you can register and connect your devices to Platform Service or IoT Tool, you must create a device type.
Room_sensor
to the device type. Room_sensor
device type.Room_sensor_1
device ID to the device and click Next.Before you send data, go to the Recent events section of your device page to monitor recent events as they arrive.
Use the following Messaging API to send device events to the platform:
POST /device/types/{typeId}/devices/{deviceId}/events/{eventName}
https://{orgId}.messaging.internetofthings.ibmcloud.com/api/v0002/device/types/{typeId}/devices/{deviceId}/events/{eventName}
Where:
{orgId}
Is the unique six-character organization ID that was generated when you registered the Platform Service. For example:
POST /device/types/Room_sensor/devices/Room_sensor_1/events/room_status
use-token-auth
. application/json
.Select the Body tab and add the following JSON payload:
{
"occupancy": random(0, 100),
"temp": random(15, 35)
}
Keep your Postman session open. You will send some more events later after you create the physical and logical interfaces.
Room_sensor
device type.room_status
event.room_status
to the interface.occupancy
and temp
as integers. Connect
and click Device type.room_status
logical interface that you created to the Room_sensor
device type.$event.occupancy
in the mapping field. For temp, use $event.temp
.Your device types are automatically generating entity types and storing the corresponding device data in the data lake.
Important: The data lake contains historical data and is populated as your devices contribute data. A time lag occurs between when you connect a device for the first time and when the data starts appearing.
Room_Sensor_1
device type.occupancy
- Number representing the occupancy level percentage in the range 0-100.temp
- Number representing temperature in the range 15-35 C.temp
data item from the Data column to view the temp input data for the device.Your device data is now flowing into the data lake, and you add a calculation by using a built-in function.
Add use calculations to the input data. Calculate the standard deviation of temperature data.
Room_Sensor_1
device type.temp_sigma
.You can create a dashobard from the user interface. Alternatively, you can create a JSON file with the following dashboard configuration. The dashboard includes two line graph cards. The first card plots occupancy of the device over the last 24 hours. The second card plots the mean and maximum temperature over the last 24 hours.
Note: The dashboard creates the mean and maximum aggregate functions.
In the JSON example, the dataSource/attributes/attribute
entry corresponds to the room_status_occupancy
data item and the temp_sigma
data item.
{
"title": "Room Sensor Graph",
"cards": [{
"id": "room_sensor_occupancy",
"size": "LARGE",
"title": "Room occupancy - input values",
"type": "TIMESERIES",
"content": {
"series": [{
"dataSourceId": "occupancyID",
"label": "Occupancy "
}
],
"unit": "%"
},
"dataSource": {
"attributes": [{
"attribute": "room_status_occupancy",
"id": "occupancy_ID"
}
],
"range": {
"count": -24,
"interval": "hour"
}
}
},
{
"id": "room_sensor_temp",
"size": "LARGE",
"title": "Temperature stanard deviation data mean vs max",
"type": "TIMESERIES",
"content": {
"series": [{
"dataSourceId": "temp_sigma_ID",
"label": "Temp - standard deviation"
}]
},
"dataSource": {
"attributes": [{
"attribute": "temp_sigma",
"id": "temp_sigma_ID"
}],
"range": {
"count": -24,
"interval": "hour"
}
}
}
]
}
Room_Sensor
device type. Visualize the data as cards by using the monitoring dashboard feature.
Room_Sensor
device type.Room_Sensor_1
device and open the dashboard that you created.