3

I am using Arduino uno. My data is storing into EEPROM whenever i run my program, it will store multiple data depend on the loop. For my program it calculate 10 sample in 0.1 sec, so 100 sample in 1 sec. How can i know how much memory i can run?

I have added this code to my program it display 895.

#include <Arduino.h>
int freeRam () {
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}
void setup(){
Serial.begin(9600);
Serial.println(freeRam());}
void loop(){}

1 Answer 1

5

The freeRam() method you are suggesting calculates the "space" between the heap and the stack, thus it returns the free SRAM.

There is no way to calculate free remaining EEPROM (if that is what you are asking), since it just contains some arbitrary data at arbitrary locations. Get the EEPROM capacity from the device data sheet and make sure to write within its boundaries.

3
  • Writing to EEPROM is relatively slow. Check EEPROM speed (older and new EEPROM differs greatly, some only do page write, some do byte write) and your sample size (number of byte to write) to see if 10 sets of sample in 0.1 sec is ok.
    – EEd
    Commented Aug 5, 2014 at 17:03
  • @JohnWilliams: ATMEGA internal EEPROM is indeed very slow. One erase/write operation takes easily 3ms. Thus, writing 10 values every 100ms (OPs requirement) you spend >30ms only storing the data. This is assuming that one value only has 1 Byte width.
    – Rev
    Commented Aug 5, 2014 at 18:43
  • I wonder if it is against rules to response with 'not asked' info, when the info is important for success of the original poster. EEPROM in UNO and Mega2560 is 100,000 times write life (less than 1 day in this case), as per Arduino web link to factory data sheet, page 1 atmel.com/dyn/resources/prod_documents/doc8161.pdf People actually test it to death in hackaday.com/2011/05/16/destroying-an-arduinos-eeprom EEPROM was designed to store in frequent changing data, like calibration data, last power down and restore, etc
    – EEd
    Commented Aug 5, 2014 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.