One of the most popular (and one of the trickiest) Arduino projects I’ve designed so far is the Arduino Digital Audio Recorder. It appeared in APC magazine issues #403 and #404. It turned an ordinary Arduino Uno R3 microcontroller board into a WAV format audio recorder that can capture 8-bit audio at up to 48kHz and store it on a FAT-formatted microSD card.
I’ve made use of and want to thank the authors of the sdfatlib library, which makes the FAT filesystem possible on an Arduino – it’s an excellent library and the best I’ve found so far.
I’m not going to regurgitate everything here – you can read the full story on the APC website.
The code link on the site points to the wrong location, so at this late stage, I’ve included the story v2 (newer version v7) software here.
But a couple of things to note before I get people complaining it’s a heap of rubbish.
1. The Recorder does just that – it records; it doesn’t play back. Just take your microSD card, load it into your PC, tablet or laptop and play the files in any WAV audio player app (yes, Windows Media Player works just fine). It doesn’t playback yet, because I just haven’t had time – I’m also studying a Master’s degree at the moment, so it is what it is.
2. I say ‘up to 48kHz’ because it depends on the microSD card – now I do say this in the original APC story, so it shouldn’t be anything new. The Arduino Uno R3 really only has one limitation for this job and that’s the 2KB of RAM. If the microSD card is fast enough, it’ll work but if it takes longer than expected for some reason to write a block, you’ll notice the DAR will start dropping out some of the recorded audio. The best tip I can give is use a clean, freshly-formatted card and see what happens. I’m not going to recommend card brands because batches will be different, so try what you’ve got. I’ve managed to get to 48kHz sampling with two cards, but dropping the sample rate down to 44.1kHz or 32kHz should get it working on others.
3. No, you can’t just plug a microphone into it. This records ‘line level’ audio – ‘line-level’ means ‘line-level’, so around 500mV to 1Vrms. If you want to record raw microphone input, you’ll need a preamp. Dynamic mics typically put out about 1mVrms (0.001Vrms), electrets up to 10mVrms if you’re lucky, so a preamp with a gain of around 40-60dB should get you close enough.
4. Remember, this is an 8-bit recorder, so there will be some background hiss. Don’t blame me – if you want audio recording at 22 to 48kHz sampling on an Arduino Uno, you can’t have it with the Arduino’s 10-bit ADC – it simply will not run that fast, unless you’re prepared to sacrifice a little in precision. It’s default speed at 10-bit if I remember correctly is around 9.7kHz, so hardly top-notch audio quality.
5. In the mag, I’ve used a special DIY shield you can buy on eBay for around $5. If you have an ordinary breadboard, that’s fine – use that. Just make sure you get the wiring right.