Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ESP32 audio kit support #824

Discussion options

Hi everyone!

I bought an ESP32 audio kit module and I saw the Arduino-audio-tools Library.

I would like to know if any of the Arduino examples are useful for my project. I need to record some audio and save it in the SD card in mp3 format without any need for additional components, just the ESP32 audio kit using the microphone and the SD card incorporated on it.

Someone can help me, please?

I will be waiting for your reply.

You must be logged in to vote

Here is an example how you can record audio from the built in microphones to an encoded file.

I would not recommend to use any mp3 or aac encoder because of the limited memory and processing power, but you can try the related encoders. Just read the Wiki.

ps. don't forget to install the AudioKit project! when you want to use the AudioKit together with the AudioTools...

Replies: 7 comments · 5 replies

Comment options

Here is an example how you can record audio from the built in microphones to an encoded file.

I would not recommend to use any mp3 or aac encoder because of the limited memory and processing power, but you can try the related encoders. Just read the Wiki.

ps. don't forget to install the AudioKit project! when you want to use the AudioKit together with the AudioTools...

You must be logged in to vote
1 reply
@anamariarincon03
Comment options

Hi Phil,

I will use the example and if I have any questions I will write to you again.

Thank you!

Answer selected by pschatzmann
Comment options

Hi Phil,

I installed both libraries but I have 2 questions:

  1. Which board should I select in the Arduino to compile the code? I have an ESP32 Audio Kit V2.2 2957.
  2. Do I need to add the line " #define AUDIOKIT_BOARD 1 " to the example you suggested?

Thank you.

You must be logged in to vote
0 replies
Comment options

There is a Readme and a Wiki that should answer all questions!
https://github.com/pschatzmann/arduino-audiokit

You must be logged in to vote
2 replies
@ManginiHearing
Comment options

Hello, thank you for all the amazing work you have done and given freely. I have this same issue. I have struggled with for many hours. I have truly done my best to look for previous answers. I am using your newer Audio Tools and Audio Driver libraries. Do I still download the Arduino Audiokit library and then change the file src/AudioKitSettings.h file to indicate I am using v2.2 2957? In this case by setting
#define AUDIOKIT_BOARD 6
?
If not, is there a similar. .h file in the Audio Driver libraries that I should change?

I am a real newbie / idiot level coder and took "no longer supported" to mean "no longer use this for anything" and didn't download it or take the suggestions in the readme as still appropriate for 2024.

I appreciate your help immensely. Mike

@pschatzmann
Comment options

As specified in the Readme, the AudioKit library is not supported any more: use the arduino-audio-driver library instead!

You find plenty of examples in this project how to use this library (e.g. with the audiokit) so please read the corresponding Wiki in this project: Just try the different drivers: AudioKitAC101,AudioKitEs8388V1,AudioKitEs8388V2 !

One of them will work...

Comment options

Hi Phil,

I noticed that you set the Sample Frequency in 16000 Hz and I have another question, is it possible to change the Sample Frequency to record audio? For example change it to 3000 Hz or 10000 Hz.

I saw the Sample Frequency on the line "AudioInfo info(16000, 1, 16);"

You must be logged in to vote
1 reply
@ansari14
Comment options

how can i set the sample rate in a7672s gsm module ?

Comment options

The wiki of the audiokit project contains the list of supported frequencies!

You must be logged in to vote
0 replies
Comment options

Hello, everyone!

I'm working on a VoIP/intercom project using the ESP32 Audio Kit V2.2 (with ES8388 codec), and I'm facing a very specific issue. ✅ What works:
I can send audio from my PC microphone via TCP socket to the ESP32's audio output (speakers) without any problem.
Wi-Fi connection is stable and working.
I'm using bidirectional TCP, with a main.cpp sketch using Arduino framework, and two Python scripts on the PC (mic_to_esp32.py and esp32_to_speaker.py).
Sending audio from PC to ESP32 is clear and clean.
❌ The problem:
The ESP32 does not send any audio from its onboard microphone to the PC.
Port 5001 (which should send audio from ESP32 to PC) connects, but no sound is transmitted.
I'm using AUDIO_HAL_ADC_INPUT_LINE1 as input device.
I’ve tried with onboard mic and also external mic on LINE IN.
The code compiles fine, no runtime errors, just silence.
🧠 AudioKit Config:

cpp
CopiarEditar
auto cfg = kit.defaultConfig(RXTX_MODE); cfg.input_device = AUDIO_HAL_ADC_INPUT_LINE1; cfg.sample_rate = 16000; cfg.channels = 1; kit.begin(cfg); kit.setVolume(100); ❓ My questions:
What am I missing to make the built-in microphone or LINE1 input of the ESP32 Audio Kit V2.2 work and transmit audio to the PC?
Has anyone succeeded in creating a working full-duplex VoIP project with this board?
Should I move to ESP-ADF instead of Arduino Framework?

Any help, hints or working examples would be greatly appreciated 🙏

Thank you in advance!

