I recently bought a ESP32 Audio KIt 2.2 A202 and used it with the basic-a2dp-audiokit example. I found that the max volume on the speakers was too low. The suggested workaround using "AI_THINKER_ES8388_VOLUME_HACK 1" did not change anything for me.
The following code change in es8388.c worked for me using bluetooth from a Samsung S20 phone:
esp_err_t es8388_set_voice_volume(int volume)
{
KIT_LOGD("es8388_set_voice_volume: %d", volume);
esp_err_t res = ESP_OK;
if (volume < 0)
volume = 0;
else if (volume > 100)
volume = 100;
//volume /= 3;;
volume = (volume*63)/100; // dataheet says only 6 bits
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, 0);
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, 0);
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL8, 192 >> 2);
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL9, 192 >> 2);
return res;
}
I found that I could use one more bit for the volume (7 instead of 6 bits documented in the datasheet). I also used ES8388_DACCONTROL8/9 to pump up the volume even a bit more.
I recently bought a ESP32 Audio KIt 2.2 A202 and used it with the basic-a2dp-audiokit example. I found that the max volume on the speakers was too low. The suggested workaround using "AI_THINKER_ES8388_VOLUME_HACK 1" did not change anything for me.
The following code change in es8388.c worked for me using bluetooth from a Samsung S20 phone:
esp_err_t es8388_set_voice_volume(int volume) { KIT_LOGD("es8388_set_voice_volume: %d", volume); esp_err_t res = ESP_OK; if (volume < 0) volume = 0; else if (volume > 100) volume = 100; //volume /= 3;; volume = (volume*63)/100; // dataheet says only 6 bits 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, 0); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, 0); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL8, 192 >> 2); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL9, 192 >> 2); return res; }
I found that I could use one more bit for the volume (7 instead of 6 bits documented in the datasheet). I also used ES8388_DACCONTROL8/9 to pump up the volume even a bit more.
Best regards,
Reinhard