Hello, I have been debating on how long to store the values of sensors. I have a temperature sensor with humidity DHT21.
The question is not how to store it but for how long to store it.
I have a 1Mb eeprom. Which is about 256KB worth of storage. The question still remains, How long do I store the data for, Once a second or Once every 15 seconds. Since we are limited on storage I’m not sure. I’m trying to store 7 days worth. Any advice would be much appreciated?
What are you refering to? Are you speaking about the sample rate?
You just have to calculate the size of your payload, divide the total available size by your payload's size, it will give you the number of samples you can save.
And then if you want 7 days retention you divide 7 days by the number of sample and you'll get the sample rate
Considering the relative short lifetime of an EEPROM, why don't you use a standard SD card to store the values? It has much more space, longer life, and it's easily removable for an offline analysis...
Please provide an example of what you want to do. For instance, you could read the temperature every hour for a week and graph the values at the end of the week using Excel. To do this you would obviously need to store the data for a week
If the data is an integer (2 bytes) then you can store 64k data values.
If you save the data every 10 seconds, then you can save about 7 days worth of data
Could you tell us what's the sampling rate you would like to achieve?
So you want to store the temperature and the humidity
The temperature could be stored into a int16_t managing some realy fast and easy calculations (do you know how to do it? what's the accuracy you need?)
Same for the humidity. This means you need only 4 bytes to store your data.
Maybe you'll need to add a timestamp; so let's say 4 more bytes (unix time on uint32_t)
The total is 8 bytes of data.
With 128kB, you could store around 128kB / 8B = 16k samples 7 days / 16k samples => one sample every 37 seconds
Hope I didn't make any mistakes and undrestood what you wanted
@Anthony_P the thing is I’m not really sold on the whole sampling thing. The reason why is I don’t know how sampling works. I never used it before have ever used it in any of my projects. If I was to log something, I just logged the raw value of it. So I’m not sure of sampling or just a raw logging of the values I mean.