Arduino IDE fails to detect the SD card Teensy 4.0 + Audio Shield

reGnak

New member
Hello everyone, today I need help with a project I'm working on.

I'm creating an audio guest book using a vintage GPO telephone I bought from Amazon, along with a Teensy 4.0 board and an audio shield. My first step was to solder the phone's micro-switch to the Teensy so it could recognize it. After that, I attempted to install my audio shield with a micro SD card. However, when I run my code in Arduino, it fails to detect the SD card, and my micro-switch code also stops working.

I've attached photos showing my setup.
1.png

2.png



I've placed my Teensy on my audio shield and added a 16GB SD card formatted to FAT32, but it seems like they're not connecting properly. When I run the code, I get an "initialization failed" error.

On my SD card, I only have a WAV file that I'd like to play when the phone is picked up.

If you have any ideas, I would appreciate your help. I'm a beginner and this is my first project, so there might be some simple mistakes in my setup.


this is my code
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// Définition des objets audio
AudioPlaySdWav           playSdWav;
AudioOutputI2S           audioOutput; 
AudioConnection          patchCord1(playSdWav, 0, audioOutput, 0);
AudioConnection          patchCord2(playSdWav, 1, audioOutput, 1);
AudioControlSGTL5000     sgtl5000_1;

const int switchPin = 0;
bool lastState = HIGH;

void setup() {
  pinMode(switchPin, INPUT_PULLUP);
  Serial.begin(9600);


  AudioMemory(8);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);

  if (!SD.begin(BUILTIN_SDCARD)) {
    Serial.println("initialization failed");
    while (1);
  }
}

void loop() {
  bool isHandsetLifted = digitalRead(switchPin) == LOW;

  if (isHandsetLifted != lastState) {
    if (isHandsetLifted) {
      Serial.println("Handset lifted");
     
      if (playSdWav.isPlaying() == false) {
          playSdWav.play("test.wav");
      }
    } else {
      Serial.println("Handset down");
      playSdWav.stop();
    }
    lastState = isHandsetLifted;
  }

  delay(100);
}

1702393537882.png
 
Try changing: if (!SD.begin(BUILTIN_SDCARD)) {
to: if (!SD.begin(10)) {

And see if that helps. The chip select for the SD card on the shield is on pin 10.
 
Looks like the pins might not be soldered.

1702394398416.png


You also need SD.begin(10), as Kurt said. Two problems can be much harder than just 1. Please know you need both reliable soldering and SD.begin(10) for this to work. One without the other won't work.
 
Oh, and I see a 3rd problem. The Teensy is installed wrong, rotated 180 degrees.

1702394653208.png


The USB side is supposed to face in the same direction as the headphone jack. In this photo, headphone jack is on the left and USB on the right side. That's rotated 180 degrees!

Look at the pin numbers printed on Teensy (both sides) and on the audio shield (bottom side), and also on the documentation. You need the pin numbers to line up.
 
Thank you for the information. So, even with the small-sized pins, I need to solder them to the audio shield ? I was under the impression that with this version, soldering wouldn't be necessary, but I appreciate the clarification. I'll give it a try.

Edit: Regarding the soldering process, should I use female pins, or do I solder the Teensy directly to my audio shield? Currently, I have it fitted snugly. Do I solder it directly, or is there something else I need to do ?
 
Last edited:
I would highly recommend using pins & strip headers (sockets) to connect the teensy & audio adapter together. That way, if you accidentally let the magic smoke out of something, you can easily replace it.

Mark J Culross
KD5RXT
 
Soldering is required for reliable operation. Some people have made it work occasionally without soldering, but it's quite unreliable.

Agree with Mark, best to get the sockets. Put the sockets onto the Teensy pins before soldering. If you solder them individually, odds of getting them aligned at right angle to the audio shield accurately enough Teensy to later plug in can be difficult. Then soldering the sockets to the audio shield.

If you solder Teensy directly to the audio shield, there is no realistic way to undo or separate them if anything goes wrong. Before you solder, consider showing us another photo as a final double check, since soldering it 180 degrees rotated or otherwise mis-aligned isn't a recoverable mistake. We can help you to avoid that, if you show photos. The other common mistake with direct soldering is getting the 2 boards too close, where parts on the bottom side of Teensy end up touching the metal shell of the SD socket. If you go for the riskier direct soldering, I recommend temporarily fitting a piece of cardboard or other material between the boards so they're definitely not touching and a small gap will exist between when the material is removed. Again, if you hard solder the headers to the audio board (not using 2 sockets), there is no realistic way to desolder.
 
Back
Top