So I have chosen the arduino-pico environment for this project. SPI is quite straightforward to work with, but keep in mind that the LRCLK (=WS) has to go on pin BCLK +1 due to limitations on the PIO in arduino-pico.
The SPI is setup like this:
#include <I2S.h>
I2S i2s(INPUT);
int32_t l, r, sample;
void setup() {
pinMode(1, OUTPUT); // L/R
digitalWrite(1, LOW); // LOW=LEFT, HIGH=RIGHT
i2s.setDATA(29);
i2s.setBCLK(3); // LRCLK = +1
i2s.setBitsPerSample(24);
i2s.begin(16000);
}
and after this can be read out:
void loop() {
i2s.read32(&l, &r);
sample = l ? l : r;
Serial.printf("%.6x\n", sample);
}
This will output 3byte 24bit samples on the UART, which can be played back on a Linux machine using the following commands:
$ cat /dev/ttyACM0 | xxd -r -p | aplay -r16000 -c1 -fS24_3BE
The call to xxd turns the hexadecimal samples into raw bytes.
This code and the pin diagram is available in https://github.com/biemster/arduino-pico-serialmic
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
I am newbye concerning the Rpi-Pico 2040 board, so I have no advice concerning your switch to C-SDK. I suppose that you have very good reasons.
On the other hand, speaking about the sample rate, I think that the limiting point is the sensitivity of the INMP441 mic, which does not allow to get up to 20kHz bandwidth. I found another microphone which seems to be able to give samples in such freq range:
ICS-43434
Are you sure? yes | no
The switch to C-SDK was because the ethernet lib uses it. I'll probably agree with you that the INMP441 is a bit underspeced when I look into it, but that's the one I had on hand and came cheap..
Are you sure? yes | no
Thank you for this project.
The sample rate is configured to 16KHz. Could the pico accept a 48KHz sample rate ?
Are you sure? yes | no
I don't see why not, and I kind of remember trying this as well (but not sure).
Keep in mind though that I have seem to swapped to C-SDK code instead of arduino-pico, as I noticed in https://github.com/biemster/pico-ethermic.
This project got stalled a bit since I did not get the PIO ethernet to work yet.
Are you sure? yes | no