Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codec initialization fails #26

Open
mihovilkolaric opened this issue Jul 7, 2021 · 94 comments
Open

Codec initialization fails #26

mihovilkolaric opened this issue Jul 7, 2021 · 94 comments

Comments

@mihovilkolaric
Copy link

I bought a "ESP32 Audio Kit v2.2 2957" and installed the toolchain as described in this readly, and the ADF (+IDF) from this repo.
I can compile and flash all examples I tried so far (here, e.g. ESP32-A1S-AudioKit/examples/get-started/play_mp3), but when running them, I find following errors on the serial console:

E (1026) AC101: reset failed!
E (1026) AUDIO_HAL: codec init failed!
E (1026) AUDIO_BOARD: /home/test/esp/ESP32-A1S-AudioKit/components/audio_board/ai_thinker_audio_kit_v2_2/board.c:55 (audio_board_codec_init): Got NULL Pointer
E (1036) AUDIO_HAL: audio_hal handle is null

and do not hear anything in the earphones.

I verified that in make menuconfig the board ESP32-AiThinker-audio V2.2 is selected.

What can I do to fix this issue?

@PratyushGehlot
Copy link

PratyushGehlot commented Jul 11, 2021

Hi @mihovilkolaric ,
I also bought last week ESP32 Audio Kit v2.2 2957 and facing the same issue.
I used Arduino sketch from here - https://github.com/schreibfaul1/AC101/blob/master/examples/ESP32AudioKit/ESP32AudioKit.ino

AC101 init failing -

Serial.printf("Connect to AC101 codec... ");
while (not ac.begin(IIC_DATA, IIC_CLK))
{
Serial.printf("Failed!\n");
delay(1000);
}

Serial Output : Connect to AC101 codec... Failed!

Setup :
esp32AudioKit

@xpeace
Copy link

xpeace commented Jul 13, 2021

Recent AI Thinker boards V2.2 2957 are using A1S designs where the AC101 was replaced by the ES8388 eventually these are the wrong boards for this A1S version. It could be possible that all recent boards are defective if the outputs of the A1S-ES8388 are not compatible to the 2.2 Audio Kit board... I did not receive an official statement regarding this mess yet... please ask the AI Thinker support. However I have created an Arduino file which autodetecs your HW wether you're having an AC101 or the ES8388 based design... AI Thinker confirmed they created these A1S ES8388 based chips... they gave no answer why tho. You see the chip when removing the EM shield - or upload the arduino file...
https://www.mikrocontroller.net/topic/474383?goto=6754783#6752864

@maqsudbd
Copy link

Hi @PratyushGehlot am facing the same issue.

Did you find any solution?

Hi @xpeace

Did you mean that the board is faulty? Or we will have to use driver for ES8388?

@mihovilkolaric
Copy link
Author

@maqsudbd : when using the driver for ES8388 (tried this by changing the "Audio Board" to LyraT 4.3 in make menuconfig), the codec can be initialized, but on the headphones-jack of the audio-board you hear only one channel, the volume is very low (hardly hearable), and can not be controlled by software.
So, hard to tell whether the board is faulty (resp.: pinning of board and chip are incompatible), or whether some adjustments in the code/firmware/GPIO-config are enough to make it work. It is impossible to say, without having a datasheet of the used A1S (with ES8388).

@maqsudbd
Copy link

@mihovilkolaric Thanks for update.

I was planning to use Arduino, made a code for AC101 and I was able to made it work for a friend. Now I am stuck and hope someone will find a solution.

I think datasheet of the used A1S (with ES8388) will help to find the root cause. I hope the board is not faulty by design.

@xpeace
Copy link

xpeace commented Jul 15, 2021

Eventually GPIO 21 needs to be activated to enable the amp...
Still trying to get in contact with AI Thinker... not much success lately...

The A1S was so much better than the LyraT -

  • You can directly work in Arduino IDE (no need for esp-idf)
  • No need 4 two USB connection (serial + power required)
  • No need to press buttons to upload a sketch (press reset + boot, unpress reset... )

It would be sufficient for me to get just one channel mic in / headphone out...

