Connect a MicroPython based Sensor via MQTT(S) to SAP Leonardo IoT Foundation
In the last blog we´ve started wit a general overview, how we can build up an little “PoC” to show up how we can combine SAP Hybris (CEC) with SAP Leonardo IoT Foundation. In Detail the following content is planned:
|1||How to combine SAP Leonardo IoT Foundation and SAP CEC – an PoC|
|2||Connect the Excavator Sensor via MQTT to SAP Cloud Platform IoT Service (this blog)|
|3||How to us SAP Smart Business Service (CF env.) with SAP Cloud Platform IoT Application Enablement – the setup|
|4||Create an “IoT Freestyle” app including “Embedded Analytics”|
|5||SAP Cloud Platform Integration as keyplayer to interact with other applications (Cloud and non Cloud)|
On this blog we wan´t now cover the first two steps, how we can connect our “Excavator” to SAP CP IoT Service and building up the “Digital Twin” with SAP CP IoT Application Enablement.
And base of the fact, that a real “Excavator” is bit expensive we use this kind of sensor an put this on the “rc toy excavator”. An why a “LoPy4” sensor? Ok the main reason is the “memory”, as u can find in the spec this is now 4 MB. If i want to use MQTT with the previous version which has only 2MB, i running in problems to allocate enough memory.
SAP Cloud Platform IoT Service configuration
The first thing what we need to do, is now to define our Capabilities and Sensor Type on SCP IoT Service.
Based on the fact that we´ve still several blogs about the creation process and the documentaion is also still in place i do not cover this again.
As result we got now the following “SensorType” and “Device”.
….and a few lines of code at the device
To interact from our device wit SCP IoT Service we need some coding in “Micropython”.
To interact via MicroPython in a secure way with the “MQTTS Cloud Gateway” from SAP Cloud Platform IoT Service please check this git repository:
And yes for “Python” also the nice “paho” library can be used:
But this does not work with “MicroPython” or i do not found the right repo. ?
Finally the adopted one for this running example can be found here:
And fo more details and examples pls check always the “SAP IoT Starterkit Repository”:
The Digital Twin
As we know from earlier blogs, we can build up easily with SAP Cloud Platform Application Enablement (AE) our “Digital Twin”.
Therefore only a short summary how the “Digital Twin” for the Excavator looks like.
To define later one (in the next blog) some nice KPI´s based on our measured values.
I´ve defined a property set engine:
We define the “type” as “dimension” pls check the offical documentation about this in detail.
In short we are now able to build aggregates, which we use in the next blog to build up some KPI´s.
Our Thing Type is quite simple and consists of our previous defined property sets:
As we already know, if we connect the both worlds we are able to see also the real measures. These measures are provided trough the data ingestion between CP IoT Service and CP IoT AE:
In this blog we got not really new stuff, but i think its part of the entire story and based on this i just cover this in a short way.
In the next blog we want to cover how to setup an configure Smart Business Service on the Cloud Foundry Environment.
SAP Cloud Platform IoT Service
SAP Cloud Platform Application Enablement
SAP Smart Business Service Cloud Foundry
Is there any advantage of having seperate capabilities for measures like temperature, humidity etc? Can't we create a single capability which includes all of them?
Looking forward to the upcoming blogs in the series.
Hi Ajith Cheruvally,
sorry for the delay.
Yes u can define such capabilities for this check the documentation, as u can see here u can send this kind of data.