# Write a monthly temperatures File

**URL:** https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308
**Category:** General
**Created:** [28 May 2025 14:06 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308 "2025-05-28T14:06:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 14:06 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/1 "2025-05-28T14:06:57Z")

</div>

Hi, I have several temperature sensors sending data to gauges on a dashboard, the data is put into a variable in a function node, what i want to do is write a file automatically at the right time of the month with all the temperatures on it, would this be easy to do ? any help appreciated.

Thanks  
Stuart

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [28 May 2025 14:21 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/2 "2025-05-28T14:21:17Z")

</div>

It sounds easy enough, but exactly why do you want to do this?

Have you considered a simple database, eg SQLite?  
You could save each temperature reading to the database as it arrives in Node-red (I think you are using MQTT?).  
Then if you need a monthly summary for emailing or similar you can create it with an SQL query, outputting to a file.

I run Node-red, Mosquitto and SQLite together quite comfortably on a Raspberry Pi Zero 2 so certainly no problem on a beefier Pi such as the Pi 5.  
A Pi is perfect for an mqtt broker and db server too since it can easily be left running 24/7

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 14:49 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/3 "2025-05-28T14:49:36Z")

</div>

Hi Jbudd,

I have about 20 gauges and they are updated every 30 seconds so I would end up with a massive database really, a simple file once a month as a recording would suit me better I think, I am just not sure how to do it, I already have some nodes that send an email if the temperatures become out of range so maybe I could modify this ?

Thanks  
Stuart

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 May 2025 15:02 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/4 "2025-05-28T15:02:35Z")

</div>

It is far easier and more resource efficient to use InfluxDB (or a similar Time Series DB) for this. That's what most of us do.

InfluxDB has the tools built right in to do all the work for you. Here is what I do:

- Write the detailed environment data into a table. Each of my sensors outputs roughly once per minute.
- I tell InfluxDB to only keep the details for one week.
- I also tell InfluxDB to summarise the per-minute data to per hour data - turning each aggregated measurement into a max, min, and avg measure per hour.
- I finally tell InfluxDB to keep the hourly data for 5 years.

I track a LOT of data in InfluxDB since it isn't only environmental data but also system performance data. I can dig out the DB sizes if you like but I used to run all of this and a lot more on a single Pi3b.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [28 May 2025 15:06 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/5 "2025-05-28T15:06:19Z")

</div>

If you really don't want a database, you probably need to retain the readings in a persistent context variable until you write them to a file, whether you write the file once a month or write a new line every 30 seconds.  
The context variable might be json format. I'm not really sure since as I said, I prefer to use a database.

There is a Write-file node which can be set to overwrite it's target file or to append to it if it exists.

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 15:06 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/6 "2025-05-28T15:06:33Z")

</div>

Hi Totally,

Think I might give this a try, Is InfluxDB a free download, not heard of it before

Cheers  
Stuart

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 May 2025 15:08 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/7 "2025-05-28T15:08:41Z")

</div>

Yes, it is free, at least for non-commercial support. Do yourself a favour and stick to the v1.8 style queries and don't use the v2 queries. 🙂

There is an article I wrote here on the forum (in FAQ's?) some years ago about the terminology and configuration that works well with Node-RED. It takes a little getting used to, especially if you know SQL. But once set up and running, you'll never need to touch it.

The other advantage is that - with the v1.8 queries - you can get full point-and-click query building and graphical output by also using InfluxDB with Grafana.

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 15:10 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/8 "2025-05-28T15:10:20Z")

</div>

Thanks  
I will have a read in a bit

Stuart

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [28 May 2025 15:12 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/9 "2025-05-28T15:12:08Z")

</div>

> [@TotallyInformation](#):
>
> It is far easier and more resource efficient to use InfluxDB (or a similar Time Series DB) for this.

Hmm it may well be more efficient but I'd argue with the far easier bit.  
While SQL databases are hardly straightforward, at least the INSERT SELECT & DELETE queries are logical.  
I find Influx distinctly odd with it's measurements and buckets.

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 15:16 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/10 "2025-05-28T15:16:32Z")