Anyone willing to unsolder the ES32-A1S 2974 from the Ver 2.2 2957 board
( IO connectors are labeled on the rear side of the board... )

Here is an image of the A1S (ES8388) with EM shield removed
ES8388

@xpeace
Copy link

xpeace commented Jul 16, 2021

Additionally I`ve found this pdf reflecting changes in the A1S board...

https://www.docdroid.net/L6LX9SK/esp32-a1s-esv23zh-cnen-pdf
but I think they left out the correct values when describing I²C / I²S values... for the esp-adf

/* I2C gpios */
#define IIC_CLK 23
#define IIC_DATA 18

It does also mention a V2.3 Audio Kit - while AI Thinker put them on a V2.2 pcb...

I now have stereo playback - headphone jack insertion event on the A1S is mapped to Key 3 when using LyraT 4.3 profile.

Volume control seems to be accepted - but there is no change in volume output on the headphone.

@xpeace
Copy link

xpeace commented Jul 17, 2021

@maqsudbd
Copy link

@xpeace Thanks for sharing the pdf.

It seems the board is not faulty rather a new one with new design. I2C are now on different pins (23,18 now, before 32,33). Also the I2S pins are different.

@xpeace
Copy link

xpeace commented Sep 25, 2021

Apart from headphone recognition I got all the functions I need working.
To get max volume from the mic of the ES8388 unit it requires to enable AGC.

@tttin46
Copy link

tttin46 commented Sep 26, 2021

New modified ESP-ADF git: https://github.com/SeaHi-Mo/esp-adf

@rxd1999
Copy link

rxd1999 commented Oct 6, 2021

Apart from headphone recognition I got all the functions I need working. To get max volume from the mic of the ES8388 unit it requires to enable AGC.

Hi
I meet the same problem these days.
Could you tell me how to enable "AGC"?
Thanks !

@tttin46
Copy link

tttin46 commented Oct 6, 2021

Apart from headphone recognition I got all the functions I need working. To get max volume from the mic of the ES8388 unit it requires to enable AGC.

Hi I meet the same problem these days. Could you tell me how to enable "AGC"? Thanks !

AMP is controlled by IO21 but its use for Speaker not for headphone jack.
screenshot_1633530849

@xpeace
Copy link

xpeace commented Oct 6, 2021

I think the question is not about the amp, to increase the mic input sensitivity AGC (Automatic Gain Control) needs to be enabled. Unfortunately it is not possible to increase the pga (programmable gain amplifier) unit without enabling AGC and adjusting the corresponding values.

Here is the settings section I am using to test the mic input. Enable the deemphasis to reduce the quantization noise - and try to reduce any heavy calculation during capture :)... Imho the biggest feature with this chip is - you got the cpu's impacting the AD signal path. Boot buttons and Key6 is also interfering the signal capture - anyone knows what`s up there ?

// PGA ALC/AGC
es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL10, 0xDA);  // Reg 0x12 (ALC enable, PGA Max. Gain=23.5dB, Min. Gain=0dB)
es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL11, 0x91);  // Reg 0x13 (ALC Target=-4.5dB, ALC Hold time = 0 mS)
es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL12, 0x12);  // Reg 0x14 (Decay time =820uS , Attack time = 416 uS)
es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL13, 0x06);  // Reg 0x15 (ALC mode) 96 Samples
es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL14, 0x00);  // Reg 0x16 (noise gate = -40.5dB, NGG = 0x01(mute ADC))

@GillesLACAUD
Copy link

