Using Two I2S devices at the same time

Hi,

I'm doing a voice recognition project using ESP32. So I'm using INMP441 microphone to recognise voice. It is a I2S device. Also, I'm using a DAC module to play music through Bluetooth. Both of these devices are I2S based. I tried uploading sketches separately for two different tasks( recognition and streaming). It works fine without any error. But when I try to combine both sketches in one, It just performs any one task based on what I put first void setup. Either playing music or voice recognition.

There are different I2S configuration settings for both devices. Also the terms(variables) used are same. Configuration for mic is in main code and for DAC module, it is in header file. Are these things conflicting?

Can anyone please guide me how to successfully combine these codes?

Can't help you combine code that we can't see ... wiring too.

While you are at it run the I2C scanner and see if it shows all ports.

Hi, @aviator2710
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Can you please elaborate?

Should I include my circuit diagram too in post?

Yes, and how you power it, please name components and label pin names.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

An I2S bus can only have one setting at once, ie clock frequencies. However input and output are independent given that constraint as they use separate wires in the bus - I don't know the precise details on the ESP32 but the first thing to find out is if the DAC and INMP441 can share the same I2S config (presumably 44.1kSPS - but the bits per sample have to agree too).

Hard to say if you don't post your code...

INMP441 I2S MEMS Microphine Pin configuration

.bck_io_num = 26, // Serial Clock (SCK)
.ws_io_num = 22, // Word Select (WS)
.data_out_num = I2S_PIN_NO_CHANGE, // not used (only for speakers)
.data_in_num = 21 // Serial Data (SD)

Adafruit I2S Stereo Decoder – UDA1334A pins

.bck_io_num = 23,
.ws_io_num = 14,
.data_out_num = 18,
.data_in_num = I2S_PIN_NO_CHANGE

At a quick glance I think both devices are using the same port (port 0). They need to use different ports if you want both running.

Code seems to working now. Thank you so much!!
But I'm getting very low volume output through DAC module. Can I connect an amplifier in between the ESP32 and DAC module?
If yes then what pins should I connect to ESP32 and DAC module?

I'm having PAM8403 amplifier board

Thank you so much once again!!

I think the dac has pins called lout, rout and agnd. These would be the ones to with the amplifier

Hi,

DAC == Digital Analog Converter.
You can amplify the analog output of the DAC, not the digital input of the DAC to increase volume.

Tom... :smiley: :+1: :coffee: :australia:

Thanks for your reply. Didn't give thought on abbreviation :sweat_smile:
The problem i'm having here is i'm using 3.5mm jack for output which is builtin in DAC module. If I had used speakers, then I could have amplified the DAC's output using amplifier board. I don't know how to amplify 3.5mm jack output.

Just a minor adjustment I2C is a serial communication protocol, so data is transferred bit by bit along a single wire (the SDA line). This wire is used to both send and receive data by any unit on the bus. All units share that wire. Like SPI, I2C is synchronous, so the output of bits is synchronized to the sampling of bits by the clock signal SCL shared by all units on the bus. The clock signal is always generated and controlled by the master. Each device on the bus has an address that is internal to itself. Some allow you to change the address within a given range. Generally a unit that is not addressed does not respond or place data on the bus. The bus is open collector/open drain which must have pull up resistors to pull it to a logic 1.

1 Like

3.5mm jack is same audio. Feed it directly into an amp input or drive headphones directly.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.