</div>

Hi Jbudd,  
I am just looking at options really, I work for a charity and so I am classed as commercial I suppose so not looking to buy any licenses, Is the SQL database free to use ?

Thanks  
Stuart

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 May 2025 15:17 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/11 "2025-05-28T15:17:26Z")

</div>

There is a fully Open Source version of InfluxDB so you will be fine if you want to use that.

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 15:18 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/12 "2025-05-28T15:18:37Z")

</div>

Thanks  
I will have a look at all this later when I get home

Stuart

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 May 2025 15:18 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/13 "2025-05-28T15:18:42Z")

</div>

> [@jbudd](#):
>
> I find Influx distinctly odd with it's measurements and buckets.

It takes a few minutes to work out. 🙂

That's why I wrote the article. Done once and forgotten about until needed - which is pretty much never.

The important part is that you don't have to worry about getting aggregations right, a very simple query gives you aggregations over time periods. And if you use Grafana, it is even easier.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 May 2025 15:22 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/14 "2025-05-28T15:22:01Z")

</div>

> [@How to effectively use InfluxDB](https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885/5):
>
> An InfluxDB measurement is similar to an SQL database table. InfluxDB tags are like indexed columns in an SQL database. InfluxDB fields are like unindexed columns in an SQL database. InfluxDB points are similar to SQL rows. So I have a database called domotica with the following measurements: [image] The environment measurement contains all of my sensor data I have a couple of tags: location and type Location tags are real places such as "Kitchen" type tags are sensor measurement types su…

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [28 May 2025 15:24 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/15 "2025-05-28T15:24:38Z")

</div>

Thanks for the info, I might set it up on my own computer at home first and see if I can get my head round it lol

Stuart

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [28 May 2025 15:27 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/16 "2025-05-28T15:27:09Z")

</div>

I see you are leaning towards Influx and it's a perfectly sound choice.

> [@acestu](#):
>
> Is the SQL database free to use ?

A quote from [sqlite.org](http://sqlite.org):  
The core SQLite database software is in the [public domain](https://sqlite.org/copyright.html). No license is necessary to use SQLite or to build SQLite into your products.

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [29 May 2025 08:15 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/17 "2025-05-29T08:15:32Z")

</div>

Hi,  
They both look a little over the top for what i need, I think I need to get my head around variables first and find out how they work in node-red, I have variables in my function flows and was told if I go to context data in the menu that the current values of the variables would be displayed but it shows nothing so I will have to post about that.

Thanks  
Stuart

---

<div class="post-metadata">

### Author: ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)
#### Post date: [29 May 2025 09:50 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/18 "2025-05-29T09:50:05Z")

</div>

> [@acestu](#):
>
> They both look a little over the top for what i need

Hey, don't be put off by using a simple file to store your data. I ran this method together with a database to record environmental data for years.

When I wanted to take a look at the data (do some stats on it) it was always the comma delimited file that I grabbed, not the database.

Good luck.

Bob

---

<div class="post-metadata">

### Author: ![acestu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acestu/32/90408_2.png) [@acestu](https://discourse.nodered.org/u/acestu)
#### Post date: [29 May 2025 10:02 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/19 "2025-05-29T10:02:10Z")

</div>

Hi Bobo,

Thanks, good to know, I know it should be a simple thing to do but still learning

Stuart

---

<div class="post-metadata">

### Author: ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)
#### Post date: [29 May 2025 10:30 UTC](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308/20 "2025-05-29T10:30:06Z")

</div>

My two tips would be:

1. To avoid the risk of losing data, consider regular file saves (every few minutes), and
2. To avoid the risk of losing the file in 1. make sure you do a backup to different media also on a regular basis.
3. Bonus tip, regularly check the integrity of your file by examining the last few records (readings).

NR can do all of the above very easily.

[Next page](https://discourse.nodered.org/t/write-a-monthly-temperatures-file/97308.md?page=2)