Same Issue for me with a new ESP32 Audio Kit V2.2 3378.....I have an ES8388 but it is on the I2C 33/32....and now i not very sure about the I2S pinout....i have read so many configurations :-(.

@GillesLACAUD
Copy link

If they change the codec and change also the pinout between the different productions....

@GillesLACAUD
Copy link

I can find any schematic with the I2C 33/32 and the ES8388 !!!

@GillesLACAUD
Copy link

and i confirm my A1S board is not the same as the Xpeace picture....the components are not in the same place.
(i have removed the shield).
PLEASE AI WHERE IS THE LAST SCHEMATIC

@xuhongv
Copy link
Member

xuhongv commented Oct 21, 2021

@GillesLACAUD @xpeace @rxd1999 @mihovilkolaric

hi , we change the i2s port in the newest A1S module:

image

@GillesLACAUD
Copy link

Hi Xuhongv.
Thank you for your quick answer. It will be very usefull.
Can you also upload the last schematic or data sheet in this post or on your web site, and give us the link.
Is it the final version of the ESP32 Audio Kit or you plan to change something else in the futur ?
I want to buy a lot of your cards and i must be sure to have always the same boards.

@GillesLACAUD
Copy link

GillesLACAUD commented Oct 21, 2021

I am sorry but i am a little bit lost...
**Where is the github with your informations ? **.

When i search i find this in the 2 repo:

For the ADF github
https://github.com/espressif/esp-adf/blob/master/components/audio_board/lyrat_v4_3/board_pins_config.c
And For the Audio kit github
https://github.com/Ai-Thinker-Open/ESP32-A1S-AudioKit/blob/master/components/audio_board/lyrat_v4_3/board_pins_config.c

image

@xuhongv
Copy link
Member

xuhongv commented Oct 21, 2021

You can use the sdk on ESPRESSIF ADF github , and then you alter the i2s pins .

@GillesLACAUD
Copy link

And the I2C pins too...
Did you have the schematics please ?

@GillesLACAUD
Copy link

ok Xuhongv....Thx for the two links....but when i open the doc the pinout is not correct
So i do not understand the difference between the software and the hardware part.
Could you check again please...
And thank you again for you help...I very appreciate
For The I2C
image
For The I2S
image

@GillesLACAUD
Copy link

Could you also tell us how we can find an identification of the version of the A1S module ? How we can know if we have an AC101, an ES8388 with 18/23 on I2C and an ES8388 with 33/32 on I2C ?
On the A1S Module we have always the same FCC ID

@xuhongv
Copy link
Member

xuhongv commented Oct 21, 2021

@xuhongv
Copy link
Member

xuhongv commented Oct 21, 2021

You can see the bottom font of the module.

@GillesLACAUD
Copy link

I think you have an ES8388 codec and not an AC101. AC101 is only for the old version.
Please read carefully all the post and i pretty sure you will find the solution

@vijugo
Copy link

vijugo commented Nov 24, 2021

En la libreria https://github.com/schreibfaul1/es8388

Modifique la dirección del dispositivo de 0x1a a 0x10 en el archivo ES8388.cpp

#include <Arduino.h>
#include "ES8388.h"
#include <Wire.h>

#define ES8388_ADDR 0x10

Proceda a escribir este programa

// the pin assignment matches the Olimex ADF board

#include "Arduino.h"
#include "WiFi.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"
#include "Wire.h"
#include "ES8388.h" // https://github.com/maditnerd/es8388

#define SD_CS 13

// GPIOs for SPI
#define SPI_MOSI 15
#define SPI_MISO 2
#define SPI_SCK 14

// I2S GPIOs
#define I2S_SDOUT 26
#define I2S_BCLK 27
#define I2S_LRCK 25
#define I2S_MCLK 0

// I2C GPIOs
#define IIC_CLK 32
#define IIC_DATA 33

// Amplifier enable
#define GPIO_PA_EN GPIO_NUM_21
#define GPIO_SEL_PA_EN GPIO_SEL_21

char ssid[] = "XXXX";
char password[] = "XXXX";

int volume = 100; // 0...100

ES8388 es;
Audio audio;

//----------------------------------------------------------------------------------------------------------------------

void setup()
{
Serial.begin(115200);
Serial.println("\r\nReset");
Serial.printf_P(PSTR("Free mem=%d\n"), ESP.getFreeHeap());

SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
SPI.setFrequency(1000000);

SD.begin(SD_CS);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}

Serial.printf_P(PSTR("Connected\r\nRSSI: "));
Serial.print(WiFi.RSSI());
Serial.print(" IP: ");
Serial.println(WiFi.localIP());

Serial.printf("Connect to ES8388 codec... ");
while (not es.begin(IIC_DATA, IIC_CLK))
{
Serial.printf("Failed!\n");
delay(1000);
}
Serial.printf("OK\n");

es.volume(ES8388::ES_MAIN, volume);
es.volume(ES8388::ES_OUT1, volume);
es.volume(ES8388::ES_OUT2, volume);
es.mute(ES8388::ES_OUT1, false);
es.mute(ES8388::ES_OUT2, false);
es.mute(ES8388::ES_MAIN, false);

// Enable amplifier
pinMode(GPIO_PA_EN, OUTPUT);
digitalWrite(GPIO_PA_EN, HIGH);

audio.setPinout(I2S_BCLK, I2S_LRCK, I2S_SDOUT);
audio.i2s_mclk_pin_select(I2S_MCLK);
audio.setVolume(21); // 0...21

audio.connecttohost("http://mp3channels.webradio.antenne.de:80/oldies-but-goldies");

//audio.connecttoFS(SD, "01/001.mp3");
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de");
}
//----------------------------------------------------------------------------------------------------------------------
void loop()
{
audio.loop();
}
//----------------------------------------------------------------------------------------------------------------------

