How to send a Integer From PLC to Siemens Mindsphere

Hello everyone. I am student and total new to Node Red. Right now, I am working on a project at the university regarding to sending data from PLC to Siemens cloud servers (Mind Sphere) with the help of a Node Red. In our project there are total of 16 sensors which I had to send the BOOLEAN data for each to the servers. Siemens already offered the function codes which we can use depending on data type. In the following picture you can see a sample of nodes I have created for 1 of the sensors only:

and the function that I use for the Boolean data is also in this picture: I have learned the codes that I used for the function from the forums since I have no knowledge of Java but the system works fine for the Boolean data. Now I have to send the data as an Integer. I have turned all 16 bits into 1 word data and as you know it will give different number value depending on different number of active sensors. Following the picture
the problem is that I don't know what program codes should I write for this function in order to send Integer value to Siemens. I would really appreciate it if any one can help me with that.

Sincerely Yours

your variable has to be encoded as string. This is also mentioned in the header of the template for the time series which can be copy/pasted to function node:

// take a look at the flow examples at
// - MindSphere expects all values to be encoded as strings
// - Integers must not have any decimal places
// - It is a good practice to use javascript literal notation
// * Examples: 
//   - Random value between 0 and 100: `${Math.random()*100}` 
//   - Variable (HUMIDITY) from input node : `${msg.payload.HUMIDITY}` 
//   - Variable (SPEED) from input node with 0 as default: `${msg.payload.SPEED || 0}`

const values = [];
msg._time = new Date();
return msg;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.