Hi,
I am completely new at NODE-RED, using flows or java script functions (OK here can i a few basics). I am trying to move somewhere with my project but because i am not moving forward, i decided to ask here for an advice
I am receiving data from sensor in Node-Red. i get new data every second. I managed to present it in ARRAY (values are Type INT).
i would like to make new Array: var SumArray = ; that sums incoming arrays together. For example if my incoming array is [1,1,1,1,1] i have in 5 seconds [5,5,5,5,5] (if its all the time the same ofc).
What i did is this:
var DArray = msg.payload; //incoming array of int values
var SumArray = [];
for (var i = 0; i<DArray.length;i++) {
SumArray[i] += DArray[i];
}
msg.payload = SumArray;
return msg;
but by output is not for example [5,5,5,5,5] but [11111].
Any tips?