// optional
void audio_info(const char *info) {
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info) { //id3 metadata
Serial.print("id3data "); Serial.println(info);
}
void audio_eof_mp3(const char *info) { //end of file
Serial.print("eof_mp3 "); Serial.println(info);
}
void audio_showstation(const char *info) {
Serial.print("station "); Serial.println(info);
}
void audio_showstreaminfo(const char *info) {
Serial.print("streaminfo "); Serial.println(info);
}
void audio_showstreamtitle(const char *info) {
Serial.print("streamtitle "); Serial.println(info);
}
void audio_bitrate(const char *info) {
Serial.print("bitrate "); Serial.println(info);
}
void audio_commercial(const char *info) { //duration in sec
Serial.print("commercial "); Serial.println(info);
}
void audio_icyurl(const char *info) { //homepage
Serial.print("icyurl "); Serial.println(info);
}
void audio_lasthost(const char *info) { //stream URL played
Serial.print("lasthost "); Serial.println(info);
}
void audio_eof_speech(const char *info) {
Serial.print("eof_speech "); Serial.println(info);
}

Modificar la linea de la dirección

@vijugo
Copy link

vijugo commented Nov 24, 2021 via email

@indotronic
Copy link

hi, i am get same issues using version 2.3, e3833 IC codec.
the headphone just a sounding

@Dharm94
Copy link

Dharm94 commented Dec 15, 2021

Hi everyone:

First of thanks as this thread helped me a lot. But I'm getting one more error on the same topic.
Screenshot from 2021-12-15 13-25-17

E (1454) gpio: gpio_install_isr_service(460): GPIO isr service already installed
Why this GPIO error is coming on every time when initialization has done. Nothing is getting recorded in wav file.

Using ESP32 Audio Kit V2.2 (3378) & on the backside of A1s (2974)

`esp_err_t get_i2c_pins(i2c_port_t port, i2c_config_t *i2c_config)
{
AUDIO_NULL_CHECK(TAG, i2c_config, return ESP_FAIL);
if (port == I2C_NUM_0 || port == I2C_NUM_1) {
i2c_config->sda_io_num = GPIO_NUM_18;
i2c_config->scl_io_num = GPIO_NUM_23;
} else {
i2c_config->sda_io_num = -1;
i2c_config->scl_io_num = -1;
ESP_LOGE(TAG, "i2c port %d is not supported", port);
return ESP_FAIL;
}
return ESP_OK;
}

esp_err_t get_i2s_pins(i2s_port_t port, i2s_pin_config_t *i2s_config)
{
AUDIO_NULL_CHECK(TAG, i2s_config, return ESP_FAIL);
if (port == I2S_NUM_0 || port == I2S_NUM_1) {
i2s_config->bck_io_num = GPIO_NUM_27;
i2s_config->ws_io_num = GPIO_NUM_25;
i2s_config->data_out_num = GPIO_NUM_26;
i2s_config->data_in_num = GPIO_NUM_35;
} else {
memset(i2s_config, -1, sizeof(i2s_pin_config_t));
ESP_LOGE(TAG, "i2s port %d is not supported", port);
return ESP_FAIL;
}
return ESP_OK;
}
`

