Teensy 4.0 and SPH0645 I2S Microphone

Status
Not open for further replies.
Hi,

I'm trying to get a Teensy 4.0 with a SPH0645 I2S microphone to work.
Unfortunately, I'm not able to receive any data from the mic.

My wiring (according to this scheme):
Teensy -> SPH0645
3.3V -> 3V
GND -> GND
21 -> BCLK
20 -> LRCL
8 -> DOUT
GND -> SEL

I'm using this code to test it:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s2;           //xy=373,144
AudioAnalyzeRMS          rms1;           //xy=789,282
AudioConnection          patchCord1(i2s2, 0, rms1, 0);
// GUItool: end automatically generated code


void setup() {
Serial.begin(38400);
  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(20);

}

void loop() {
Serial.println(rms1.read());
delay(100);
}

I already tried to route both I2S channels to the rms node. When using channel 0, I constantly get a value of "0.04".
On channel 1 I get "0.00".

I'm using Arduino version 1.8.12 and Teensyduino 1.52-beta2.
 
Your sketch and wiring works for me with T4 and Adafruit SPH0645. RMS only has small change so multiplying by 100 will help see the activity. Using 100*Peak shows more variation. Here is Serialplotter response for sketch in post #2 when saying "works for me"
wfm.png
 
Using the code from your link now gives me constant "4.39 4.39" readings.
Did you also do the test with Teensyduino 1.52-beta2? Maybe that's the problem.
 
Using the code from your link now gives me constant "4.39 4.39" readings.
Did you also do the test with Teensyduino 1.52-beta2? Maybe that's the problem.

i was using Arduino 1.8.11 with 1.52-beta2. can you attach a photo of your T4 and wiring to mic? I assume you did change the the AudioInput from PDM to I2S in the sketch in post #2.
 
Last edited:
photo looks ok. have you looked at Peak and RMS with the IDE's SerialPlotter using post #2 sketch? graph should vary as you make sounds near mic.
 
photo looks ok. have you looked at Peak and RMS with the IDE's SerialPlotter using post #2 sketch? graph should vary as you make sounds near mic.

Yes I did. Only getting a constant value like in the serial monitor.

The SPH0645 is not the best choice as it's I2S output violates the timing specification. The Data signal transitions on the wrong edge.

I saw that thread. But somehow the data sigal seems to transition on the right edge (falling) in my case. See the attached scope pic.
DS1Z_QuickPrint2.png
 
I saw that thread. But somehow the data sigal seems to transition on the right edge (falling) in my case. See the attached scope pic.
Well, I can't explain that. Different flavor of SPH0645 perhaps? This picture is from the datasheet provided by Adafruit for their SPH0645 Breakout:
 

Attachments

  • SPH0645.jpg
    SPH0645.jpg
    42.8 KB · Views: 64
FWIW here is scope shot of my adafruit SPH0645 with T4
adamic.png
data (purple) is triggered on rising BCLK (yellow), LRCLK (blue) triggered on falling BCLK
 
I saw that thread. But somehow the data sigal seems to transition on the right edge (falling) in my case. See the attached scope pic.
View attachment 19669

Never mind I had a wrong sketch loaded in (I can't edit my post from above).
With the correct sketch I experience the same behavior as you do:
DS1Z_QuickPrint3.png

@gfvalvo:
Did you ever try the fix you proposed in the older thread with the FF and the inverter?
 
here is scope of Tindie I2S mic, Invensense ICS43434.
tindiemic.png
sketch serial output is only 0's when run on T4, even though scope looks ok ? on T3.2 serial output ok with Tindie I2S mic

?? :confused: now when i wire adafruit I2S mic to T4, RMS and Peak aren't changing ? (4.82). still works with T3.2 and T3.6
 
Last edited:
?? :confused: now when i wire adafruit I2S mic to T4, RMS and Peak aren't changing ? (4.82). still works with T3.2 and T3.6

I had been using 1.8.11 and 1.52-beta2. I cloned in Paul's latest cores but mic RMS/peak values still frozen, then i rebuilt RMS/peak sketch with 1.8.10 and 1.49 and adafruit mic is working again with T4. ?? Also worked with 1.8.12 and 1.51 and 1.52-beta1

Also tindie I2S mic worked with T4 using 1.8.12 and 1.52-beta1
tindiemic.png

EDIT: I think the latest Audio lib on github fixes the problem on 1.52.-beta2
also see https://forum.pjrc.com/threads/60354-Teensyduino-1-52-Beta-2?p=235163&viewfull=1#post235163
 
Last edited:
Status
Not open for further replies.
Back
Top