Danielya
Posts: 15
Joined: Thu May 04, 2017 12:25 pm

Both speaker and microphone via I2S

Sun May 14, 2017 4:54 am

Hello there,
I've connected a speaker module (Hifiberry DAC) to the Rpi via I2S and it's working ok.
Now I'm trying to connect a microphone also via I2S. What I did was following the instructions in the following page:
https://learn.adafruit.com/adafruit-i2s ... g-and-test

Somewhere in the middle, it says:
Download the module, written by Paul Creaser

git clone https://github.com/PaulCreaser/rpi-i2s-audio
cd rpi-i2s-audio
make -C /lib/modules/$(uname -r )/build M=$(pwd) modules
sudo insmod my_loader.ko

Verify that the module was loaded:
lsmod | grep my_loader
dmesg | tail
But in dmesg I get:
bcm2835-i2s 3f203000.i2s: Trying to bind component to card "snd_rpi_simple_card" but is already bound to card "snd_rpi_hifiberry_dac"
It seems that the mic is trying to bind to the same sound card the speaker is bound to. What can I do? Is there another option to connect both mic and speaker to I2S?

Thanks.

laagland
Posts: 6
Joined: Tue May 23, 2017 8:33 am

Re: Both speaker and microphone via I2S

Tue May 23, 2017 8:34 am

Did you find an answer to this? I'm running into the same problem

Vincent209
Posts: 2
Joined: Thu Sep 14, 2017 10:06 am

Re: Both speaker and microphone via I2S

Tue Sep 19, 2017 7:17 pm

Any answer on this one? I've just encountered the same..

mayurharge
Posts: 3
Joined: Fri Jul 13, 2018 7:26 am

Re: Both speaker and microphone via I2S

Fri Jul 13, 2018 8:38 am

I have found a way to get this done!
so I have followed this tutorial guide from Adafruit https://learn.adafruit.com/adafruit-i2s ... g-and-test for Microphone
and this one https://learn.adafruit.com/adafruit-max ... -pi-wiring for the speaker.
So things to Consider are
1. BLK and LRCL pins are common for both speaker and microphone
2. Dout pin from the microphone is connected to the pin #38 GPIO-20
and Din pin of i2s Amplifier is connected to the pin#40 GPIO-21

Note: I have set up my microphone first and then i2s speaker

and it worked without any problem

stanbenj
Posts: 1
Joined: Thu Jul 26, 2018 5:32 pm

Re: Both speaker and microphone via I2S

Thu Jul 26, 2018 6:48 pm

mayurharge wrote:
Fri Jul 13, 2018 8:38 am
I have found a way to get this done!
so I have followed this tutorial guide from Adafruit https://learn.adafruit.com/adafruit-i2s ... g-and-test for Microphone
and this one https://learn.adafruit.com/adafruit-max ... -pi-wiring for the speaker.
So things to Consider are
1. BLK and LRCL pins are common for both speaker and microphone
2. Dout pin from the microphone is connected to the pin #38 GPIO-20
and Din pin of i2s Amplifier is connected to the pin#40 GPIO-21

Note: I have set up my microphone first and then i2s speaker

and it worked without any problem
Hello Dear

I've followed the process but once I restarted the Pi zero, the microphone stopped working. Is yours still working perfectly? I mean, can you use both micro and speaker on a PI?

Yumanook
Posts: 1
Joined: Sun Aug 12, 2018 8:06 am

Re: Both speaker and microphone via I2S

Sun Aug 12, 2018 8:08 am

Hello yea I um am doing the same thing as you guys but I still get the error "bcm2835-i2s 20203000.i2s: Trying to bind component to card "snd_rpi_simple_card" but is already bound to card "snd_rpi_hifiberry_dac"". I also set up my speaker first, then the mic. Can you tell us how you got this to work? Thanks!

mayurharge
Posts: 3
Joined: Fri Jul 13, 2018 7:26 am

Re: Both speaker and microphone via I2S

Fri Sep 14, 2018 5:40 am

I have not tested this on raspberry pi zero w. With raspberry pi 3 it worked without a problem after restarting the device also.
I am using raspbian Jessie image on my pi.
I guess you're not using the commands for microphone correctly.
I will update the commands for accessing the microphone one i complete tests on rpi zero.

lbdroidman
Posts: 13
Joined: Wed Oct 17, 2018 7:46 pm

Re: Both speaker and microphone via I2S

Thu Oct 18, 2018 2:59 pm

Ok, so this all comes down to drivers/devicetree and the fact that you have 2 drivers competing for the same seat ("sound"). The one who sat in the seat first (hifiberry) wins.

So here is the thing; the hifiberry driver defines both a machine driver, as well as a platform driver. Looking at the machine driver portion of it, it seems to be irrelevant, its just a way to bind the codec driver (pcm5102) with the platform, and should be trivial to replace with something more flexible, like simple-card (which contrary to its name, is not particularly simple): https://github.com/torvalds/linux/blob/ ... e-card.txt

simple-card allows you to define multiple dai-links, so you can set one link to the pcm5102, and another to a dummy codec for the i2s input.

Frankly, I don't actually see *any* need for hifiberry to even HAVE a machine driver. All it is, is a codec, and nothing more. I guess what they really wanted in this, was just to stick their name (advertising) into the kernel, and the reason you will NEVER see that driver pushed upstream, is because it is meaningless.

mayurharge
Posts: 3
Joined: Fri Jul 13, 2018 7:26 am

Re: Both speaker and microphone via I2S

Mon Oct 29, 2018 11:48 am

stanbenj wrote:
Thu Jul 26, 2018 6:48 pm
mayurharge wrote:
Fri Jul 13, 2018 8:38 am
I have found a way to get this done!
so I have followed this tutorial guide from Adafruit https://learn.adafruit.com/adafruit-i2s ... g-and-test for Microphone
and this one https://learn.adafruit.com/adafruit-max ... -pi-wiring for the speaker.
So things to Consider are
1. BLK and LRCL pins are common for both speaker and microphone
2. Dout pin from the microphone is connected to the pin #38 GPIO-20
and Din pin of i2s Amplifier is connected to the pin#40 GPIO-21

Note: I have set up my microphone first and then i2s speaker

and it worked without any problem
Hello Dear

I've followed the process but once I restarted the Pi zero, the microphone stopped working. Is yours still working perfectly? I mean, can you use both micro and speaker on a PI?
I guess you are doing something wrong today I have tested with Pi zero and both speaker and microphone were running fine, even after the reboot.

use " arecord -l " to get the list of recording devices

arecord -D plughw:1 -c1 -r 48000 -f S32_LE -t wav -V mono -v file.wav
arecord = init command
-D name of device i.e plughw
-c channels
-r rate
-f format
-t file tipe
-V vumeter
-v verbose
file.wav is the file name i hope this might help

besi
Posts: 1
Joined: Tue Nov 06, 2018 10:27 am

Re: Both speaker and microphone via I2S

Tue Nov 06, 2018 5:43 pm

    @mayurharge I am struggling to get both the mic and the amplifier working together. Do you think you could post the contents of /etc/modules as well as /boot/config.txt here?

    Return to “Interfacing (DSI, CSI, I2C, etc.)”