I'm able to play MP3 songs from sd using examples but unable to record anything.

@mario44
Copy link

mario44 commented Dec 15, 2021

Hello, I recently bought an ESP32-A1S V2.2 3478
I need a pin description. Has anyone got such a version yet?
esp32-A1S

@superjasiek
Copy link

Well, it looks exactly the same as mine but mine is 3378. I use it for squeezelite player and found some pin configuration:

dac_config": "model=ES8388,bck=27,ws=25,do=26,sda=33,scl=32,i2c=16"
spi_config": "mosi=23,clk=18,dc=5,host=1"
set_GPIO": "21=amp,22=green:0,39=jack:0",

@mario44
Copy link

mario44 commented Dec 15, 2021

@xuhongv Did you have any idea about the 3478 boards ?

@mario44
Copy link

mario44 commented Dec 15, 2021

@superjasiek Thank you very much, I will try!
Could you please define more precisely what it is:
i2c = 16
dc = 5
host = 1

@GillesLACAUD
Copy link

The version on the ESP32 Audio Kit is not important. The difference is in the ESP32-A1S module.
The only way to find the correct mapping (for I2c codec) is to scan the I2C bus and find the correct I2C adress (AC101 or ES8388) and the correct I2C mapping for ES8388 (Lyra Version) or ES8388 (Last version).
The correct (and the last version) is:
Board with ES8388 last version map at I2C pin 32/33

@GillesLACAUD
Copy link

Did someone has some trouble with the TP4065 ?....When the component is in charging mode (only red led on) I can hear some noise and whistle on the audio output.
When the status is Ok (Green led On) the noise disappear.
I have find a workaround....I pull the CE pin for this component

@mario44
Copy link

mario44 commented Dec 15, 2021

My project includes: Internet streaming playback and I2C LCD 1602 display. The problem is that the board sometimes restarts by itself. The es8388 audio codec uses the pins: (IIC_CLK 32, IIC_DATA 33), while the LCD display uses the pins: (IIC_DATA 21, IIC_CLK 23). I am looking for a complete description of all pins for this version 3478.
Below are the pins that I have marked in my code:
#define SD_CS 13

#define SPI_MOSI 15
#define SPI_MISO 2
#define SPI_SCK 14

#define I2S_DOUT 26
#define I2S_BCLK 27
#define I2S_LRC 25
#define I2S_MCLK 0
#define I2S_DIN 35

#define ES8388_IIC_CLK 32
#define ES8388_IIC_DATA 33

#define GPIO_PA_EN 21

#define LED_BUILTIN 22
#define KEY6 5
#define KEY5 18
#define KEY4 23
#define KEY3 19

@RitikDutta
Copy link

I'm able to play MP3 songs from sd using examples but unable to record anything. i also have the same issue does anyone got the solution??

@hogthrob
Copy link

