For some context: I have a greenhouse that has a sensor that reads in the temperature every minute and adds it to a temp array for an hour. After an hour the average of the array is taken and that value is stored in an hourly array which is used to build and send me an email of a graph every 24 hours.
When I let my system run for 24 hours it is sending the email as intended. However, there are sometimes when I need to make physical changes to the system in which I have to turn the system off to do so. This causes the temp minute and hourly arrays to be lost upon restarting.
The solution I came up with is to store the data in two different .txt files. I know this would work because I am currently doing it to track the minutes elapsed. However, I don't really want to keep adding a bunch of text files to store data. Is there another way?

Instead of creating text files for each individual variable, you can simply store the information as
jsonand load it as adict.If you wanted to be able to gather statistical data, over an extended period of time, you can expand on the above and do something similar to the below.
Keep in mind that the json method has an issue. Every time you store a sample, the entire json file is loaded, the sample is appended to the return value, and the entire file is rewritten with the new data. There will definitely be some point where you should clear the json. One improvement to my script would be to keep an instance of
readingsalive at all times. This way you can cutread()down to one initial call, and justwrite()when necessary. The only way around this is to use a "real database", meaning a system that does not have to load in it's entirety to be updated.