Query - Storing some data in RAM for later


I'm still learning about the RAM side of these micros, so just wanted to check what my limitations are.

I have my Arduino connected to the Relay Shield prototype I made, which features a SPI Port Expander and 4 Relays. The Relays are driven from the Port Expander so the only IO going to the Arduino is the SPI comms. I also have a SHT15 Temp/Humidity sensor attached to the Arduino.

Basically I just have a little program reading the temperature in every 10 seconds and then checking it against a set point, and then switching the relay accordingly.

What I want to do however is save the FLOAT temperature value into an array, so I can basically log the temperature over time. I only want to save the data once every 10 minutes, and I am just wondering what the best method of doing this is and how long I would be able to log for.

I am assuming that this has to be stored into RAM, so at a guess I don't have very much logging potential. I only need a few hours worth, and I plan to have a rolling array so the last few hours is stored and the oldest basically falls off the end.

I dont know how much RAM I would be using currently, and therefore dont know how much RAM I would have left.

I have seen people talk about PROGMEM, but I dont know if that is relevant for what I am trying to do or not. Or should I be using the EEPROM? Is this used for anything else in normal operation, or is it only used if you explicitly tell it to use the EEPROM?

Is someone able to assist and point me in the right direction please.

I am fine for defining the array etc, but just dont know if I have an option for storing it somewhere else (progmem maybe?), or how much logging potential I may have. Its just for a test, not for long term use. I would use a SD card or something for the final product, but just want to know what I can do in the mean time.


Not to worry, have managed to get something working using EEPROM.

May not be the best approach but I should get what I need for now using this approach.

Converting the Float*10 into an integer and saving that, giving me 1 decimal place saved without having to actually save a float. Got it logging to EEPROM and can read them back and all appears to be correct.

Can you post your code please, it can help others ... thanks.

WanaGo, To further save space, you may use your first temperature value as a base and then the next one stored only as differential to save almost 50% space. Say, in your way, 35.5DegC will be 355, taking 2 bytes. If the next temperature is 36.2DegC, then another two bytes for 362. If instead you save the difference 362-355=7, you only use 1 byte. You only use half the space as long as you're not logging temperatures +-12.7DegC away from your last temperature. Data should be very easy to restore once they are on the PC side.

Thats a smart idea liudr.

I have a couple of EEPROM chips coming however, so space wont be an issue shortly, but that is a good idea to remember for next time.

This is essentially differential calculus in real-life application. I use this way to store temperature curves so I can store more curves and else. Just curious, what EEPROM are you planning to use? I could use some more room to store stuff so your experience will help.

I havent used any EEPROM before, so im very new to this also - however since the internal EEPROM test I did went so well I decided to get some external chips.

I was getting a few bits from Sparkfun and saw they had some I2C EEPROM chips, so decided to get a few of them.

256K bits in size, Microchip 24LC256


Thought I would give them a try.


Just found a tutorial on using it with Arduino too.