arrayFIFO in flash memory

I’m trying to insert into the flash memory a FIFO array that cyclically saves values ​​every 2 minutes

var a = [];
    for (var count = 0; count < 500; count++)
            a[count] = count;
        },2 * 60 * 1000);

I am aware that as it is a horrible code,
anyway it gives me LOW_MEMORY error, MEMORY is because I’m not using flash memory?


There’s a few issues with your code.

  • You’re running in a while(true), which means RuuviTag cannot sleep and power consumption is large.
  • You’re setting the setInterval() in a for-loop 500 times which gives you 500 instances of function running at interval
  • The for-loop is within while(true), so you’re adding the setInterval() instances until you run out of memory. Using flash would not help here, you’d fill the flash almost instantly.

Try implementing the FIFO push and pop -functions, and calling those from one setInterval-function.


I think that you are confusing setInterval and setTimeout methods.
I think that all you need is one call for setInterval.