Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

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(){}
share|improve this question

migrated from electronics.stackexchange.com Aug 5 '14 at 6:44

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

1 Answer 1

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.

share|improve this answer
    
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. –  John Williams Aug 5 '14 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. –  Rev1.0 Aug 5 '14 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 –  John Williams Aug 5 '14 at 20:12
    
Thanks for all for your reply. :) –  Fufu Alex Aug 6 '14 at 4:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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