I want to store noise data (basically from A0) from an Arduino Uno to an SD card with faster writing speed, preferably by using 512 data together and the write it at once. What should be the code?
-
2What did you come up yourself?– Michel KeijzersCommented Mar 1, 2019 at 8:36
-
Please read How to Ask.– sa_leinadCommented Mar 1, 2019 at 13:16
-
why do you need fast data logging ....... noise that is sampled at one hour interval, still results in a random data set .......... are you referring to noise as being random data? ..... or are you referring to recording a sound?– jsotolaCommented Mar 1, 2019 at 18:05
Add a comment
|
1 Answer
- Read the values into an array big enough to store them
- Write the array with the
write(const uint8_t *buffer, size_t size)
method.
Each write
then gives you a block of binary data (512 values, 1024 bytes if they're 16-bit integers) written to the SD card. What you do with it then is up to you.
Note: an Arduino UNO only has 2kB of memory. If you have 512 integers that's half your memory gone. The SD card library needs another 512 bytes or more for its internal sector buffer. That's another 25% of your memory used. Already you're up to 75% of your memory gone.
-
Sounds like a small customization of the SD card lib is in order so it doesn't gobble up a quarter of your memory. Commented Mar 1, 2019 at 12:10
-
@ratchetfreak That wouldn't be a "small" optimization... SD card sectors are 512 bytes. You can only read or write entire sectors. You need somewhere to store the current sector...– MajenkoCommented Mar 1, 2019 at 12:24
-
You could reuse the user's buffer. Then flip-flop 2 512 byte buffers as you transfer the data accross. Commented Mar 1, 2019 at 13:46