Teensy4.1 with SGTL5000 REV D Audio Shield

Hi everyone,


I’m working on a Teensy 4.1 audio project using the Teensy Audio Shield Rev D (SGTL5000) and a CD6283 IC amplifier connected to my speaker. I’m trying to implement real-time audio loopback, where the microphone and speaker are connected to the same codec. The goal is to feed live audio into the microphone and get clear audio output from the speaker, but I’m consistently getting noisy output from the speaker.


Hardware Details:


  • Microcontroller: Teensy 4.1
  • Audio Shield: SGTL5000-based Teensy Audio Shield Rev D
  • Amplifier: CD6283 IC, single-channel (left channel only connected)
  • Speaker: (Add details, e.g., 8 Ω, 6 W, etc.)

Connections:


  • Teensy 4.1 and Audio Shield:Standard I²S and I²C connections
    • LRCLK: Pin 20
    • BCLK: Pin 21
    • SCL: Pin 19
    • SDA: Pin 18
    • DIN: Pin 7
    • DOUT: Pin 8
    • MCLK: Pin 23
  • CD6283 IC Amplifier:
    • Input signal: From the LINE OUT pad of the codec’s left channel (L pin) on the Teensy Audio Shield, with the L pin connected to pin 7 of the amplifier and the GND pin connected to the amplifier’s ground.
    • Input ground: GND of Audio Shield
    • Power: Regulated 12 V from external power supply
    • Speaker: Connected to the CD6283 IC output pins

I tested the Teensy 4.1 with the SparkFun WM8960 audio codec using the same speaker, and it worked fine — I got clear output. However, with the SGTL5000 Audio Shield, I only get digital/hiss/whistle noise.


How can I solve this problem and get clean Audio output?
 
If that’s how you connected the amplifier, you probably need to do more. Here’s the test circuit from a datasheet:
1755326434639.jpeg

 
How is everything powered and wired together - is there a ground loop for instance in the audio path?
 
Is this with an exmaple that could be linked? Or a sketch that could be posted?
Thank you for your reply this is the skecth I am using:-

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
// --- Audio objects ---
AudioInputI2S i2s_in; // I2S1 input from SGTL5000 ADC
AudioOutputI2S i2s_out; // I2S1 output to SGTL5000 DAC
AudioConnection patchCord1(i2s_in, 0, i2s_out, 0); // Left in -> Left out
AudioControlSGTL5000 sgtl5000_1; // SGTL5000 control interface
void setup() {
Serial.begin(115200);
// 1️⃣ Start Audio library & MCLK
AudioMemory(12);
delay(5); // Let MCLK stabilize
// 2️⃣ Scan for SGTL5000 on I2C
Wire.begin();
bool found = false;
for (byte addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
Serial.print("I2C device found at 0x");
Serial.println(addr, HEX);
if (addr == 0x0A) found = true;
}
}
if (!found) {
Serial.println("SGTL5000 not found at 0x0A — check wiring/clock!");
while (1) delay(1000);
}
// 3️⃣ Enable SGTL5000
sgtl5000_1.enable();
// 4️⃣ Use MIC input (shield MIC pin)
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(10); // Adjust 20–36 for your mic
// 5️⃣ Output level to LINE OUT
sgtl5000_1.lineOutLevel(13); // ~1.2 Vrms; safe for your amp
Serial.println("Loopback running: MIC -> LINE OUT");
}
void loop() {
// Nothing needed — audio routing is automatic
}
 
How is everything powered and wired together - is there a ground loop for instance in the audio path?
Now the codec is powered only by the Teensy, and the Teensy is getting power from the USB cable through my PC. Both are connected with jumper wires. When I connect the ground pin (the one marked in red), I don’t get continuity on all the pins marked in yellow. I don’t understand why.
Other than these two pins, I am getting continuity on all the others.

The problem is that sometimes I get a clear output, but after reconnecting, I get the same noisy output again. I’m struggling to get a consistently clean output every time.
1755331466436.png
 
