Greetings,
I have been working on a fairly intensive project using an Arduino UNO as a data logger. Everything was going great until I needed to add a few Arrays into my code. The added Arrays would make my code do all sorts of funny things, e.g. return funny results or lock up the microcontorller. Here is the simplest code I cold build that would reproduce the problem.
#include <Wire.h>
//#include <SPI.h>
#include <SD.h>
#include <MemoryFree.h>
void setup() {
Serial.begin(9600);
Serial.print("freeMemory()=");
Serial.println(freeMemory());
Serial.println("hello world");
float data[250];
int i;
for (i = 0; i < 250; i = i + 1) {
data[i] = i;
}
for (i = 0; i < 250; i = i + 1) {
Serial.println(data[i]);
}
}
void loop() {
}
The problem is only present when both the Wire.h and SD.h libraries are uncommitted. I did some reading and I think this may be a memory problem. I was able to check this with the Memoryfree.h library. here are my results
No libraries active; freeMemory()=796
Wire.h active; freeMemory()=589
SD.h active; freeMemory()=184
I am starting to think this is an SRAM issue,
.
Here are the questions I have
Is there a "simple" way to fix this?
I am using Wire.h and SD.h successfully without arrays, in my code and projects. Will the lack of memory cause hurt my UNO's on my working boards?
Would adding an external ram, as shown in the link below be a possible fix to this problem?
http://playground.arduino.cc/Main/SpiRAM
Thanks in advance for any help.