Single MEMS microphone with audio over UDP, using only RP2040 and INMP441 and just 3 resistors! (and an RJ45, plus some more for active PoE)
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
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
There are no less then three very well supported ways to program a Raspberry Pi Pico, all with a great and active community:
So first thing is to decide which one to use in this project. The two main requirements are SPI input for the INMP441, and the ability to use https://github.com/kingyoPiyo/Pico-10BASE-T for sending the audio frames over Ethernet.
Funny thing is, the 10BASE-T code by kingyoPiyo is written for the C-SDK, and only arduino-pico and MicroPython have SPI input! (the SPI code in the C-SDK is output only as of yet)
So for now I have chosen to go with arduino-pico, since it should be relatively straightforward to use the 10BASE-T code as a library in Arduino. I've never done this before, so keep your fingers crossed.
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates