Record audio with MRK 1010

greetings all,

I'm new to Arduino and I'm working on a project that record an audio and store it in SD card through a card reader, After that, I want to read the audio from the card and store it in a variable in order to send the audio to a server.

that problem is, while searching on Google/ YouTube an all they use TMRpcm library and try my best to pivot the tutorials to achieve my goal. but the TMRpcm library not supporting MKR boards.

can someone help me in dealing with Audio? how to record it store it in SD and read the audio again to send the audio to a server.

Note that I store it in SD because based on my knowledge the audio size will exceed the Arduino memory capacity. Open for suggestion to improve the work.

thank you in advance :+1:t2:

If you quickly rid yourself of the idea that audio is stored by your Arduino, the better off you will be.

Your Arduino AD converter will return an integer, 2 bytes, of information every time you ask for an analog read. No Audio! You can do that analog read as often as you can and can write the integer to your SD card. Remember, you get only 10 bit values from the AD read.

The glitch comes in when a 512 byte block of data is ACTUALLY written to the SD card. No other code will be executed during that time, meaning NO audio sampling.

Others will be here soon to tell you that audio is AC and will have to be handled carefully in your Arduino.

Thanks a lot Paul, and if you have hints of how to implement it without using the SD card it would be appreciated!

Also, looking forward to hear more from others :pray:t2:

Greetings All,

I'm new in Arduino world, I'm planning to make an audio recorder using MRK1010 board and store the audio in SD card. And read from the card to be send to a server.

I tried to use TMRpcm as there are many tutorials using it, but it's not compatible with MRK family, only for ARV architecture. I read here that TMRpcm for playing the audio back which is not the goal.

can someone guide me to the correct path? is it feasible to use MRK 1010 in this project or I should change it?

You can record using I2S on board via I2S microphone or dedicated ADC.

@hanarduino , do not cross-post. Threads merged.

It looks like you’re using some pretty comple libraries which are probably using your your resources.
Maybe a bigger Arduino, or trim back the libraries if you can.

1 Like

The code below contains array out of bounds and can't works correctly.
You declare fileSlNum as array of two element, but put 10 chars in it:

the same for this code:

note that the file_name array has length of two chars.

Fixing this errors leads your code to further increasing of memory usage.

can you clarify how trimming a library can be done?

my bad, I put old code with missing numbers.. if don't mind can you have a look again ?

There's some minor stuff you can do - your wait function could be done more simply with millis for example. But the libraries are your real problem and even if you can drop dynamic memory a bit, it will likely crash if there isn't enough stack and heap space.

Your best bet, as suggested is to get a more capable Arduino.

what about support the space using SD card if possible ? do you think it would solve the issue ? I really wanna implement it using this board

The SD card makes it worse. It allocates a 512 byte buffer when you open a file. So you need to slim down your RAM usage a lot. In the project you're copying, I didn't see any WiFi, nor do you use it (yet) in your code. Does it help if you drop it?

I wish but I'm planning to send the recorded audio to a server so WIFI connection is needed

The arrays you allocated looks oversized now. Show the current compiler output - how much memory is missing after array sizes fix?

Maybe get an Uno WiFi 2?

Hello There !

im working with Uno Wifi rev 2 and SD card reader and MAX 9814.
my goal is to record an audio and write/read it in/from the SD card.

how can I do it without library as TMRpcm not supporting the board I'm using.
any direction how to deal with audio? recording and storing it ?

please avoid suggest using another board as I already bought it

Of course, you can write your own code.
But you will need to dive into register settings as normal analogRead is not fast enough.
Even then, you will never reach great quality. I am not sure, but sampling frequency will be limited to 16 kHz or so. So you need to filter everything above 8 kHz out of your audio.
So basically you will have phone quality sound then. OK for speech, but not to listen to an orchestra.
I am not even sure if you can record and save to SD at the same time...
If not, then you would only be able to record a really short message as memory will fill up quickly with audio files (8 bit sound at 16 kHz will produce 16kByte per second... (and you have only 2 kByte)
So basically: you will need another board (...sorry!).
ESP boards are cheaper and much more capable...

@build_1971 I don't know, honestly I'm beginner and what you said scares me due to the lake of knowledge but thanks a lot

Maybe with modules like these?