Hi,
I would like to trend three temperature readings over a day with a reading every minute.
When I compile the code I get the following error:
c:/users/michael/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Michael\AppData\Local\arduino\sketches\ACD2F7E090EC811ABE7EA4A6C174DBE2/WH2_WiFi.ino.elf section `.heap' will not fit in region `RAM'
c:/users/michael/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: section .stack_dummy VMA [20007b00,20007eff] overlaps section .heap VMA [20007548,20009547]
c:/users/michael/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 0 bytes
collect2.exe: error: ld returned 1 exit status
exit status 1
Compiling this simplified code for testing:
const int TEMPERATURE_SAMPLES = 1440; // every minute
//Temperature samples for daily trend
int t1TemperaturePerMinute[TEMPERATURE_SAMPLES] = {};
int t2TemperaturePerMinute[TEMPERATURE_SAMPLES] = {};
int t3TemperaturePerMinute[TEMPERATURE_SAMPLES] = {};
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i < TEMPERATURE_SAMPLES; i++) {
t1TemperaturePerMinute[i] = i;
t2TemperaturePerMinute[i] = i;
t3TemperaturePerMinute[i] = i;
}
}
Results in this error:
c:/users/michael/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: section .stack_dummy VMA [20007b00,20007eff] overlaps section .heap VMA [20005df0,20007def]
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
Commenting out t2... and t3... in the for loop:
for (int i = 0; i < TEMPERATURE_SAMPLES; i++) {
t1TemperaturePerMinute[i] = i;
//t2TemperaturePerMinute[i] = i;
//t3TemperaturePerMinute[i] = i;
}
compiles successfully:
Sketch uses 51880 bytes (19%) of program storage space. Maximum is 262144 bytes.
Global variables use 12500 bytes (38%) of dynamic memory, leaving 20268 bytes for local variables. Maximum is 32768 bytes.
Commenting out just t3... in the for loop:
for (int i = 0; i < TEMPERATURE_SAMPLES; i++) {
t1TemperaturePerMinute[i] = i;
t2TemperaturePerMinute[i] = i;
//t3TemperaturePerMinute[i] = i;
}
also compiles successfully:
Sketch uses 51896 bytes (19%) of program storage space. Maximum is 262144 bytes.
Global variables use 18260 bytes (55%) of dynamic memory, leaving 14508 bytes for local variables. Maximum is 32768 bytes.
Going from one to two arrays increases the global variable usage by 5,760 bytes; there are still 14,508 bytes free.
Why does going to three arrays cause a RAM overflow?
I'm using Arduino IDE 2.3.7 and Arduino UNO R4 Boards 1.5.2
thanks,
Michael