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?
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).
.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)
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?
Thanks for your reply. Didn't give thought on abbreviation
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.