In this project, we will make a simple ESP32 sound recorder, with both sound input and audio output. We will use the MakePyhton ESP32 and voice interaction hat.

I made a music player for ESP32 in the past, and many people are very interested in it. But it has a problem that can play MP3 format audio only. WAV is one of the common music formats, which can be encountered in daily life. I want to refer to the previous audio player for remaking a new one.
I have an idea during the design, I wonder why I didn't add a microphone to the player in which both sound input and audio output can be performed. It sounds like making a simple voice recorder.

1. How Do ESP32 Record Voice and Play

Connect the audio coding chip to ESP32 for collecting sounds and playing audio. Wm8960 is a low power, high quality stereo CODEC, that provides two interface types: voice input and output. The communication between ESP32 and WM8960 is I2S. The Mics have been integrated on the board I design in order to connect to the input interface. And the board provides the 3.5mm audio jack as the player output.

In addition, the board has an SD card slot for suppling the SD card to save the recorded voice. So the player can play the audio file stored in the SD card.

The board is named Voice interface Hat, and the working diagram of the board is as the picture.

2. Bills of Material
1. MakePthon ESP32
2. Voice interaction Hat for MakePython
3. Micro SD card
4. Micro USB cable

3. How to Connect the Components?

Connect two boards according to the pin, Use the USB cable to connect them for power supply.

4. Software
I have programmed it for record and play, and the program is available in Github:
• Please use the Arduino IDE upload program.
• Set the player volume by writing a value to the register.

bool WM8960_Volume(float L_volume,float R_volume)
  L_volume = L_volume * 0xff;
  WM8960_Write_Reg(LEFT_DAC_VOLUME, (uint8_t)L_volume | 0x0100);
  R_volume = R_volume * 0xff;
  WM8960_Write_Reg(RIGHT_DAC_VOLUME, (uint8_t)R_volume | 0x0100);
  return true;


• Record something by the Voice interface hat

void WM8960_Record(String filename, char *buff, int record_time)
    int headerSize = 44;
    byte header[headerSize];
    int waveDataSize = record_time * 16000 * 16 * 2 / 8;
    int recode_time = millis();
    int part_time = recode_time;

    File file =, FILE_WRITE);
    if (!file)

    Serial.println("Begin to record:");

    for (int j = 0; j < waveDataSize / sizeof(buff); ++j)
        I2S_Read(buff, sizeof(buff));
        file.write((const byte *)buff, sizeof(buff));
        if ((millis() - part_time) > 1000)
            part_time = millis();
    CreateWavHeader(header, waveDataSize);
    file.write(header, headerSize);

    Serial.println(millis() - recode_time);


• Play the audio which the format is WAV.

void WM8960_Play (String filename, char *buff)
    File file =;
    if (! file)
    Serial.println("Begin to play:");
    while (file.readBytes(buff, sizeof(buff)))
        I2S_Write(buff, sizeof(buff));


• Set the wifi SSID and password for ESP32 to connect wifi.

const char *ssid = "Makerfabs";
const char *password = "123456789";


5. How to use the ESP32 Sound Recorder

1. After loading the program to ESP32, reset the ESP32.
2. Turn up or down the button at the left of the board to select the menu, press to confirm the selection.
3. After entering the recording function, you need to keep pressing the button until the recording ends.
4. The playback function can display two recording files, one is the current recording completed, and the other is the last recorded file.

6. Result
If the wireless communication function of ESP32 can be used on the transmission of recorded voice, many points can be achieved such as sending recording voice. That sounds interesting. I will try the voice transmission in air next. If you have other ideas about this board, please leave a message to me.


If you have any questions or need custom PCBA service, you're welcome to leave us message to