Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
phillip_kujawa
 
Posts: 35
Joined: Mon Oct 09, 2017 10:47 pm

Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by phillip_kujawa »

Hey Guys,

Let me start off by saying I'm a hardware electronics novice. Recently purchased the ADAFRUIT I2S MEMS MICROPHONE BREAKOUT - SPH0645LM4H and the ADAFRUIT I2S 3W CLASS D AMPLIFIER BREAKOUT - MAX98357A for a doorbell project using my Raspberry Pi Zero. Can anyone point me in the right direction in terms of wiring these two devices to the Pi and then creating the appropriate device overlay? How can we access the devices through Python after?

Any help is greatly appreciated!

Cheers,
Phil

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by adafruit_support_mike »

The best place to start would be with the tutorials for each device:

https://learn.adafruit.com/adafruit-i2s ... t/overview
https://learn.adafruit.com/adafruit-max ... p/overview

Those explain how to handle the connections to a RasPi.

User avatar
phillip_kujawa
 
Posts: 35
Joined: Mon Oct 09, 2017 10:47 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by phillip_kujawa »

adafruit_support_mike wrote:The best place to start would be with the tutorials for each device:

https://learn.adafruit.com/adafruit-i2s ... t/overview
https://learn.adafruit.com/adafruit-max ... p/overview

Those explain how to handle the connections to a RasPi.
Hey Mike,

Both have similar pin selection since raspberry pi only has one set of i2s pins. Both Raspberry Pi GPIO pins 18 (BITCLOCK) and 19 (LRCLOCK) are used by both devices. Can you provide me any further insight on how to wire these two devices to the Pi and how I can get both devices working simultaneously.

Thanks,
Phil

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by adafruit_support_mike »

Sorry for the delay in getting back to you.

We haven't tried to combine the I2S mic and speakers on the RasPi because honestly, ALSA is kind of arcane. The best suggestion we have is to combine the .asoundrc clauses from the two tutorials and see what happens.

User avatar
skspurling
 
Posts: 8
Joined: Fri May 13, 2016 1:17 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by skspurling »

Okay, from what I can derive from the spec sheet(Very simple compared to I2C or anything else), there's one master that provides clock, and one line that provide data. It says that systems can be very complex, leading to the assumption that you just cascade all the stuff onto the bus.

"The bus has only to handle audio data, while the other signals, such
as sub-coding and control, are transferred separately. To minimize
the number of pins required and to keep wiring simple, a 3-line serial
bus is used consisting of a line for two time-multiplexed data
channels, a word select line and a clock line.

Since the transmitter and receiver have the same clock signal for
data transmission, the transmitter as the master, has to generate the
bit clock, word-select signal and data. In complex systems however,
there may be several transmitters and receivers, which makes it
difficult to define the master. In such systems, there is usually a
system master controlling digital audio data-flow between the
various ICs. ..."

It looks like one transmitter device gets to clock data at a time. Unfortunately, I don't see any collision detection or bus negotiation protocol defined. If you cascade everything together, it might work great, or it may not work at all. It's an insanely simple protocol, but they don't say that this is a two device interconnect, and they don't say it isn't limited to two chips. They kind of insinuate that a bunch of transmitters and receivers could be present, and that you might need a master clock if things get too complex. They don't require it.... I'd say hook it up and give it a try. Not like something is going to get over amped or over voltaged.

User avatar
skspurling
 
Posts: 8
Joined: Fri May 13, 2016 1:17 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by skspurling »

Okay, the answer you were looking for was staring me in the face already...
I was looking at alternatives to the AIY voice hat, since it was impossible to get the kit when it was released. There was a person who made a DIY AIY hat using Adafruit components. He used the MEMS I2S mics and a I2S mono amp board, and a proto hat with the EEPROM. Looks like the data line for Dout and Din are separate. You still need to use the LCLK to select on both, and the data clock is cascaded across both, but in and out audio data are kept separate by using separate in and out pins.
Look carefully, the example applications use different pins.

User avatar
skspurling
 
Posts: 8
Joined: Fri May 13, 2016 1:17 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by skspurling »

Okay, I got it working. The input and output combination is like setting up just the mic, but a little different.

Let's see. You have to use the simple sound card driver that comes with the linux kernel. Use My_loader and use the instructions that are given for the Mic. There's kind of hints and suggestions all over the place, and some of the older versions of the simple sound driver set the clock divider for the bclk wrong. The kicker for the sound output was settings for it in /etc/asound.conf. This gives some hints: https://www.raspberrypi.org/forums/view ... 2&start=25
Don't try to follow it. It's out of date by now. Just look at it and the Adafruit I2S mems mic instruction page. My_loader is about the same as loader. Simple Sound card is in the precompiled kernel modules.

As far as the clk siginals and FMT line, those are all shared. Dout for the speakers would be pin 40, and Din for the mic is pin 38. Every thing else is shared. Don't use the hifiberry driver or any of the others. You need the simple sound driver from the linux kernel only, and the loader to instantiate the devices. No overlays other than I2S.

My main issue is that the sound format is fixed at s32_le, and I need a 16 bit sample for pocketsphinx. I am going to open a new post to ask about that. I'm not up on sox or ffmpeg, so I am not sure how to pipe a live transcoding for this. Any one have a suggestion?

User avatar
phillip_kujawa
 
Posts: 35
Joined: Mon Oct 09, 2017 10:47 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by phillip_kujawa »

skspurling wrote:Okay, I got it working. The input and output combination is like setting up just the mic, but a little different.

Let's see. You have to use the simple sound card driver that comes with the linux kernel. Use My_loader and use the instructions that are given for the Mic. There's kind of hints and suggestions all over the place, and some of the older versions of the simple sound driver set the clock divider for the bclk wrong. The kicker for the sound output was settings for it in /etc/asound.conf. This gives some hints: https://www.raspberrypi.org/forums/view ... 2&start=25
Don't try to follow it. It's out of date by now. Just look at it and the Adafruit I2S mems mic instruction page. My_loader is about the same as loader. Simple Sound card is in the precompiled kernel modules.

As far as the clk siginals and FMT line, those are all shared. Dout for the speakers would be pin 40, and Din for the mic is pin 38. Every thing else is shared. Don't use the hifiberry driver or any of the others. You need the simple sound driver from the linux kernel only, and the loader to instantiate the devices. No overlays other than I2S.

My main issue is that the sound format is fixed at s32_le, and I need a 16 bit sample for pocketsphinx. I am going to open a new post to ask about that. I'm not up on sox or ffmpeg, so I am not sure how to pipe a live transcoding for this. Any one have a suggestion?
Ok I got both devices to work but the issue I'm having now is "device busy" when one devices is used and the other is not. I cannot have them both used simultaneously.

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit i2S Mic and i2S Amp connect to Raspberry Pi

Post by adafruit_support_mike »

I don't think it's possible to run an I2S speaker and mic at the same time. They use the bus in different ways.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”