Did you make sure to prevent audio feedback? If you use a mic as input and amplified audio as output via speaker, you will get audio feedback depending on the distance between microphone and speaker.
 
Could be the wiring.

Can you try the board plugged directly ontop the Teensy instead of using jumper wires?

Normally, when the AudioBoard is plugged directly, the path between the red and yellow GND points is shorted within the Teensy. Looking at the traces the Volume pot GND is routed to the top G pin (near 5V), these two will beep when testing continuity. The main GND is the Red one it it should be used when connecting the GND with a wire.
If you intend to use a Volume pot either connect the yellow G to the corresponding pin on the Teensy or just short the yellow GND with the red one on the Audio Board.

I'd suggest checking the returns of all the SGTL5000_1 configuration calls to see if any of it fails. Misconfigured codec can produce a noisy output. The fact that sometimes it works fine, yet more often after reconnecting doesn't suggests it might be something with startup/configuration.
If the wires are long, try making them as short as possible.

Hope it helps!
 
Using a ProtoSupplies MINI platform with PJRC Audio on PCB - Good GND and connects with above sketch:

Added this for headphones that sound clear: sgtl5000_1.volume(0.9); // to enable listening on headphones

Putting Speaker/Amp on LineOut sounds good here.

Some 2-3 clicks on UPLOAD, but none on repowering - no Audio noise.

Mini-Platform-Audio-Section.jpg
 
I meant how is everything powered, including amp, and in particular about grounding - a ground loop is often the cause of noise in audio. A diagram showing all the connections between units would provide this info.
 
Could be the wiring.

Can you try the board plugged directly ontop the Teensy instead of using jumper wires?

Normally, when the AudioBoard is plugged directly, the path between the red and yellow GND points is shorted within the Teensy. Looking at the traces the Volume pot GND is routed to the top G pin (near 5V), these two will beep when testing continuity. The main GND is the Red one it it should be used when connecting the GND with a wire.
If you intend to use a Volume pot either connect the yellow G to the corresponding pin on the Teensy or just short the yellow GND with the red one on the Audio Board.

I'd suggest checking the returns of all the SGTL5000_1 configuration calls to see if any of it fails. Misconfigured codec can produce a noisy output. The fact that sometimes it works fine, yet more often after reconnecting doesn't suggests it might be something with startup/configuration.
If the wires are long, try making them as short as possible.

Hope it helps!
Yes, I am doing this now (the board is plugged directly on top of the Teensy instead of using jumper wires). Now I’m getting a clean output.

Thank you everyone for your replies.
 
The audio board is not only working with a Teensy but also with an ESP32P4, and than we can use with a sample rate of 96KHz.

Yes yes I know it's not a Teensy but I like to say that the PRJC audio adapter is a awesome device.


Best,
Johan
 
I'm hopeful that selection of audio sample rate will become a Tools menu selection in Teensyduino 1.63. Look out for it sometime in, oh, maybe 2028?
 
Many, many years ago, you could set the sample rate at runtime. Is that no longer possible? Many projects rely on that feature.
As for the menu: Yes, that would be good too.
 
You can set it, but it involves editing cores, specifically AudioStream.h. If the Arduino IDE made it possible to define macros on the compiler command line, that would work, but that can only be done via the Tools menu. PlatformIO can do it, I think, but having played with that recently I think it’s just as much of a mess as Arduino.

I still use Arduino IDE, because it’s the lowest common denominator and likely starting point for all. Not because I like it…
 
Well, you say “no problem”, but doesn’t it stuff up all the frequencies, filter cutoffs, etc, that are dependent on AUDIO_SAMPLE_RATE?
 
Of course, yes.
And it goes without saying that things like that have to be adjusted when the sample rate changes. That is an inevitable consequence.
But there are ways to handle that, too. Often, it's just a simple multiplication of the parameters.

However, for some use cases, it "just works" without.
 
Back
Top