In my last blog, I have described how to process audio input data and encountered the bug that the microphone and line input are mixed together and that there is an open issue for this which has been open for quite some time now.

So I decided to do a little bit of research for my ESP32 AudioKit V2.2 3478 :

First Assumption: The Registers are not set up correctly

The ES8388 Data Sheet describes in Register 10:

  • Input1 the register values 4:5 and 7:6 must be 00
  • Input2 the register values 4:5 and 7:6 must be 01

The value 10 is reserved and the value 11 is used for differential input.

So the next step is to determine the current register setting:

#include "AudioTools.h"
#include "AudioLibs/AudioKit.h"
#include "Wire.h"

using namespace audio_tools;  

AudioKitStream kit; // Access I2S as stream

void readRegister(int addr, int reg){
    Wire.begin(I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO);
    Wire.beginTransmission(addr >> 1);
    Wire.write(reg);
    int rc = Wire.endTransmission();

    uint8_t result_len = Wire.requestFrom((uint16_t)(addr >> 1), (uint8_t)1, true);
    if (result_len > 0) {
        byte result = Wire.read();
        Serial.print(reg);
        Serial.print("/0x");
        Serial.print(reg,HEX);
        Serial.print(" : ");
        Serial.print(result,HEX);
    } 
}

void dumpRegisters(){
    for (int j=0;j<53;j++){
      readRegister(ES8388_ADDR,j);
    }  
}

// Arduino Setup
void setup(void) {
    Serial.begin(115200);
    AudioLogger::instance().begin(Serial, AudioLogger::Info);

    // setup kit
    auto cfg = kit.defaultConfig(RXTX_MODE);
    cfg.input_device = AUDIO_HAL_ADC_INPUT_LINE2;
    kit.begin(cfg);

    // dump all registers
    dumpRegisters();
}

// Arduino loop - copy data
void loop() {
}

Executing the sketch gives the following results

0/0x0 : 12
1/0x1 : 50
2/0x2 : 0
3/0x3 : 0
4/0x4 : 3C
5/0x5 : 0
6/0x6 : 0
7/0x7 : 7C
8/0x8 : 0
9/0x9 : BB
10/0xA : 50
11/0xB : 2
12/0xC : C
13/0xD : 2
14/0xE : 30
15/0xF : 20
16/0x10 : 0
17/0x11 : 0
18/0x12 : 38
19/0x13 : B0
20/0x14 : 32
21/0x15 : 6
22/0x16 : 0
23/0x17 : 18
24/0x18 : 2
25/0x19 : 0
26/0x1A : 0
27/0x1B : 0
28/0x1C : 8
29/0x1D : 0
30/0x1E : 1F
31/0x1F : F7
32/0x20 : FD
33/0x21 : FF
34/0x22 : 1F
35/0x23 : F7
36/0x24 : FD
37/0x25 : FF
38/0x26 : 0
39/0x27 : 90
40/0x28 : 28
41/0x29 : 28
42/0x2A : 90
43/0x2B : 80
44/0x2C : 0
45/0x2D : 0
46/0x2E : D
47/0x2F : D
48/0x30 : 0
49/0x31 : 0
50/0x32 : 0
51/0x33 : AA
52/0x34 : AA

For Register 10 I am getting
AUDIO_HAL_ADC_INPUT_LINE1: “A:0” – hex 00 gives 0b00000000
AUDIO_HAL_ADC_INPUT_LINE2: “A:50” – hex 50 gives 0b01010000

This looks correct and this assumption did turn out to be false. The strange thing however is that I dont get any input with AUDIO_HAL_ADC_INPUT_LINE1 and with AUDIO_HAL_ADC_INPUT_LINE2, I get both the Microphone and the Line IN!

Second Assumption: The Board Design is routing the signals to the wrong pins

Here are the pins for the ES8388:

ES8388

  • Linein should go only to LINEINL and LINEINR
  • Microphone input should go only to MIC1P and MIC1N and MIC2P and MIC2N

Fortunately the wiring schema has been published: This looks OK as well: The Mic pins are routed to the mic inputs and the line input is also ending up at the right pins.

Third Assumption: The Board is routing the signals to the wrong pins

I will have to test this with an Oscilloscope. I tapping on the microphones and tried to determine if I see any impact on line in.
But no – this does not seem to be the case.

Forth Assumption: The Mixer is configured to provide the microphone input

This would be managed via register 39 – bit 6!
Register 39 has 0x90 which is 0b10010000 – and bit 6 is switched off.
Assumption busted!

Help !!! I am running out of options now…


12 Comments

Dave · 20. May 2023 at 23:57

Hi, here is a picture of the mod to fix the microphone bug:
https://drive.google.com/file/d/1bNTqA7qR6yINwzaFS8-NN3DnJnNqaQof/view
(quite difficult to do…)

Marco · 17. May 2023 at 14:57

Hello, did mike share the picture indicating the capacitor to move?

Jeff Lundstrom · 9. February 2023 at 17:01

Did anyone get this working by unsoldering the onboard mics? I am about ready to try that to get line in to work, but don’t want to damage the board if it will not help. Thanks! Jeff

P · 5. September 2022 at 21:22

Just dropped by as you’re a top hit on google now for this issue – i upvoted the github issue too.

I am fast coming around to the idea that whilst I thought this little board would be perfect ( I need 16x of them ), perhaps I would be best buying the esp32’s and wiring them up myself to an i2s amp for output and perhaps an i2s mic for input? I have been unable to capture a decent recording from the onboard mics – the recording is full of noise – sounds like noise coming from the pcb itself?! like a digital weirdness?