It seems to me that it is possible to distinguish the 2 different variants of the ESP A1S ES8388 module by visual inspection. As previous posters noted, the label 2974 is used on both variants, so this is not the way to do it. However, looking at the right side of the module where the shield leaves an opening (orientation: antenna top), you can see different component layouts. The newer variant with I2C on 33/32 has from left to right 3 very small components and then 2 large capacitors.
The older 23/18 has 1 small component, then the two large capacitors, then 3 more small components (as shown in the "deshieled" picture above (https://user-images.githubusercontent.com/6201950/125838451-b219d7e1-74e5-4b07-af2c-3fb9e27cb558.png). At least this is the difference on my two variants.

Of course, the easiest way is to have the software scan then I2C bus with both pin configurations and see if there is a response.

@Dharm94
Copy link

Dharm94 commented Jan 20, 2022

I'm able to play MP3 songs from sd using examples but unable to record anything. i also have the same issue does anyone got the solution??

Hey Bro!!!! I found the problem and solution too.
If you got the audio output that means now pins config for the audio codec is proper.

After I got an audio output, I read one comment on Github that someone is getting recorded buzzing sound whenever he rubs the finger on mic3 and mic4 pads on PCB.

So basically the problem is in LyraT boards config. It is by default uses AUDIO_HAL_ADC_INPUT_LINE1. But in AudioKit inbuilt microphones are connected on AUDIO_HAL_ADC_INPUT_LINE2.

To change this in your esp-adf edit this file:
/home/......./esp/esp-adf/components/audio_board/lyrat_v4_3/board_def.h

At line number 42 change AUDIO_HAL_ADC_INPUT_LINE1 to AUDIO_HAL_ADC_INPUT_LINE2.

This will record input from microphones and line-in aux pin.

Here is a codec config after change.::::

#define AUDIO_CODEC_DEFAULT_CONFIG(){
.adc_input = AUDIO_HAL_ADC_INPUT_LINE2,
.dac_output = AUDIO_HAL_DAC_OUTPUT_ALL,
.codec_mode = AUDIO_HAL_CODEC_MODE_BOTH,
.i2s_iface = {
.mode = AUDIO_HAL_MODE_SLAVE,
.fmt = AUDIO_HAL_I2S_NORMAL,
.samples = AUDIO_HAL_48K_SAMPLES,
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
},
};

@abubakar1075
Copy link

I'm able to play MP3 songs from sd using examples but unable to record anything. i also have the same issue does anyone got the solution??

Hey Bro!!!! I found the problem and solution too. If you got the audio output that means now pins config for the audio codec is proper.

After I got an audio output, I read one comment on Github that someone is getting recorded buzzing sound whenever he rubs the finger on mic3 and mic4 pads on PCB.

So basically the problem is in LyraT boards config. It is by default uses AUDIO_HAL_ADC_INPUT_LINE1. But in AudioKit inbuilt microphones are connected on AUDIO_HAL_ADC_INPUT_LINE2.

To change this in your esp-adf edit this file: /home/......./esp/esp-adf/components/audio_board/lyrat_v4_3/board_def.h

At line number 42 change AUDIO_HAL_ADC_INPUT_LINE1 to AUDIO_HAL_ADC_INPUT_LINE2.

This will record input from microphones and line-in aux pin.

Here is a codec config after change.::::

#define AUDIO_CODEC_DEFAULT_CONFIG(){ .adc_input = AUDIO_HAL_ADC_INPUT_LINE2, .dac_output = AUDIO_HAL_DAC_OUTPUT_ALL, .codec_mode = AUDIO_HAL_CODEC_MODE_BOTH, .i2s_iface = { .mode = AUDIO_HAL_MODE_SLAVE, .fmt = AUDIO_HAL_I2S_NORMAL, .samples = AUDIO_HAL_48K_SAMPLES, .bits = AUDIO_HAL_BIT_LENGTH_16BITS, }, };

..............Waooooo.... Worked like a magic ... Thank you

@pierluigizagaria
Copy link

pierluigizagaria commented Jun 8, 2022

Hi everyone, I have no luck on getting the jack microphone audio into the board.
Setting AUDIO_HAL_ADC_INPUT_LINE2 will make the built in microphone work without any problem.
The volume is very low on the headphone jack too!
help!

I fixed the headphone out volume as suggested before. Thanks @tttin46

esp_err_t es8388_set_voice_volume(int volume)
{
  esp_err_t res = ESP_OK;
  if (volume < 0)
  volume = 0;
  else if (volume > 100)
  volume = 100;
  volume /= 3;
  res = es_write_reg(ES8388_ADDR, ES8388_DACCONTROL4, volume);
  res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL5, volume);
  res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL24, volume);
  res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL25, volume);
  res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL26, volume);
  res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, volume);
  return res;
}

Still have problem with audio input from jack.

@GrumpyMeow
Copy link

GrumpyMeow commented Aug 18, 2022

Beware for your ears: The code below with a volume of "100" will make the output !LOUD!. The output will be 33db louder compared to previously posted code. So 11times louder (right?).

