This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Maximum size of data in pstorage?

I have an nrf51-DK with an external Temperatur/Humidity sensor. Data is received over I2C. The goal is to save data 6 weeks. I will also need the SoftDevice S110, because I want to send the data to a mobile device.

My calculation:

-Data type is uint8_t. As I remember uint8_t needs 1Byte storage size. -I would like to sample the data every minute. So for 6 weeks: 6724*60 = 60480. -There are 2 different data to store(Temperature/Humidity).

Result: 60480 * 2 = 120 kBytes

My question is, what is the maximum size of data which can be stored in the pstorage?

And would it be possible to store 120 kBytes data?

Parents
  • Well that rather depends on how complicated your application is. For a start you'd need a 256Kb flash chip. The softdevice takes 96Kb, which leaves you with 160Kb. So if you can fit your entire application into less than 40Kb then you have 120Kb to store your data.

    The ble heart rate app, when compiled in release mode, is about 15Kb, so if your app is no more complicated than that you might manage it.

    You have another option as well. Temperature and humidity data doesn't change very fast, not normally at least. If you take one of the 256 values which uint8_t gives you and use it as a sentinel you have a reasonable shot at compressing your data stream.

    For example, say that 0 is not a valid temperature value, you just use 1-255 for real data. If your reading changes, then you put each new value into your stream. If however you read the same value more than 3 times, store it as [value, 0, number of times - 3]. So for example if your reading was 123, 10 times in a row, you'd write 123, 0, 7.

    Your worst case doing that is the value changes at least one in every 3 readings and you store the full amount of data, 120Kb, however as soon as you get more than 3 same readings in a row, you save a byte. You never store more data, but you can end up storing less.

    I've done this with temperature data, it's very compressible, I get runs of 20-30 minutes all the same, which means 20-30 bytes becomes .. 3.

Reply
  • Well that rather depends on how complicated your application is. For a start you'd need a 256Kb flash chip. The softdevice takes 96Kb, which leaves you with 160Kb. So if you can fit your entire application into less than 40Kb then you have 120Kb to store your data.

    The ble heart rate app, when compiled in release mode, is about 15Kb, so if your app is no more complicated than that you might manage it.

    You have another option as well. Temperature and humidity data doesn't change very fast, not normally at least. If you take one of the 256 values which uint8_t gives you and use it as a sentinel you have a reasonable shot at compressing your data stream.

    For example, say that 0 is not a valid temperature value, you just use 1-255 for real data. If your reading changes, then you put each new value into your stream. If however you read the same value more than 3 times, store it as [value, 0, number of times - 3]. So for example if your reading was 123, 10 times in a row, you'd write 123, 0, 7.

    Your worst case doing that is the value changes at least one in every 3 readings and you store the full amount of data, 120Kb, however as soon as you get more than 3 same readings in a row, you save a byte. You never store more data, but you can end up storing less.

    I've done this with temperature data, it's very compressible, I get runs of 20-30 minutes all the same, which means 20-30 bytes becomes .. 3.

Children
No Data
Related