# Automatically write sensor data to new folder after midnight

**URL:** <https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840>\
**Category:** General\
**Created:** [28 April 2021 08:15 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840 "2021-04-28T08:15:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave298](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Dave298](https://discourse.nodered.org/u/Dave298)\
**Post date:** [28 April 2021 08:15 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840/1 "2021-04-28T08:15:40Z")

</div>

Hi guys, 🙂

I have just started to work a bit more intensively with Node Red, as part of a project. In the project are many temperature sensors (DS18B20) on a machine and measure the temperature for several weeks.

For this I have a raspi with Node Red, which communicate via a router with the microcontrollers NodeMCU ESP8266. Every 5 min the temperature is measured. Because I have a lot of sensors and the measurements last for several weeks, I don't want to copy the data from the raspi to the PC every evening via the software WinSCP by drag&drop and then delete the data on the raspi again.

**Surely there is a way to write a function that writes the data into a new folder from midnight and no more data must be moved manually into a folder?** 🤔  
So, as a result, I should have about 15 folders after the measurements, each containing the measurement data from each sensor from that day.

Unfortunately I have no idea how to create this function or what I would have to write in the function.

PS: The raspi has no access to the internet, therefore currently no time, that I still have to realize with a RTC module.

I would be very grateful if you could help me. 🙂

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [28 April 2021 08:17 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840/2 "2021-04-28T08:17:56Z")

</div>

Have you considered writing all data to a database? It would be much easier in the long run.

---

<div class="post-metadata">

**Author:** ![Dave298](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Dave298](https://discourse.nodered.org/u/Dave298)\
**Post date:** [28 April 2021 08:24 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840/3 "2021-04-28T08:24:18Z")

</div>

Yes, I had already tried that, but unfortunately it did not work as well as I wanted (but maybe it was also me that I had not chosen a good or simple database).  
Currently the measurement process works fine, so I just want to remove the annoying drag&drop part.  
A function that creates a folder based on the date would be the easiest solution in my opinion.

By the way, which database would you recommend to me?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [28 April 2021 08:30 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840/4 "2021-04-28T08:30:46Z")

</div>

If you are storing sensor data the InfluxDB (v1.8.5 NOT v.2.x as the query syntax has a steep learning curve), in combination with Grafana for displaying your data.

If you could install InfuxDB on a computer with internet access you would not need to worry about time on the Pi as the database timestamps are created automatically in InfluxDB.

---

<div class="post-metadata">

**Author:** ![Dave298](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Dave298](https://discourse.nodered.org/u/Dave298)\
**Post date:** [28 April 2021 09:13 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840/5 "2021-04-28T09:13:59Z")

</div>

Unfortunately there is no possibility to provide internet access on site.

With Grafana ob the pi, only my graphics would look better?

---

<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:** [27 June 2021 09:14 UTC](https://discourse.nodered.org/t/automatically-write-sensor-data-to-new-folder-after-midnight/44840/6 "2021-06-27T09:14:21Z")

</div>

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