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

**URL:** <https://discourse.nodered.org/t/mqtt-node-doesnt-save-any-data-in-my-file/53379>\
**Category:** General\
**Created:** [8 November 2021 13:48 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-save-any-data-in-my-file/53379 "2021-11-08T13:48:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![crackl1ng](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackl1ng/32/50653_2.png) [@crackl1ng](https://discourse.nodered.org/u/crackl1ng)\
**Post date:** [8 November 2021 13:48 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-save-any-data-in-my-file/53379/1 "2021-11-08T13:48:35Z")

</div>

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.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/2649a9546affc1b6c25531831e92359ca93b9631.png)

Thank you in advance!

Kindly

Crackl1ng

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [8 November 2021 13:52 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-save-any-data-in-my-file/53379/2 "2021-11-08T13:52:47Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![crackl1ng](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackl1ng/32/50653_2.png) [@crackl1ng](https://discourse.nodered.org/u/crackl1ng)\
**Post date:** [8 November 2021 18:51 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-save-any-data-in-my-file/53379/3 "2021-11-08T18:51:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 November 2021 18:52 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-save-any-data-in-my-file/53379/4 "2021-11-22T18:52:29Z")

</div>

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