ESP32 audio recording files to Computer using WAV file

Thread Starter

Brettjohnson7191

Joined Apr 28, 2022
27
C-like:
Simple code is as follows.
const int soundPin = 35;
int sound = 0;
void setup() {
  Serial.begin(9600);
  delay(1000);
}
void loop() {
  sound = analogRead(soundPin);
  Serial.println(sound);
  delay(3);
}
Hello all, I hope this is the correct place for this thread.
I am using an ESP32 with an adafruit max4466 microphone. I am testing the quality of audio files picked up using simple ADC read before switching to different techniques. It would be easy to save the files to an external SD card connected right to the ESP32, but I do not have that at hand currently. So, my question is how can I save my data to a wav file on my laptop to listen to the audio? I do not believe Arduino IDE has the library's to do this so a python script will be needed. So if someone could point me in the right direction that would be greatly appreciated.

And yes I know that reading the values strictly from the ADC will not be a clean nor high quality audio this is just where I am starting this project.



serial plotter shows recognizable sound patterns and confirms its functionality.
 
Last edited by a moderator:

Ya’akov

Joined Jan 27, 2019
8,962
Welcome to AAC.

The simplest way, since you are just prototyping, would probably be a simple serial connection. This doesn’t involve the Arduino IDE, just the computer. You could write a small script to accept the data and convert it to a valid file format. But the gist is, write the file out on serial.

If you want to make it a bit fancy, you can provide a very simple command interface where you can choose to initiate the download by a command from the computer (script), or, you can do something as hackish as putting a button on the ESP32 that starts the transfer. FIrst cat /dev/tty-XXX > sound.dat, then press the button, then ^C, then process the. (For Windows you should be able to do something similar but it‘s been a very long time since I cared about how that would work so I can’t suggest the exact method).

Anyway, other methods such as network transfer seem very heavyweight for what amounts, I expect, to a temporary workaround. Also, consider moving to a board with native USB that can do Mass Storage, then you could write a filesystem to flash and just plug the thing in like a USB drive to read (and write) files.
 

Thread Starter

Brettjohnson7191

Joined Apr 28, 2022
27
Okay So I have successfully read the microphone data in through ADC7 and stored this data into a .txt file on a sd card connected to the ESP32. Now I am not sure how to convert this data to a .wav file. I can not find anything about it online either. Any help is appreciated
 

Thread Starter

Brettjohnson7191

Joined Apr 28, 2022
27
Okay this is bring up more issues. I am getting the understanding that the quality of my audio files is going to be absolutely horrible using just the ADC. I am thinking about aborting and just getting an I2s mic
 
Top