Hi,
I tried to connect the new i2s microphone from adafruit with the teensy (without audio board). The MEMS Breakout board is a Adafruit I2S MEMS Microphone Breakout - SPH0645LM4H, but it did not work .
The problem is, that the FFT values are always 0.0. I
Maybe it's a problem of the clock? Adafruit writes in there tutorial, that the clock BCLK should be between 2-4Mhz. But the teensy BCLK runs with 1.41MHz. Is it somehow possible to change this clock? or did someone use this breakout board already with the teensy?
Connections:
Micro -> Teensy
SEL -> Not connected (tried also GND or 3V (changes channel of mono microphone)
LRCL -> 23
DOUT -> 13
BCLK -> 9
GND -> GND
3V -> 3.3V
Code:
Thanks,
Georg
I tried to connect the new i2s microphone from adafruit with the teensy (without audio board). The MEMS Breakout board is a Adafruit I2S MEMS Microphone Breakout - SPH0645LM4H, but it did not work .
The problem is, that the FFT values are always 0.0. I
Maybe it's a problem of the clock? Adafruit writes in there tutorial, that the clock BCLK should be between 2-4Mhz. But the teensy BCLK runs with 1.41MHz. Is it somehow possible to change this clock? or did someone use this breakout board already with the teensy?
Connections:
Micro -> Teensy
SEL -> Not connected (tried also GND or 3V (changes channel of mono microphone)
LRCL -> 23
DOUT -> 13
BCLK -> 9
GND -> GND
3V -> 3.3V
Code:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=139,91
AudioAnalyzeFFT1024 fft1024; //xy=467,147
// Create Audio connections between the components
//
AudioConnection c2(i2s1, 0, fft1024, 0);
// GUItool: end automatically generated code
// The scale sets how much sound is needed in each frequency range to
// show all 8 bars. Higher numbers are more sensitive.
float scale = 60.0;
// An array to hold the 16 frequency bands
float level[16];
// This array holds the on-screen levels. When the signal drops quickly,
// these are used to lower the on-screen level 1 bar per update, which
// looks more pleasing to corresponds to human sound perception.
int shown[16];
void setup() {
delay(200);
Serial.println("Start Setup");
// Audio requires memory to work.
AudioMemory(12);
//i2s1.begin();
fft1024.windowFunction(AudioWindowHanning1024);
Serial.println("End Setup");
}
void loop() {
if (fft1024.available()) {
// read the 512 FFT frequencies into 16 levels
// music is heard in octaves, but the FFT data
// is linear, so for the higher octaves, read
// many FFT bins together.
level[0] = fft1024.read(0);
level[1] = fft1024.read(1);
level[2] = fft1024.read(2, 3);
level[3] = fft1024.read(4, 6);
level[4] = fft1024.read(7, 10);
level[5] = fft1024.read(11, 15);
level[6] = fft1024.read(16, 22);
level[7] = fft1024.read(23, 32);
level[8] = fft1024.read(33, 46);
level[9] = fft1024.read(47, 66);
level[10] = fft1024.read(67, 93);
level[11] = fft1024.read(94, 131);
level[12] = fft1024.read(132, 184);
level[13] = fft1024.read(185, 257);
level[14] = fft1024.read(258, 359);
level[15] = fft1024.read(360, 511);
// See this conversation to change this to more or less than 16 log-scaled bands?
// https://forum.pjrc.com/threads/32677-Is-there-a-logarithmic-function-for-FFT-bin-selection-for-any-given-of-bands
// if you have the volume pot soldered to your audio shield
// uncomment this line to make it adjust the full scale signal
//scale = 8.0 + analogRead(A1) / 5.0;
for (int i=0; i<16; i++) {
Serial.print(level[i]);
// TODO: conversion from FFT data to display bars should be
// exponentially scaled. But how keep it a simple example?
int val = level[i] * scale;
if (val > 8) val = 8;
if (val >= shown[i]) {
shown[i] = val;
} else {
if (shown[i] > 0) shown[i] = shown[i] - 1;
val = shown[i];
}
//Serial.print(shown[i]);
Serial.print(" ");
}
Serial.println("");
}
}
Thanks,
Georg