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: 
kachiever
Participant
This blog is for all those people who are currently working on IoT space of SAP or planning to do the same. I was also exploring the space & faced a problem which I solved later & sharing here for all who are currently facing the same or may face it in future.


What's SAP IoT Service Cockpit ? 


So, SAP has come up with IOT Service which gives you access to SAP's on Cloud IoT solution called Internet of Things Service Cockpit. Its a ready to use solutions, so if you want to connect your IOT device with SCP, you can do some basic configurations & with few simple steps you can achieve the same. Cockpit provide two globally accepted channels of communication with device namely MQTT & REST.

What are we doing here ?


In this blog we will focus on a MQTT channel based device, or a device which communicate with cloud through MQTT communication channel. We are focusing on MQTT as its most common communication channel in IOT space, I was using the same & faced some issue which resulted in this blog.

Why was it required ?


So, I was basically doing a simple hands on where I wanted to define a simple device on the cockpit and try to simulate a scenario where, we send data to my configured device on the cockpit. I wanted a tool which takes a CSV file as an input and uses its data to send message to cloud through MQTT. I searched a lot but was not able to find any tool that can easily connect with the IOT Cockpit.


MQTT Device Simulator


I created a simple tool in NodeJS to do the same. So, if you want to send data to Cloud you need to create some IDs , generate a certificate and then you can send data using the same(we will see all this further). So , this tool takes the certificate as its(no need to do any conversions), your iDs, the CSV file and sends the data using MQTT to Cloud in the desired interval of time. Basically with this tool you can easily simulate a MQTT based IOT device for your testing without any need of a physical device.

Assumption



  1.  NodeJS is installed on your machine.

  2. You have Created your Device Model IoT Cockpit(Capability, Sensor Type & MQTT Device).

  3. You have Generated your PEM Certificate for the Device & have your Secret Key.


Setting up the Tool


Now as all the above conditions are met, we can proceed further & follow the below steps to setup the simulator.

  • Download the Repository from GitHub : https://github.com/brutecoder/MQTT-Device-Simulator-for-IoT-Service-Cockpit The Repository looks like as above, download it as zip file. Now, extract it on your machine so we can do the tweaks according to your device.

  • Open the "certificate" folder & replace the PEM certificate with your generated PEM certificate & rename it as "device1_certificate.pem". Open "device1_passphrase.txt" , and enter the secret key you got during the PEM certificate generation on IoT Service Cockpit.

  • Replace or copy paste your required CSV data in "data.csv", make sure you don't rename it to something else, keep it as "data.csv".

  • Now, time to make some changes to "csv_to_mqtt.js", as per your device. I have defined 2 fields in code for testing namely, temperature & humidity. You , need to add your device specific fields on line 11, 12, 13, 14.

  • On line number 24 you will find below code. You can replace "5000" with desired interval time 1000 = 1 seconds.

  • On line number 27 you will find below code. You can replace Temp & Hum or can add more required fields.

  • Final Changes to be made on line number 35. You replace Temp & Hum or can add more required fields.


That's all , you are good to go, just save the code. Open terminal & run the code. You will get the below messages in terminal , giving status of connection & the data that has been sent.

3 Comments
Labels in this area