Msg in a file, thanks :)

Hello,
I have datas from sensor (temperature, lignt, humidity, etc.) that are received in a node-red function with this code :

var split = msg.payload.split("\r");
var Humidity = parseInt(split[1].slice(12, split[1].length-1));
var Pressure = (parseInt(split[2].slice(11, split[2].length-1))/100).toFixed(0);
var Temperature = parseFloat(split[3].slice(15, split[3].length-1)).toFixed(1);
var Light = parseInt(split[4].slice(9, split[4].length-1));
var Noise = parseFloat(split[5].slice(9, split[5].length-1)).toFixed(2);

var txt = split[5].slice(9, split[5].length-1);

var msg0 = {payload:Humidity};
var msg1 = {payload:Pressure};
var msg2 = {payload:Temperature};
var msg3 = {payload:Light};
var msg4 = {payload:Noise};

var msg5 = {payload:txt};
//msg.payload = Humidity
return [msg0, msg1, msg2, msg3, msg4, msg5];

Then they display in a dashboard.

But I want to have them in a .txt file, together in the same file.

Something like that :

22 78 1
23 78 2
22 80 1
22 79 1
24 78 2
22 79 1
etc...

So I can put them in excel after.

I am a node-red newbie, so I put the "file storage", connected all the msg0, msg1, msg2, msg3, msg4, msg5 to that file storage, but the result is not like above, any idea ?

thanks !

I think there are probably some simplifications that could be made, could you add a debug node showing what is going into your function node and show us what is there?

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