MQTT-Node doesn't save any data in my file

Hi community,

I'm a beginner in node-red and javascript in general and tried to display my LoRaWAN temperature sensor in a .txt file on my Raspberry Pi. I tried out creating data with a timestamp, which worked fine and showed me, that node-red is capable of writing data on my Pi.
I'm extracting the temperature data in a function node like this:

msg = {temperatur: msg.payload.uplink_message.decoded_payload.temp};
return msg;

which works well in the debug window.

For the file node, I simply tell it to create a new file and append the new data. The output is set to the right directory and it works with the timestamps, but still if I connect the "function"-node to the "file in"-node, it does not create any data.

I also include an image of what my debug window displays, which is also to the file in node.

Thank you in advance!



The File node writes the contents of msg.payload to the file. You do not have a msg.payload property in the message.

Depending on how you want the data to appear in the file, you could do the following to get just the data value written to the file.

msg.payload =  msg.payload.uplink_message.decoded_payload.temp;
return msg;

Wow thank you very much, the solution was very simple!

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