Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
fabianl
Product and Topic Expert
Product and Topic Expert
In contrast to my first blog we deal now how we can use the API´s from the SAP Cloud Platform Internet of Things Service.

Here u can found the complete series abbout the scenario:

After the successfully creation we want use now an "ESP12-E" modul with the "DHT22" sensor to send real measuremts to IoT service.



To get to know which kind of API´s exist and how to handle is a closer look in the documentation.

We can access the API via the following URL:

Each tile represent different functional categories:



 

After we are logged in (user/pw/tenant) we can access fo e.g. the "Devices" category.

By clicking the "List Operations" we get an overview about the options that exists:



To list our devices we click on the "readDevices" operation an get more details, features and the option to try out the API:



 

Device Model creation in action


 

Prerequisite: The most important thing here is before we start to execute the certain API´s is to get the knowledge about the underlying device model:



For a full description about the different kind of entities please check the documentation

 

In our sceanario we want to execute different API calls to create:

  • Capabilities

  • Device

  • Sensor

  • SensorType


For the execution of the API calls iam using here the postman chrome extension but "curl" etc. work´s also fine.
Capabilties

In our body of the API calls we enter now the relevant information for the two capabilities (temp and humidity):
{
"name": "FridgeTemperature",
"properties": [
{
"name": "Temperature",
"dataType": "float",
"unitOfMeasure": "°C"
}
]
}

{
"name": "FridgeHumidity",
"properties": [
{
"name": "Humidity",
"dataType": "float",
"unitOfMeasure": "%"
}
]
}

As result (here for the temperature) we got an id which we need later:
{
"id": "525",
"name": "FridgeTemperature",
"properties": [
{
"name": "Temperature",
"dataType": "float",
"unitOfMeasure": "°C",
"formatter": {
"scale": 0,
"shift": 0,
"swap": false
}
}
]
}

Device

Let´s create our device "My Fridge" ;o)
{
"gatewayId": "5",
"name": "Fridge_at_Home"
}

Resp:
{
"id": "32",
"gatewayId": "5",
"name": "Fridge_at_Home",
"physicalAddress": "8093b71a21501a1d",
"creationTimestamp": 1502189238621,
"status": "fullyFunctional",
"online": true,
"sensors": [
{
"id": "56",
"deviceId": "32",
"sensorTypeId": "0",
"name": "Sensor: 00000001",
"physicalAddress": "00000001"
}
]
}

SensorType

For the creation of the SeonsorType we refer to the id´s from our newly created capabilities:
{
"name": "DHT22",
"capabilities": [
{
"id": "525"
},
{
"id": "526"
}
]
}

Resp:
{
"id": "214",
"name": "DHT22",
"capabilities": [
{
"id": "525",
"name": "FridgeTemperature",
"type": "measure"
},
{
"id": "526",
"name": "FridgeHumidity",
"type": "measure"
}
],
"protocol": "*"
}

Sensor

Our last task is now to create the sensor, i called it simple "ESP-12_DHT22_fridge_in" and also here we have now the reference to our "Device" and to the "SensorType" which we already created before:
{
"deviceId": "32",
"sensorTypeId": "214",
"name": "ESP12E_DHT22_fridge_in"
}

{
"id": "57",
"deviceId": "32",
"sensorTypeId": "214",
"name": "ESP12E_DHT22_fridge_in",
"physicalAddress": "f7bed59e58f1b1d7"
}

Result

Now we check what´s happening on the IoT service cockpit.....



....and yeah the device is created.

 

Send data to IoT service


As prerequisite we install and configure here also the "Internet of Things Gateway" in more detail we using here the "REST" adapter.

The setup process is described here

My IoT Gateway Edge component runs in my example Herr on an "Raspberry PI 3" to collect the data and fwd (and this works also with an Raspberry PI Zero ?) this in a secure way to IoT service.

 

Let´s test if everything works as aspected.

We just send 2 test messages, one for the temeprature and one for the humidity.

By execute an http POST for Temperature and Humidity:
URL: http://192.168.1.19:8699/measures/8093b71a21501a1d

Body Temperature: { "measureIds": 525, "values": 20.10, "logNodeAddr": "f7bed59e58f1b1d7"}
Body Humidity: { "measureIds": 526, "values": 56.10, "logNodeAddr": "f7bed59e58f1b1d7"}

We got the values:



Now we can prepare our ESP-12E and flash program to the device.

I´am using here the "Arduino IDE" and this tiny program:

And now we get our data:



By the way not sure if my fridge temp is ok ❄️?

cheers,

fabian

 
Labels in this area