How long to store data?

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?

Joseph

Hello

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

Hey @Anthony_P that is my problem right there. I’m unsure if I should do raw storing the values or sampling then storing the values.

First, that is wrong 1Mbit is 128K Bytes.
If you stored 1 byte a second you could only store 35 hours of data

You seem to be confusing the sampling rate, ie how often you read the sensors, and the period over which data recordings are saved

What do you want to do with the data ?

Hey @jim-p you are right. My fault there. Still trying to wake up. Only 6am here.

@UKHeliBob just to store it and read it back later. That is all.

So do you want to store 1 weeks worth of temperatures?

@jim-p yes sir.

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

It depends the use he makes of it. If he does only 1 sample each day, he will die before the EEPROM

@docdoc space on the pcb. Not enough room. I was thinking of using maybe a winbond chip to get more storage.

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

I was thinking of every 15 seconds and there are 6 bytes to store each time.

What difference do you make between those two?

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

No you would have to do 30 seconds or more

Every 15 seconds for 7 days it a loooooot
How did you calculate those 6 bytes? Can you give us the details?

@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.

Just write your 6 data bytes to the PROM once every 30 seconds. It's that simple.