SD Card failing to initialise - Audio Player

Hi there,

As part of a university design assignment, I’m trying to create an audio player that plays one music file on loop unless a sensor is touched to play a different music file.

Currently I’m at the stage where I’m wanting to load a music file (wav file) to an SD card and get the Arduino Uno to play it, just so I know it works before I move to try get it to respond with sensors.

The current issue I’m having is when I tried to build the simple audio player for initial prototyping, when run nothing happened or played. I was using this tutorial: https://create.arduino.cc/projecthub/HUNMAN/speaker-with-arduino-and-micro-sd-f238b8?ref=search&ref_id=speaker%20sd%20card&offset=0

I have checked each output is connected correctly from the SD card module to the Arduino Uno as I’m aware it supposed to be:

Gnd - Gnd
5+ - 5+
MISO - Pin 12
MOSI - Pin 11
SCK - Pin 13
CS - Pin 4

In trying to work out what is wrong I’ve been running the Example code available in the Arduino software: SD – CardInfo
and each time I run it is says the card won’t initialise:

I’ve tried 4 different SD cards, each different sizes (128mb, 2gb, 4gb, 32gb) and none want to initialise.

Wondering if this is a module issue? I’m using a SD card module

Or if not what else I can try do because I’m at a lost!
(also I am working off a macbook)

Hi Georgia,

Are the uSD cards FAT32 format?

Can you check what the voltage is between the 3.3V and GND pads when powered? Try not to short anything :slight_smile:

image

It’s a bit hard to tell where you wiring is going from the pictures but here’s a couple of things to try:

SD notes from the Arduino site
https://www.arduino.cc/en/Reference/SDCardNotes

Make sure you format your card correctly
Follow the instructions from the site above but I usually use the software from the SD association to make sure it’s the right format.

*If you post up a better photo where it’s clear where the wires are going it would help.

1 Like

Hi Graham and Shaun,

Yes all my SD cards are currently in the FAT32 format, but I will try the to format again using the SD Memory card formatter. Honestly not quite sure how to check what the voltage is? Should I be attaching to the 3.3V instead of the 5V?

Yeah wiring always looks confusing, I’ve tried getting a clearer image by removing the breadboard I was using and I’ve changed each wire to a different colour and separated the photos of power/GND wires and the other input wires to make it easier again:

Did you specify the CS pin in the sd.begin() call?

The parameter is optional, and defaults to 10. As you are using pin 4, it should be sd.begin(4)

Refer https://www.arduino.cc/en/reference/SD

I tested the code with a Uno and it works with the CS pin 4 as in the sample code. It didn’t work first time when I used a Catalex adaptor similar to the one you have but it’s likely the adaptor is faulty. It did work on an Adafruit microSd adaptor.

1 Like

I was following what the code said and what CS pin was specified (4) but I decided to switch to pin 10 and altered the code accordingly doing that with switching power to 3.3V instead of 5V suddenly I had a response.

However like you Shaun, sometimes it works and sometimes it doesn’t. Is the Adafruit microSD adaptor more reliable?

Also if anyone has any advice with wiring up a speaker with an amplifier to the Arduino it’d be greatly appreciated at a lost of where to start.

I use the Adafruit because it has proper level shifting and a decent size 3V regulator on-board.

For the amplification you need to filter the pulse-width-modulated output before sending it to the amplifier. This can be done with a series resistor and capacitor. There’s an example of doing this in this article (https://simple-circuit.com/arduino-wave-audio-player-sd-card/). A 1k resistor and 10µF capacitor shown are about right.

1 Like

Hi Georgia,
This project of mine produced reasonable audio from files saved as .wav on an SD card.
You could use just the audio output area.

It uses direct register access and interrupts. The Arduino is rather busy when producing audio.
The power to the audio amplifier is switched because the Arduino produces a lot of digital noise which could be heard through the amplifier when not outputting audio.

Regards
Jim

2 Likes

Thanks,

I will definitely be using that simple circuit link because the previous article I was using is, I think, far too complicated for me and my skill level.
I managed to get a speaker/sd circuit working last week (with the current SD module I had) but because the sound wasn’t filtered it wasn’t very clear, hence my need to include an amplifier.

However, yesterday when I went to continue working the SD card and SD module again failed to initialise and read. I think I will be purchasing Adafruit module and hopefully it works more reliably.

1 Like