I am trying to write sensor data to sd card and while the data is being written, if the sensor data is above a particular value, I want to play an audio file which is on the sd card.
Is it possible to play the audio file while simultaneously writing data to the sd card?
What hardware are you using to play the audio file? The Arduino doesn't know squat about audio files.
Proper hardware would read enough data from a file, so that you could also write to a different file, with only minimal chances of both the Arduino and the other hardware needing to read from and write to the SD card at the same time. Mostly the Arduino would write to, and the other hardware read from, buffers. Writing to the card, or reading from the card, happens only when the buffer becomes full (a write happens) or empty (a read happens).
I was wondering if its even possible to play the audio file from the sd card ( whenever the data point exceeds a certain value) while continuously writing the sensor data to the card.
I was wondering if its even possible to play the audio file from the sd card ( whenever the data point exceeds a certain value) while continuously writing the sensor data to the card.
So, that library has a file open on the SD card, using 512+ bytes of SRAM. Do you have enough SRAM to open a second file, using another 512+ bytes of SRAM?
How quickly does that library use up the 512 bytes that it reads each time? How often will you fill up the 512 byte buffer that you will be using to write to the file?
How important is it that the audio play glitch-free (that is, with no delays caused by you writing to the card when it needs to read from the card?
I have an audio file (31 KB) (around 2 sec) saved on the sd card. When I collect sensor data, the microcontroller creates a file "DATA00" and writes the sensor data to this file.
The audio plays just once (when the datapoint is above a value) and after playing once, the audio file gets corrupted and the data is not readable anymore.
The microcontroller writes data to the file "DATA00" every 30 ms.
I had an other question too. Can the sd card keep writing data to the DATA file while the audio is being played?
From what I noticed, its not able to do that.