[HTML]
#include
#include "AudioTools.h"
#include "AudioLibs/AudioKit.h"
// ======= CONFIGS =======
const char* ssid = "Pandora";
const char* password = "vini5701";
const int port_in = 5000; // Entrada de áudio (fala do PC pro ESP32)
const int port_out = 5001; // Saída de áudio (fala do ESP32 pro PC)
WiFiServer serverIn(port_in);
WiFiServer serverOut(port_out);
AudioKitStream kit;
StreamCopy copierIn;
StreamCopy copierOut;
// ======== TASKS =========
void taskAudioIn(void* param) {
WiFiClient* client = (WiFiClient*)param;
copierIn.begin(kit, client);
while (client->connected()) {
copierIn.copy();
delay(1);
}
client->stop();
delete client;
vTaskDelete(NULL);
}
void taskAudioOut(void
param) {
WiFiClient* client = (WiFiClient*)param;
copierOut.begin(*client, kit);
while (client->connected()) {
copierOut.copy();
delay(1);
}
client->stop();
delete client;
vTaskDelete(NULL);
}
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// Wi-Fi
Serial.println("Conectando ao Wi-Fi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\n✅ Conectado! IP:");
Serial.println(WiFi.localIP());
// Áudio
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sample_rate = 16000;
cfg.channels = 1;
cfg.bits_per_sample = 16;
cfg.input_device = AUDIO_HAL_ADC_INPUT_LINE1; // microfone embutido da ESP32 Audio Kit V2.2
kit.begin(cfg);
kit.setVolume(60); // 🔊 volume ajustado para evitar chiado
serverIn.begin();
serverOut.begin();
Serial.printf("🔊 Porta IN (fala): %d\n", port_in);
Serial.printf("🎤 Porta OUT (mic ): %d\n", port_out);
}
void loop() {
if (serverIn.hasClient()) {
WiFiClient client = serverIn.available();
if (client) {
xTaskCreatePinnedToCore(taskAudioIn, "audioIn", 4096, new WiFiClient(client), 1, NULL, 1);
Serial.println("🔊 Cliente IN conectado");
}
}
if (serverOut.hasClient()) {
WiFiClient client = serverOut.available();
if (client) {
xTaskCreatePinnedToCore(taskAudioOut, "audioOut", 4096, new WiFiClient(client), 1, NULL, 0);
Serial.println("🎤 Cliente OUT conectado");
}
}
delay(100);
}
​[HTML]
[HTML]
[platformio]
default_envs = esp32dev
[env:esp32dev]
platform = espressif32@5.0.0
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
build_flags =
-DAUDIOKIT_BOARD=5
-DCORE_DEBUG_LEVEL=1
-Wno-unused-variable
-Wno-unused-but-set-variable
-Wno-unused-function
-Wno-format-extra-args
lib_deps =
Wire
https://github.com/pschatzmann/arduino-audio-tools.git#v0.9.4
https://github.com/pschatzmann/arduino-audiokit.git#v0.6.3
https://github.com/pschatzmann/arduino-libhelix.git#v0.8
https://github.com/pschatzmann/arduino-libmad.git#v0.7
https://github.com/greiman/SdFat.git#2.2.0
knolleary/PubSubClient@2.8
upload_port = COM3
monitor_port = COM3
[HTML]

You must be logged in to vote
0 replies
Comment options

Please follow the advice given in the Wiki

You must be logged in to vote
1 reply
@viniciusmbs
Comment options

Hello, my name is Vinícius and I'm from Brazil. I really appreciate your time and your response — thank you!

Unfortunately, it didn’t help me much, and I’ll explain why. I’m facing two main challenges:

The language barrier, as I only speak Portuguese.

I’m not an expert in this kind of configuration or audio processing.

I’ve already tested many drivers — including yours, as you can see in my code portfolio. I also tried configuring VoIP, but it gave me many errors with the ESP board. The farthest I got was this:

✅ I can send clear, excellent audio from the computer to the board, and it plays perfectly on the speaker.

❌ But I still can't send audio from the board to the computer — not even for testing.
At one point, I did manage to get a very loud static sound, but I got lost in the code and couldn’t make it work again.

My goal:
I have an old intercom system, and Alexa already notifies me on my phone when someone rings the doorbell.
I can even open the front gate remotely and see who called.
I used to have a camera, but the communication quality was very poor.

Now, I want to place this ESP32 Audio Kit inside the intercom.
When Alexa notifies me, I want to trigger the ESP board via TCP (or VoIP if possible) to communicate.

This is the easiest path I’ve found so far. I really feel that only one small step is missing — just being able to send audio from the ESP board to the PC (or phone). If I can get that working, the entire project will come together.

I truly appreciate all your documentation — it was very valuable. I watched almost all of your videos and reviewed all of your libraries, but unfortunately, I still couldn’t solve it.

I thank you from the bottom of my heart. I’ve been trying for three weeks, and this is the farthest I’ve gotten so far.
I’ll keep trying.

— Vinícius

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.