The final thing i was going to try was desoldering the 2 x mics and wiring to an external mic – off the board – to see if it cuts out the audio interference – my final application would need this too – and given i cannot see mic headers seems i would need to desolder these onboard mics anyway?

I guess it is ultimately a ‘dev audio kit’ and not for production – where i’d rather just pick it up, attach some peripherals and slap it into the application i have

    pschatzmann · 11. September 2022 at 21:32

    The LyraT board seams to be better suited if you want to record audio…

Uzmeyer · 30. May 2022 at 12:35

I don’t know if by now you have found the reason yourself but I am currently also researching this board for my own project and I am fairly certain I have found the problem. After looking at both the schematic for the board as well as the (horrible) ones for the ESP32-A1S it is indeed a hardware issue but with the ES8388 A1S module itself or how it acts when placed on a board designed around the AC101 version.
The AC101 has two stereo inputs, one with differential mic preamps and one with single ended line-in. These are routed to MIC1N/MIC1P + MIC2N/MIC2P and LINEINL + LINEINR respectively on the A1S module and the names reflect those in the datasheet of the AC101.
However, the ES8388 only has two sets of single ended stereo inputs, LIN1 + RIN1 and LIN2 + RIN2. They can also be combined into two differential inputs consisting of LIN1/RIN1 and LIN2/RIN2, however that way you obviously only have one stereo input. When replacing the AC101 with the ES8388 they tried to keep it pin compatible (my best guess is to not have to get a new fcc id by selling it as the same thing), but the ES is just lacking inputs.
The MIC1N/MIC1P inputs are routed to LIN1/RIN1 and the MIC2N/MIC2P to RIN2/LIN2. The LINEINL/LINEINR inputs are routed to LIN2/RIN2, meaning they use the same pins as MIC2, thus you always get the signal of MIC2 when using line-in and it should be inverted on the right channel.
I’m not 100% sure if I got all the routing correct but it is certain that some mic inputs are internally connected with the line-in. If I am correct, the only way to fix this is taking MIC2 out of the circuit, simplest by removing the coupling caps C19 and C20, then you would be left with a working stereo line-in on LIN2/RIN2 and mono microphone on LIN1+RIN1.
Compare this the Lyrat board, wich also uses the ES8388, but they use the microphones single ended on LIN1/RIN1 and line-in on LIN2/RIN2.

There is a simmilar hardware bug for the output, as the AC101 has a separate stereo headphone/line out and stereo differential speaker out while the ES8388 has only two stereo line outputs LOUT1/ROUT1 and LOUT2/ROUT2 (The wiring of the Lyrat board makes it look like LOUT1/2 and ROUT1/2 can be combined for differential output but i couldn’t find that in the datasheet). On the A1S LOUT1/ROUT1 are routed to SPOLN/SPORN and LOUT2/ROUT2 are routed to HPOUTL/LPOUTR, SPOLP and SPORP are internally open, wich means the speaker amps on the board only get the inverted input. According to the datasheet it should still work but it’s not in ideal configuration.

Again, I am not sure if i got everything correct but the gist of it should be right, hope it helps

    pschatzmann · 30. May 2022 at 13:26

    Thanks for your feed back. I also came to the conclusion that it is a hardware bug.
    However I am flabbergasted about the amount of different AI Thinker Audiokit board versions there are and how difficult it is to find the differences between them.

    Mike R · 29. April 2023 at 10:56

    Sorry to revive an old post, but this seems to be one of the best repositories on the ES8388 version of the A1S module. TLDR; I can get perfectly working stereo line in and stereo microphones by moving two capacitors on the AIThinker AudioKit board.
    On my board (V2.2 A247 ES8388), LINEINL (pin 22) and MIC1N (pin18) are connected together on the A1S module. Similarly, LINEINR (pin 21) and MIC2N (pin 14) are also connected on the module. These two pairs are routed to LIN2 and RIN2 on the ES8388 respectively.
    Some capacitors were already removed on the AI Thinker board that I received, but they appear to be the wrong ones. C17 was removed which connects the left microphone to the MIC1P (pin 17 on the A1S, LIN1 on the ES8388) and C19 was removed which connects the right microphone to MIC2P (pin 15 on the A1S). I think the intention was to make the microphones single ended and remove the negative input. However, the effect was to disconnect the microphones from the LIN1 / RIN1 input, and at the same time leave them connected to the LIN2 / RIN2 inputs (which are also connected to the line in circuit). This is why there is no input on Input Line 1 and mixed microphones / line in audio on Input Line 2.
    I moved capacitor C18 to the C17 position and C20 to the C19 position. This connects the microphones to the left and right channels of Input Line 1 and isolates them from the Input Line 2 / line in path. The fix works well on my board, and I can now use either stereo microphones, stereo line in, or mix both in software. I have a picture of where the caps are on the board if anyone is interested.

      pschatzmann · 29. April 2023 at 11:27

      Cool, that’s helpful!

      DrNeurosurg · 11. May 2023 at 16:46

      Yep – please share this picture … Thx

        Marco · 17. May 2023 at 10:38

        Did Mike shared the picture? I’ve the same problem and ‘im interested to understand th Mike proposed solution but it’s hard to me understnd where capacitor are located….

          Mike R · 3. November 2023 at 0:02

          Sorry for the very late reply. https://imgur.com/a/VR9Qyv3 but I am not sure how long this will last. I will try to write up the change a create a pull request.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *