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?

  • 2
    What did you come up yourself? Commented Mar 1, 2019 at 8:36
  • Please read How to Ask.
    – sa_leinad
    Commented 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?
    – jsotola
    Commented Mar 1, 2019 at 18:05

1 Answer 1

  1. Read the values into an array big enough to store them
  2. 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...
    – Majenko
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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