The code from @pierluigizagaria and @lderani enabled me to control the output volume. Going through the documentation (https://dl.radxa.com/rock2/docs/hw/ds/ES8388%20user%20Guide.pdf) i think there is a small issue to be resolved. The volume of LOUT1, ROUT1, LOUT2 and ROUT2 is set in "+db", while the LDACVOL and RDACVOL are set in "-db". Thus the given code partially negated the output volume. Please see my code as a suggestion (2957 ES8388 board). I here set "0db" to get maximum output/volume:

esp_err_t es8388_set_voice_volume(int volume) 
{ 
    esp_err_t res = ESP_OK; 
    if (volume < 0) volume = 0; else if (volume > 100) volume = 100; 
    volume /= 3; 
    res = es_write_reg(ES8388_ADDR, ES8388_DACCONTROL4, 0); // LDACVOL  0..-96db  in 0.5steps (0=loud, 192=silent)
    res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL5, 0); // RDACVOL 0..-96db  in 0.5steps (0=loud, 192=silent)
    res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL24, volume);  // LOUT1 volume 0..33 dB
    res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL25, volume);  // ROUT1 volume 0..33 dB
    res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL26, volume);  // LOUT2 volume 0..33 dB
    res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, volume);  // ROUT2 volume 0..33 dB
    return res; 
}

@mithy99
Copy link

mithy99 commented Nov 15, 2022

Thank you folks, I've solve a lots of problem with this post.
I am using 2974 version of AI audio kit board

and with faust, I can generate the sound but MIC and Line In never work...
is someone have a solution?

@mithy99
Copy link

mithy99 commented Nov 15, 2022

BTW, I can read es8388 reg with I2C
and set I2S port as mentioned above.

and... today I found the solution

config.adc_input = AUDIO_HAL_ADC_INPUT_LINE2; //set the codec input configuration
config.dac_output = AUDIO_HAL_DAC_OUTPUT_ALL; //set the codec output configuration
config.codec_mode = AUDIO_HAL_CODEC_MODE_BOTH; //set the codec mode
config.i2s_iface.samples = AUDIO_HAL_48K_SAMPLES; //set the sample rate (must match faust)
config.i2s_iface.bits = AUDIO_HAL_BIT_LENGTH_32BITS; //set the bit depth (always 32)

==================================================
AUDIO_HAL_ADC_INPUT_LINE2 should be setting
AUDIO_HAL_ADC_INPUT_ALL dose not working

@pierluigizagaria
Copy link

I could't get the board work with the esp-adf v.2.4.1, anyone managed to get it working?

@mithy99
Copy link

mithy99 commented Nov 29, 2022

Most of solutions are mentioned above.
I had a problem too(still have...) but I made it works according to comments

@johermohit
Copy link

I am using esp32 audiokit v2.2 a149
with espo32a1s 2974
i am not getting any output on speakers , i have tried al most everything nothing seems to be working.

@x-trace
Copy link

x-trace commented Mar 14, 2023

Have a nice day, everyone.
Thanks for the working library! Please add an audio input (example ES8388_IN in). I want to make a mini Wi-Fi+FM+SD station.

Всём хорошего дня.
Спасибо за рабочую библиотеку! Добавьте пожалуйста аудио вход (пример ES8388_IN in). Хочу мини Wi-Fi+FM+SD станцию сделать.

My test board (Моя тестовая плата)
IMG_20230314_232445

@SerdarAbali
Copy link

Due to many irrelevant responses to original post, I am still unsure which pins are correct, what version should use what path to make a succesful compile and play a sample mp3. This post became anything but "Codec initialization fails" and 2957 model. I also have V2.2 2957 and get the same exact error as in first post. Does anyone have any idea if this board is trash, should I waste anymore time or not? So what is the solution?

@lderani
Copy link

lderani commented Jun 26, 2023

Hi everyone,

I posted a set of .zip files that contains the modifications I've made so far to make the ESP32-A1S work with ESP-ADF (4.2.2). See my reply in issue #42 to get the details. I hope it helps!

Luis.

@tbnobody
Copy link

tbnobody commented Nov 1, 2023

I just compared the PDF shown in #26 (comment) with the datasheet shown here: https://docs.ai-thinker.com/_media/esp32-audio-kit_v2.2_sch.pdf

It is either too late in the evening or MIC1 is connected to PIN 17 and 18 which is then internally connected to MIC1N and MIC2P??? Same goes for MIC2 which is connected to pin 14 and 15 which is internally connected to MIC2N and MIC1P??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests